Skip to content
Open
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 @@ -114,7 +114,7 @@ public boolean hasRequestMetadataOnly() {
return true;
}

/** There is no concept of refreshing an API tokens, this method is a no-op. */
/** There is no concept of refreshing an API key, so this method is a no-op. */
@Override
public void refresh() throws IOException {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@

import org.jspecify.annotations.NullMarked;

// an interface to identify retryable errors
/**
* Interface implemented by authentication exceptions that report whether the underlying failure is
* retryable and how many retry attempts were performed.
*/
@NullMarked
public interface Retryable {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ public class AuthHttpConstants {
/** HTTP "Bearer" authentication scheme */
public static final String BEARER = "Bearer";

/** HTTP "Authentication" header */
/** HTTP "Authorization" header */
public static final String AUTHORIZATION = "Authorization";
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
import java.io.IOException;
import org.jspecify.annotations.NullMarked;

/**
* Internal API. This class is public only due to Java's visibility settings. Direct use by
* customers is not recommended, as it may be updated without any backwards compatibility
* guarantees.
*
* <p>Factory for creating the default {@link MtlsProvider} from available client certificate
* sources.
*/
@NullMarked
@InternalApi
public class DefaultMtlsProviderFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ private boolean runningOnAppEngine() {
}
throw new RuntimeException(
String.format(
"Unexpected error trying to determine if runnning on Google App Engine: %s",
"Unexpected error trying to determine if running on Google App Engine: %s",
cause.getMessage()),
cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
* token exchange spec. Indicates the type of the security token in the credential file
* @param tokenUrl the Security Token Service token exchange endpoint
* @param tokenInfoUrl the endpoint used to retrieve account related information. Required for
* gCloud session account identification.
* gcloud session account identification.
* @param credentialSource the external credential source
* @param serviceAccountImpersonationUrl the URL for the service account impersonation request.
* This URL is required for some APIs. If this URL is not available, the access token from the
Expand Down Expand Up @@ -160,7 +160,7 @@
* token exchange spec. Indicates the type of the security token in the credential file
* @param tokenUrl the Security Token Service token exchange endpoint
* @param tokenInfoUrl the endpoint used to retrieve account related information. Required for
* gCloud session account identification.
* gcloud session account identification.
* @param credentialSource the external credential source
* @param serviceAccountImpersonationUrl the URL for the service account impersonation request.
* This URL is required for some APIs. If this URL is not available, the access token from the
Expand Down Expand Up @@ -359,13 +359,14 @@
/**
* Returns credentials defined by a JSON file stream.
*
* <p>Returns {@link IdentityPoolCredentials} or {@link AwsCredentials}.
* <p>Returns {@link IdentityPoolCredentials}, {@link AwsCredentials}, or {@link
* PluggableAuthCredentials}.
*
* <p>Important: If you accept a credential configuration (credential JSON/File/Stream) from an
* 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

Check failure on line 369 in google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java

View workflow job for this annotation

GitHub Actions / BomContentAssertionsTest (Test for assertion logic in BomContentTest)

no tag name after @

Check failure on line 369 in google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java

View workflow job for this annotation

GitHub Actions / bom-content-test

no tag name after @
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
*
* @param credentialsStream the stream with the credential definition
Expand All @@ -380,13 +381,14 @@
/**
* Returns credentials defined by a JSON file stream.
*
* <p>Returns a {@link IdentityPoolCredentials} or {@link AwsCredentials}.
* <p>Returns {@link IdentityPoolCredentials}, {@link AwsCredentials}, or {@link
* PluggableAuthCredentials}.
*
* <p>Important: If you accept a credential configuration (credential JSON/File/Stream) from an
* 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

Check failure on line 391 in google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java

View workflow job for this annotation

GitHub Actions / BomContentAssertionsTest (Test for assertion logic in BomContentTest)

no tag name after @

Check failure on line 391 in google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java

View workflow job for this annotation

GitHub Actions / bom-content-test

no tag name after @
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
*
* @param credentialsStream the stream with the credential definition
Expand Down Expand Up @@ -416,7 +418,7 @@
}

/**
* Returns external account credentials defined by JSON using the format generated by gCloud.
* Returns external account credentials defined by JSON using the format generated by gcloud.
*
* <p>Important: If you accept a credential configuration (credential JSON/File/Stream) from an
* external source for authentication to Google Cloud Platform, you must validate it before
Expand Down Expand Up @@ -932,7 +934,7 @@
}

/**
* Sets the optional endpoint used to retrieve account related information. Required for gCloud
* Sets the optional endpoint used to retrieve account related information. Required for gcloud
* session account identification.
*
* @param tokenInfoUrl the token info url to set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
* OAuth2 credentials for Google Distributed Cloud Hosted (GDCH) service accounts.
*
* <p>Exchanges a locally signed ES256 JWT assertion with the configured GDCH token server to obtain
* short-lived access tokens for a target API audience.
*/
@NullMarked
public class GdchCredentials extends GoogleCredentials {
private static final LoggerProvider LOGGER_PROVIDER =
Expand Down Expand Up @@ -137,14 +143,13 @@
}

/**
* Returns credentials defined by a GdchCredentials key file in JSON format from the Google
* Developers Console.
* Returns credentials defined by a GDCH service account key file in JSON format.
*
* <p>Important: If you accept a credential configuration (credential JSON/File/Stream) from an
* 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

Check failure on line 152 in google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/GdchCredentials.java

View workflow job for this annotation

GitHub Actions / BomContentAssertionsTest (Test for assertion logic in BomContentTest)

no tag name after @

Check failure on line 152 in google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/GdchCredentials.java

View workflow job for this annotation

GitHub Actions / bom-content-test

no tag name after @
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
*
* @param credentialsStream the stream with the credential definition.
Expand All @@ -156,14 +161,13 @@
}

/**
* Returns credentials defined by a GdchCredentials key file in JSON format from the Google
* Developers Console.
* Returns credentials defined by a GDCH service account key file in JSON format.
*
* <p>Important: If you accept a credential configuration (credential JSON/File/Stream) from an
* 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

Check failure on line 170 in google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/GdchCredentials.java

View workflow job for this annotation

GitHub Actions / BomContentAssertionsTest (Test for assertion logic in BomContentTest)

no tag name after @

Check failure on line 170 in google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/GdchCredentials.java

View workflow job for this annotation

GitHub Actions / bom-content-test

no tag name after @
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
*
* @param credentialsStream the stream with the credential definition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class GoogleAuthException extends IOException implements Retryable {
* Creates an instance of the exception based on {@link HttpResponseException} and a custom error
* message.
*
* @see #createWithTokenEndpointResponseException(HttpResponseException, String)
* @see #createWithTokenEndpointResponseException(HttpResponseException)
* @param responseException an instance of {@link HttpResponseException}
* @param message The detail message (which is saved for later retrieval by the {@link
* #getMessage()} method)
Expand Down Expand Up @@ -167,11 +167,11 @@ static GoogleAuthException createWithTokenEndpointIOException(
}

/**
* Creates an instance of the exception based on {@link IOException} returned by Google token
* endpoint. It uses response status code information to populate the {@code #isRetryable}
* property and a number of performed attempts to populate the {@code #retryCount} property
* Creates an instance of the exception based on an {@link IOException} thrown while calling the
* Google token endpoint. Marks the exception as retryable ({@link #isRetryable()} returns {@code
* true}) and sets {@link #getRetryCount()} to the default token endpoint retry count.
*
* @see #createWithTokenEndpointIOException(IOException)
* @see #createWithTokenEndpointIOException(IOException, String)
* @param ioException an instance of {@link IOException}
* @return new instance of {@link GoogleAuthException}
*/
Expand All @@ -185,7 +185,7 @@ public boolean isRetryable() {
return isRetryable;
}

/** Returns number of reties performed for the related HTTP request */
/** Returns number of retries performed for the related HTTP request */
@Override
public int getRetryCount() {
return retryCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@
*
* @return the credentials instance.
* @throws IOException if the credentials cannot be created in the current environment.
* @see <a
* href="https://docs.cloud.google.com/docs/authentication/application-default-credentials#order">Application
* Default Credentials search order</a>
Comment on lines +171 to +173

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The URL domain docs.cloud.google.com is incorrect. The canonical domain for Google Cloud documentation is cloud.google.com.

Suggested change
* @see <a
* href="https://docs.cloud.google.com/docs/authentication/application-default-credentials#order">Application
* Default Credentials search order</a>
* @see <a
* href="https://cloud.google.com/docs/authentication/application-default-credentials#order">Application
* Default Credentials search order</a>

*/
public static GoogleCredentials getApplicationDefault() throws IOException {
return getApplicationDefault(OAuth2Utils.HTTP_TRANSPORT_FACTORY);
Expand All @@ -183,8 +186,12 @@
* <ol>
* <li>Credentials file pointed to by the {@code GOOGLE_APPLICATION_CREDENTIALS} environment
* variable
* <li>Credentials provided by the Google Cloud SDK {@code gcloud auth application-default
* login} command
* <li>Credentials provided by the Google Cloud SDK.
* <ol>
* <li>{@code gcloud auth application-default login} for user account credentials.
* <li>{@code gcloud auth application-default login --impersonate-service-account} for
* impersonated service account credentials.
* </ol>
* <li>Google App Engine built-in credentials
* <li>Google Cloud Shell built-in credentials
* <li>Google Compute Engine built-in credentials
Expand All @@ -194,6 +201,9 @@
* tokens.
* @return the credentials instance.
* @throws IOException if the credentials cannot be created in the current environment.
* @see <a
* href="https://docs.cloud.google.com/docs/authentication/application-default-credentials#order">Application
* Default Credentials search order</a>
Comment on lines +204 to +206

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The URL domain docs.cloud.google.com is incorrect. The canonical domain for Google Cloud documentation is cloud.google.com.

Suggested change
* @see <a
* href="https://docs.cloud.google.com/docs/authentication/application-default-credentials#order">Application
* Default Credentials search order</a>
* @see <a
* href="https://cloud.google.com/docs/authentication/application-default-credentials#order">Application
* Default Credentials search order</a>

*/
public static GoogleCredentials getApplicationDefault(HttpTransportFactory transportFactory)
throws IOException {
Expand Down Expand Up @@ -225,14 +235,18 @@
* <p>Regardless of the method used, it is always your responsibility to validate configurations
* received from external sources.
*
* <p>See the {@see <a

Check failure on line 238 in google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/GoogleCredentials.java

View workflow job for this annotation

GitHub Actions / BomContentAssertionsTest (Test for assertion logic in BomContentTest)

no tag name after @

Check failure on line 238 in google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/GoogleCredentials.java

View workflow job for this annotation

GitHub Actions / bom-content-test

no tag name after @
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}
* for more details.
*
* <p>Returns credentials defined by a JSON file stream.
*
* <p>The stream can contain a Service Account key file in JSON format from the Google Developers
* Console or a stored user credential using the format supported by the Cloud SDK.
* <p>The stream can contain a JSON credential configuration for any supported type: {@link
* ServiceAccountCredentials} ({@code service_account}), {@link UserCredentials} ({@code
* authorized_user}), {@link ExternalAccountCredentials} ({@code external_account}), {@link
* ExternalAccountAuthorizedUserCredentials} ({@code external_account_authorized_user}), {@link
* ImpersonatedCredentials} ({@code impersonated_service_account}), or {@link GdchCredentials}
* ({@code gdch_service_account}).
*
* @param credentialsStream the stream with the credential definition.
* @return the credential defined by the credentialsStream.
Expand Down Expand Up @@ -292,14 +306,18 @@
* <p>Regardless of the method used, it is always your responsibility to validate configurations
* received from external sources.
*
* <p>See the {@see <a

Check failure on line 309 in google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/GoogleCredentials.java

View workflow job for this annotation

GitHub Actions / BomContentAssertionsTest (Test for assertion logic in BomContentTest)

no tag name after @

Check failure on line 309 in google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/GoogleCredentials.java

View workflow job for this annotation

GitHub Actions / bom-content-test

no tag name after @
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}
* for more details.
*
* <p>Returns credentials defined by a JSON file stream.
*
* <p>The stream can contain a Service Account key file in JSON format from the Google Developers
* Console or a stored user credential using the format supported by the Cloud SDK.
* <p>The stream can contain a JSON credential configuration for any supported type: {@link
* ServiceAccountCredentials} ({@code service_account}), {@link UserCredentials} ({@code
* authorized_user}), {@link ExternalAccountCredentials} ({@code external_account}), {@link
* ExternalAccountAuthorizedUserCredentials} ({@code external_account_authorized_user}), {@link
* ImpersonatedCredentials} ({@code impersonated_service_account}), or {@link GdchCredentials}
* ({@code gdch_service_account}).
*
* @param credentialsStream the stream with the credential definition.
* @return the credential defined by the credentialsStream.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ public interface CredentialsChangedListener {
* This is typically used by code caching the access token.
*
* @param credentials The updated credentials instance
* @throws IOException My be thrown by listeners if saving credentials fails.
* @throws IOException May be thrown by listeners if saving credentials fails.
*/
void onChanged(OAuth2Credentials credentials) throws IOException;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@

import org.jspecify.annotations.NullMarked;

/**
* Provider of Proof Key for Code Exchange (PKCE) parameters ({@code code_verifier}, {@code
* code_challenge}, and {@code code_challenge_method}) for OAuth 2.0 authorization flows as defined
* in <a href="https://datatracker.ietf.org/doc/html/rfc7636">RFC 7636</a>.
*/
@NullMarked
public interface PKCEProvider {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private UserAuthorizer(Builder builder) {
}

/**
* Returns the Client ID user to identify the OAuth2 consent prompt.
* Returns the Client ID used to identify the OAuth2 consent prompt.
*
* @return The Client ID.
*/
Expand Down
Loading