Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
* <p>Credentials with type {@code CredentialTypeForMetrics.DO_NOT_SEND} is default value for
* credential implementations that do not set type specifically. It is not expected to send metrics.
*
* <p>
*
* @see #getLabel()
*/
@NullMarked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,19 @@ public class AwsCredentialSource extends ExternalAccountCredentials.CredentialSo
final @Nullable String imdsv2SessionTokenUrl;

/**
* The source of the AWS credential. The credential source map must contain the
* `regional_cred_verification_url` field.
* The source of the AWS credential. The credential source map must contain the {@code
* regional_cred_verification_url} and {@code environment_id} fields.
*
* <p>The `regional_cred_verification_url` is the regional GetCallerIdentity action URL, used to
* determine the account ID and its roles.
* <p>The {@code regional_cred_verification_url} is the regional GetCallerIdentity action URL,
* used to determine the account ID and its roles.
*
* <p>The `environment_id` is the environment identifier, in the format “aws${version}”. This
* indicates whether breaking changes were introduced to the underlying AWS implementation.
* <p>The {@code environment_id} is the environment identifier, in the format {@code
* aws${version}}. This indicates whether breaking changes were introduced to the underlying AWS
* implementation.
*
* <p>The `region_url` identifies the targeted region. Optional.
* <p>The {@code region_url} identifies the targeted region. Optional.
*
* <p>The `url` locates the metadata server used to retrieve the AWS credentials. Optional.
* <p>The {@code url} locates the metadata server used to retrieve the AWS credentials. Optional.
*/
public AwsCredentialSource(Map<String, Object> credentialSourceMap) {
super(credentialSourceMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ public Builder setAwsSecurityCredentialsSupplier(
/**
* Sets the AWS regional credential verification URL. If set, will override any credential
* verification URL provided in the credential source. If not set, the credential verification
* URL will default to
* `https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&amp;Version=2011-06-15`
* URL will default to {@code
* https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15}
*
* @param regionalCredentialVerificationUrlOverride the AWS credential verification url to set.
* @return this {@code Builder} object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public interface AwsSecurityCredentialsSupplier extends Serializable {
*
* @param context relevant context from the calling credential.
* @return the AWS region that should be used for the credential.
* @throws IOException
* @throws IOException if retrieving the AWS region fails.
*/
String getRegion(ExternalAccountSupplierContext context) throws IOException;

Expand All @@ -56,7 +56,7 @@ public interface AwsSecurityCredentialsSupplier extends Serializable {
*
* @param context relevant context from the calling credential.
* @return valid AWS security credentials that can be exchanged for a GCP access token.
* @throws IOException
* @throws IOException if retrieving the AWS security credentials fails.
*/
AwsSecurityCredentials getCredentials(ExternalAccountSupplierContext context) throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,13 @@ public AccessToken refreshAccessToken() throws IOException {
*
* @param targetAudience the aud: field the IdToken should include
* @param options list of Credential specific options for the token. For example, an IDToken for a
* ComputeEngineCredential could have the full formatted claims returned if
* IdTokenProvider.Option.FORMAT_FULL) is provided as a list option. Valid option values are:
* {@link ComputeEngineCredentials} could have the full formatted claims returned if {@link
* IdTokenProvider.Option#FORMAT_FULL} is provided as a list option. Valid option values are:
* <br>
* IdTokenProvider.Option.FORMAT_FULL<br>
* IdTokenProvider.Option.LICENSES_TRUE<br>
* IdTokenProvider.Option.DISABLE_BOUND_ID_TOKEN (request an ID token that is not bound to the
* agent identity certificate)<br>
* {@link IdTokenProvider.Option#FORMAT_FULL}<br>
* {@link IdTokenProvider.Option#LICENSES_TRUE}<br>
* {@link IdTokenProvider.Option#DISABLE_BOUND_ID_TOKEN} (request an ID token that is not
* bound to the agent identity certificate)<br>
* If no options are set, the defaults are "&amp;format=standard&amp;licenses=false"
* @throws IOException if the attempt to get an IdToken failed
* @return IdToken object which includes the raw id_token, JsonWebSignature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ class ExecutableResponse {
}

/**
* Returns the version of the executable output. Only version `1` is currently supported. This is
* useful for future changes to the expected output format.
* Returns the version of the executable output. Only version {@code 1} is currently supported.
* This is useful for future changes to the expected output format.
*
* @return The version of the JSON output.
*/
Expand All @@ -125,7 +125,7 @@ int getVersion() {
* operation. When this is false, the response should contain an additional error code and
* message.
*
* @return Whether the `success` field in the executable response is true.
* @return Whether the {@code success} field in the executable response is true.
*/
boolean isSuccessful() {
return this.success;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ private ExternalAccountAuthorizedUserCredentials(Builder builder) {
* external source for authentication to Google Cloud Platform, you must validate it before
* providing it to any Google API or library. Providing an unvalidated credential configuration to
* Google APIs can compromise the security of your systems and data. For more information, refer
* to {@see <a
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
* to <a
* href="https://docs.cloud.google.com/docs/authentication/client-libraries#external-credentials">documentation</a>.
*
* @param credentialsStream the stream with the credential definition
* @return the credential defined by the credentialsStream
Expand All @@ -153,8 +153,8 @@ public static ExternalAccountAuthorizedUserCredentials fromStream(InputStream cr
* external source for authentication to Google Cloud Platform, you must validate it before
* providing it to any Google API or library. Providing an unvalidated credential configuration to
* Google APIs can compromise the security of your systems and data. For more information, refer
* to {@see <a
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
* to <a
* href="https://docs.cloud.google.com/docs/authentication/client-libraries#external-credentials">documentation</a>.
*
* @param credentialsStream the stream with the credential definition
* @param transportFactory the HTTP transport factory used to create the transport to get access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ public Map<String, List<String>> getRequestMetadata(@Nullable URI uri) throws IO
* external source for authentication to Google Cloud Platform, you must validate it before
* providing it to any Google API or library. Providing an unvalidated credential configuration to
* Google APIs can compromise the security of your systems and data. For more information, refer
* to {@see <a
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
* to <a
* href="https://docs.cloud.google.com/docs/authentication/client-libraries#external-credentials">documentation</a>.
*
* @param credentialsStream the stream with the credential definition
* @return the credential defined by the credentialsStream
Expand All @@ -386,8 +386,8 @@ public static ExternalAccountCredentials fromStream(InputStream credentialsStrea
* external source for authentication to Google Cloud Platform, you must validate it before
* providing it to any Google API or library. Providing an unvalidated credential configuration to
* Google APIs can compromise the security of your systems and data. For more information, refer
* to {@see <a
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
* to <a
* href="https://docs.cloud.google.com/docs/authentication/client-libraries#external-credentials">documentation</a>.
*
* @param credentialsStream the stream with the credential definition
* @param transportFactory the HTTP transport factory used to create the transport to get access
Expand Down Expand Up @@ -422,8 +422,8 @@ public static ExternalAccountCredentials fromStream(
* external source for authentication to Google Cloud Platform, you must validate it before
* providing it to any Google API or library. Providing an unvalidated credential configuration to
* Google APIs can compromise the security of your systems and data. For more information, refer
* to {@link <a
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
* to <a
* href="https://docs.cloud.google.com/docs/authentication/client-libraries#external-credentials">documentation</a>.
*
* @param json a map from the JSON representing the credentials
* @param transportFactory HTTP transport factory, creates the transport used to get access tokens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ public class GdchCredentials extends GoogleCredentials {
* external source for authentication to Google Cloud Platform, you must validate it before
* providing it to any Google API or library. Providing an unvalidated credential configuration to
* Google APIs can compromise the security of your systems and data. For more information, refer
* to {@see <a
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
* to <a
* href="https://docs.cloud.google.com/docs/authentication/client-libraries#external-credentials">documentation</a>.
*
* @param credentialsStream the stream with the credential definition.
* @return the credential defined by the credentialsStream.
Expand All @@ -163,8 +163,8 @@ public static GdchCredentials fromStream(InputStream credentialsStream) throws I
* external source for authentication to Google Cloud Platform, you must validate it before
* providing it to any Google API or library. Providing an unvalidated credential configuration to
* Google APIs can compromise the security of your systems and data. For more information, refer
* to {@see <a
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
* to <a
* href="https://docs.cloud.google.com/docs/authentication/client-libraries#external-credentials">documentation</a>.
*
* @param credentialsStream the stream with the credential definition.
* @param transportFactory HTTP transport factory, creates the transport used to get access
Expand Down Expand Up @@ -285,7 +285,7 @@ static GdchCredentials fromPem(String privateKeyPem, GdchCredentials.Builder bui
}

/**
* This method is obsolete. Please use {@link #createWithGdchAudience(String)}} instead. Create a
* This method is obsolete. Please use {@link #createWithGdchAudience(String)} instead. Create a
* copy of GDCH credentials with the specified audience.
*
* @param apiAudience The intended audience for GDCH credentials.
Expand Down Expand Up @@ -377,8 +377,9 @@ public AccessToken refreshAccessToken() throws IOException {
* Create a self-signed JWT for GDCH authentication flow.
*
* <p>The self-signed JWT is used to exchange access token from GDCH authentication
* (tokenServerUri), not for API call. It uses the serviceIdentityName as the `iss` and `sub`
* claim, and the tokenServerUri as the `aud` claim. The JWT is signed with the privateKey.
* (tokenServerUri), not for API call. It uses {@link #getIssuerSubjectValue(String, String)} as
* the {@code iss} and {@code sub} claims, and the tokenServerUri as the {@code aud} claim. The
* JWT is signed with the privateKey.
*/
String createAssertion(JsonFactory jsonFactory, long currentTime) throws IOException {
JsonWebSignature.Header header = new JsonWebSignature.Header();
Expand Down Expand Up @@ -407,8 +408,8 @@ String createAssertion(JsonFactory jsonFactory, long currentTime) throws IOExcep
/**
* Get the issuer and subject value in the format GDCH token server required.
*
* <p>This value is specific to GDCH and combined parameter used for both `iss` and `sub` fields
* in JWT claim.
* <p>This value is specific to GDCH and combined parameter used for both {@code iss} and {@code
* sub} fields in JWT claim.
*/
@VisibleForTesting
static String getIssuerSubjectValue(String projectId, String serviceIdentityName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ public static GoogleCredentials getApplicationDefault(HttpTransportFactory trans
* used without validation on your side.
*
* <p>If you know that you will be loading credential configurations of a specific type, it is
* recommended to use a credential-type-specific `fromStream()` method. This will ensure that an
* unexpected credential type with potential for malicious intent is not loaded unintentionally.
* You might still have to do validation for certain credential types. Please follow the
* recommendation for that method. For example, if you want to load only service accounts, you can
* use: <code>
* recommended to use a credential-type-specific {@code fromStream()} method. This will ensure
* that an unexpected credential type with potential for malicious intent is not loaded
* unintentionally. You might still have to do validation for certain credential types. Please
* follow the recommendation for that method. For example, if you want to load only service
* accounts, you can use: <code>
* GoogleCredentials credentials = ServiceAccountCredentials.fromStream(json);
* </code>. See {@link ServiceAccountCredentials#fromStream(InputStream, HttpTransportFactory)}.
*
Expand All @@ -225,8 +225,8 @@ public static GoogleCredentials getApplicationDefault(HttpTransportFactory trans
* <p>Regardless of the method used, it is always your responsibility to validate configurations
* received from external sources.
*
* <p>See the {@see <a
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}
* <p>See the <a
* href="https://docs.cloud.google.com/docs/authentication/client-libraries#external-credentials">documentation</a>
* for more details.
*
* <p>Returns credentials defined by a JSON file stream.
Expand Down Expand Up @@ -277,11 +277,11 @@ static String extractFromJson(Map<String, Object> json, String field) throws IOE
* used without validation on your side.
*
* <p>If you know that you will be loading credential configurations of a specific type, it is
* recommended to use a credential-type-specific `fromStream()` method. This will ensure that an
* unexpected credential type with potential for malicious intent is not loaded unintentionally.
* You might still have to do validation for certain credential types. Please follow the
* recommendation for that method. For example, if you want to load only service accounts, you can
* use: <code>
* recommended to use a credential-type-specific {@code fromStream()} method. This will ensure
* that an unexpected credential type with potential for malicious intent is not loaded
* unintentionally. You might still have to do validation for certain credential types. Please
* follow the recommendation for that method. For example, if you want to load only service
* accounts, you can use: <code>
* GoogleCredentials credentials = ServiceAccountCredentials.fromStream(json);
* </code>. See {@link ServiceAccountCredentials#fromStream(InputStream, HttpTransportFactory)}.
*
Expand All @@ -292,8 +292,8 @@ static String extractFromJson(Map<String, Object> json, String field) throws IOE
* <p>Regardless of the method used, it is always your responsibility to validate configurations
* received from external sources.
*
* <p>See the {@see <a
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}
* <p>See the <a
* href="https://docs.cloud.google.com/docs/authentication/client-libraries#external-credentials">documentation</a>
* for more details.
*
* <p>Returns credentials defined by a JSON file stream.
Expand All @@ -302,6 +302,8 @@ static String extractFromJson(Map<String, Object> json, String field) throws IOE
* Console or a stored user credential using the format supported by the Cloud SDK.
*
* @param credentialsStream the stream with the credential definition.
* @param transportFactory HTTP transport factory, creates the transport used to get access
* tokens.
* @return the credential defined by the credentialsStream.
* @throws IOException if the credential cannot be created from the stream.
*/
Expand Down Expand Up @@ -494,6 +496,8 @@ protected GoogleCredentials(Builder builder) {
* {@link Builder#setUniverseDomain(String)}) to specify the universe domain explicitly.
*
* @param accessToken initial or temporary access token
* @param refreshMargin margin before expiration to trigger an asynchronous refresh
* @param expirationMargin margin before expiration to treat the token as expired
* @deprecated Use {@link #GoogleCredentials(Builder)} for subclasses, or {@link #newBuilder()}
* with {@link Builder#setAccessToken(AccessToken)} and {@link
* Builder#setUniverseDomain(String)} for a non-default universe domain.
Expand Down Expand Up @@ -655,14 +659,14 @@ GoogleCredentials withSource(String source) {
* <li>principal - Identity used for the credential
* </ul>
*
* Unknown field values (i.e. null) are not included in the mapping (e.g. ComputeCredentials may
* not know the principal value until after a call to MDS is made and the field will be excluded
* if `getCredentialInfo` is called prior to retrieving that value). A new map of the fields is
* created on every time this method is called as fields may be updated throughout the Credential
* lifecycle. This mapping is intended to provide information about the Credential that is created
* via ADC. Some fields may not be known if a Credential is directly created (e.g.
* `ServiceAccountCredential.fromStream(InputStream)` may not know the source of the file stream).
* These fields are populated on a best effort basis.
* Unknown field values (i.e. null) are not included in the mapping (e.g. {@link
* ComputeEngineCredentials} may not know the principal value until after a call to MDS is made
* and the field will be excluded if {@link #getCredentialInfo()} is called prior to retrieving
* that value). A new map of the fields is created every time this method is called as fields may
* be updated throughout the Credential lifecycle. This mapping is intended to provide information
* about the Credential that is created via ADC. Some fields may not be known if a Credential is
* directly created (e.g. {@link ServiceAccountCredentials#fromStream(InputStream)} may not know
* the source of the file stream). These fields are populated on a best effort basis.
*
* @return ImmutableMap of information regarding how the Credential was initialized
*/
Expand Down
Loading