58
58
/**
59
59
* Base external account credentials class.
60
60
*
61
- * <p>Handles initializing external credentials, calls to STS, and service account impersonation.
61
+ * <p>Handles initializing external credentials, calls to the Security Token Service, and service
62
+ * account impersonation.
62
63
*/
63
64
public abstract class ExternalAccountCredentials extends GoogleCredentials
64
65
implements QuotaProjectIdProvider {
@@ -89,8 +90,9 @@ abstract static class CredentialSource {
89
90
@ Nullable private final String clientId ;
90
91
@ Nullable private final String clientSecret ;
91
92
92
- // This is used for Workforce Pools. It is passed to STS during token exchange in the
93
- // `options` param and will be embedded in the token by STS.
93
+ // This is used for Workforce Pools. It is passed to the Security Token Service during token
94
+ // exchange in the `options` param and will be embedded in the token by the Security Token
95
+ // Service.
94
96
@ Nullable private final String workforcePoolUserProject ;
95
97
96
98
protected transient HttpTransportFactory transportFactory ;
@@ -104,18 +106,17 @@ abstract static class CredentialSource {
104
106
* workforce credentials.
105
107
*
106
108
* @param transportFactory HTTP transport factory, creates the transport used to get access tokens
107
- * @param audience the STS audience which is usually the fully specified resource name of the
108
- * workload/workforce pool provider
109
- * @param subjectTokenType the STS subject token type based on the OAuth 2.0 token exchange spec.
110
- * Indicates the type of the security token in the credential file
111
- * @param tokenUrl the STS token exchange endpoint
109
+ * @param audience the Security Token Service audience, which is usually the fully specified
110
+ * resource name of the workload/workforce pool provider
111
+ * @param subjectTokenType the Security Token Service subject token type based on the OAuth 2.0
112
+ * token exchange spec. Indicates the type of the security token in the credential file
113
+ * @param tokenUrl the Security Token Service token exchange endpoint
112
114
* @param tokenInfoUrl the endpoint used to retrieve account related information. Required for
113
115
* gCloud session account identification.
114
116
* @param credentialSource the external credential source
115
117
* @param serviceAccountImpersonationUrl the URL for the service account impersonation request.
116
- * This is only required for workload identity pools when APIs to be accessed have not
117
- * integrated with UberMint. If this is not available, the STS returned GCP access token is
118
- * directly used. May be null.
118
+ * This URL is required for some APIs. If this URL is not available, the access token from the
119
+ * Security Token Service is used directly. May be null.
119
120
* @param quotaProjectId the project used for quota and billing purposes. May be null.
120
121
* @param clientId client ID of the service account from the console. May be null.
121
122
* @param clientSecret client secret of the service account from the console. May be null.
@@ -395,11 +396,11 @@ private static boolean isAwsCredential(Map<String, Object> credentialSource) {
395
396
}
396
397
397
398
/**
398
- * Exchanges the external credential for a GCP access token.
399
+ * Exchanges the external credential for a Google Cloud access token.
399
400
*
400
- * @param stsTokenExchangeRequest the STS token exchange request
401
- * @return the access token returned by STS
402
- * @throws OAuthException if the call to STS fails
401
+ * @param stsTokenExchangeRequest the Security Token Service token exchange request
402
+ * @return the access token returned by the Security Token Service
403
+ * @throws OAuthException if the call to the Security Token Service fails
403
404
*/
404
405
protected AccessToken exchangeExternalCredentialForAccessToken (
405
406
StsTokenExchangeRequest stsTokenExchangeRequest ) throws IOException {
@@ -413,7 +414,8 @@ protected AccessToken exchangeExternalCredentialForAccessToken(
413
414
tokenUrl , stsTokenExchangeRequest , transportFactory .create ().createRequestFactory ());
414
415
415
416
// If this credential was initialized with a Workforce configuration then the
416
- // workforcePoolUserProject must passed to STS via the the internal options param.
417
+ // workforcePoolUserProject must be passed to the Security Token Service via the internal
418
+ // options param.
417
419
if (isWorkforcePoolConfiguration ()) {
418
420
GenericJson options = new GenericJson ();
419
421
options .setFactory (OAuth2Utils .JSON_FACTORY );
@@ -431,7 +433,7 @@ protected AccessToken exchangeExternalCredentialForAccessToken(
431
433
}
432
434
433
435
/**
434
- * Retrieves the external subject token to be exchanged for a GCP access token.
436
+ * Retrieves the external subject token to be exchanged for a Google Cloud access token.
435
437
*
436
438
* <p>Must be implemented by subclasses as the retrieval method is dependent on the credential
437
439
* source.
@@ -603,24 +605,24 @@ public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) {
603
605
}
604
606
605
607
/**
606
- * Sets the STS audience which is usually the fully specified resource name of the
607
- * workload/workforce pool provider.
608
+ * Sets the Security Token Service audience, which is usually the fully specified resource name
609
+ * of the workload/workforce pool provider.
608
610
*/
609
611
public Builder setAudience (String audience ) {
610
612
this .audience = audience ;
611
613
return this ;
612
614
}
613
615
614
616
/**
615
- * Sets the STS subject token type based on the OAuth 2.0 token exchange spec. Indicates the
616
- * type of the security token in the credential file.
617
+ * Sets the Security Token Service subject token type based on the OAuth 2.0 token exchange
618
+ * spec. Indicates the type of the security token in the credential file.
617
619
*/
618
620
public Builder setSubjectTokenType (String subjectTokenType ) {
619
621
this .subjectTokenType = subjectTokenType ;
620
622
return this ;
621
623
}
622
624
623
- /** Sets the STS token exchange endpoint. */
625
+ /** Sets the Security Token Service token exchange endpoint. */
624
626
public Builder setTokenUrl (String tokenUrl ) {
625
627
this .tokenUrl = tokenUrl ;
626
628
return this ;
@@ -633,9 +635,9 @@ public Builder setCredentialSource(CredentialSource credentialSource) {
633
635
}
634
636
635
637
/**
636
- * Sets the optional URL used for service account impersonation. This is only required when APIs
637
- * to be accessed have not integrated with UberMint . If this is not available, the STS returned
638
- * GCP access token is directly used .
638
+ * Sets the optional URL used for service account impersonation, which is required for some
639
+ * APIs . If this URL is not available, the access token from the Security Token Service is used
640
+ * directly.
639
641
*/
640
642
public Builder setServiceAccountImpersonationUrl (String serviceAccountImpersonationUrl ) {
641
643
this .serviceAccountImpersonationUrl = serviceAccountImpersonationUrl ;
0 commit comments