File tree Expand file tree Collapse file tree 3 files changed +21
-10
lines changed
java/com/google/auth/credentialaccessboundary
oauth2_http/javatests/com/google/auth/oauth2 Expand file tree Collapse file tree 3 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,22 @@ private ClientSideCredentialAccessBoundaryFactory(Builder builder) {
6161 this .tokenExchangeEndpoint = builder .tokenExchangeEndpoint ;
6262 }
6363
64+ /**
65+ * Refreshes the source credential and exchanges it for an intermediary access token using the STS
66+ * endpoint.
67+ *
68+ * <p>If the source credential is expired, it will be refreshed. A token exchange request is then
69+ * made to the STS endpoint. The resulting intermediary access token and access boundary session
70+ * key are stored. The intermediary access token's expiration time is determined as follows:
71+ *
72+ * <ol>
73+ * <li>If the STS response includes `expires_in`, that value is used.
74+ * <li>Otherwise, if the source credential has an expiration time, that value is used.
75+ * <li>Otherwise, the intermediary token will have no expiration time.
76+ * </ol>
77+ *
78+ * @throws IOException If an error occurs during credential refresh or token exchange.
79+ */
6480 private void refreshCredentials () throws IOException {
6581 try {
6682 this .sourceCredential .refreshIfExpired ();
@@ -70,7 +86,7 @@ private void refreshCredentials() throws IOException {
7086
7187 AccessToken sourceAccessToken = sourceCredential .getAccessToken ();
7288 if (sourceAccessToken == null || Strings .isNullOrEmpty (sourceAccessToken .getTokenValue ())) {
73- throw new IOException ("The source credential does not have an access token." );
89+ throw new IllegalStateException ("The source credential does not have an access token." );
7490 }
7591
7692 StsTokenExchangeRequest request =
Original file line number Diff line number Diff line change 2020 <dependency >
2121 <groupId >com.google.auth</groupId >
2222 <artifactId >google-auth-library-oauth2-http</artifactId >
23- <version >${project.version} </version >
2423 </dependency >
2524 <dependency >
2625 <groupId >com.google.auth</groupId >
2726 <artifactId >google-auth-library-credentials</artifactId >
28- <version >1.29.1-SNAPSHOT</version >
2927 </dependency >
3028 <dependency >
3129 <groupId >com.google.http-client</groupId >
3230 <artifactId >google-http-client</artifactId >
33- <version >1.45.0</version >
3431 </dependency >
3532 <dependency >
3633 <groupId >com.google.errorprone</groupId >
3734 <artifactId >error_prone_annotations</artifactId >
38- <version >2.35.1</version >
3935 </dependency >
4036 <dependency >
4137 <groupId >com.google.guava</groupId >
4238 <artifactId >guava</artifactId >
43- <version >33.3.1-android</version >
4439 </dependency >
4540 </dependencies >
4641
47- </project >
42+ </project >
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ public final class MockStsTransport extends MockHttpTransport {
6565 private static final String ACCESS_TOKEN = "accessToken" ;
6666 private static final String TOKEN_TYPE = "Bearer" ;
6767 private static final Long EXPIRES_IN = 3600L ;
68- private static final String ACCESS_BOUNDARY_SESSION_KEY = "accessBoundarySessionKey" ;
68+ private static final String ACCESS_BOUNDARY_SESSION_KEY_VALUE = "accessBoundarySessionKey" ;
6969
7070 private final Queue <IOException > responseErrorSequence = new ArrayDeque <>();
7171 private final Queue <List <String >> scopeSequence = new ArrayDeque <>();
@@ -137,7 +137,7 @@ public LowLevelHttpResponse execute() throws IOException {
137137 }
138138
139139 if (returnAccessBoundarySessionKey ) {
140- response .put ("access_boundary_session_key" , ACCESS_BOUNDARY_SESSION_KEY );
140+ response .put ("access_boundary_session_key" , ACCESS_BOUNDARY_SESSION_KEY_VALUE );
141141 }
142142
143143 return new MockLowLevelHttpResponse ()
@@ -177,7 +177,7 @@ public Long getExpiresIn() {
177177 }
178178
179179 public String getAccessBoundarySessionKey () {
180- return ACCESS_BOUNDARY_SESSION_KEY ;
180+ return ACCESS_BOUNDARY_SESSION_KEY_VALUE ;
181181 }
182182
183183 public void setReturnExpiresIn (boolean returnExpiresIn ) {
You can’t perform that action at this time.
0 commit comments