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 @@ -74,7 +74,7 @@
}

/** A getter for the credentials instance being used */
public Credentials getCredentials() {

Check warning on line 77 in google-auth-library-java/oauth2_http/java/com/google/auth/http/HttpCredentialsAdapter.java

View workflow job for this annotation

GitHub Actions / bom-content-test

Check warning on line 77 in google-auth-library-java/oauth2_http/java/com/google/auth/http/HttpCredentialsAdapter.java

View workflow job for this annotation

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

return credentials;
}

Expand Down Expand Up @@ -113,11 +113,11 @@
* {@inheritDoc}
*
* <p>Checks if {@code WWW-Authenticate} exists and contains a "Bearer" value (see <a
* href="http://tools.ietf.org/html/rfc6750#section-3.1">rfc6750 section 3.1</a> for more
* details). If so, it refreshes the token in case the error code contains {@code invalid_token}.
* If there is no "Bearer" in {@code WWW-Authenticate} and the status code is {@link
* HttpStatusCodes#STATUS_CODE_UNAUTHORIZED} it refreshes the token. If the token refresh throws
* an I/O exception, this implementation will log the exception and return {@code false}.
* href="https://datatracker.ietf.org/doc/html/rfc6750#section-3.1">RFC 6750 Section 3.1</a> for
* more details). If so, it refreshes the token in case the error code contains {@code
* invalid_token}. If there is no "Bearer" in {@code WWW-Authenticate} and the status code is
* {@link HttpStatusCodes#STATUS_CODE_UNAUTHORIZED} it refreshes the token. If the token refresh
* throws an I/O exception, this implementation will log the exception and return {@code false}.
*/
@Override
public boolean handleResponse(HttpRequest request, HttpResponse response, boolean supportsRetry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
* MtlsProvider is used by the Gax library for configuring mutual TLS in the HTTP and GRPC transport
* layer. The source of the client certificate is up to the implementation.
*
* <p>Note: This interface will replace the identically named "MtlsProvider" implementation in the
* Gax library. The Gax library version of MtlsProvider will be marked as deprecated. See
* https://github.com/googleapis/google-auth-library-java/issues/1758
* <p>Note: This interface replaces the deprecated {@code com.google.api.gax.rpc.mtls.MtlsProvider}
* class in GAX. See <a href="https://google.aip.dev/auth/4114">AIP-4114</a> for device certificate
* mutual TLS details.
*/
@NullMarked
public interface MtlsProvider {
Expand All @@ -59,5 +59,5 @@
*
* @throws IOException if a general I/O error occurs while determining availability.
*/
boolean isAvailable() throws IOException;

Check warning on line 62 in google-auth-library-java/oauth2_http/java/com/google/auth/mtls/MtlsProvider.java

View workflow job for this annotation

GitHub Actions / bom-content-test

Check warning on line 62 in google-auth-library-java/oauth2_http/java/com/google/auth/mtls/MtlsProvider.java

View workflow job for this annotation

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
import org.jspecify.annotations.NullMarked;

/**
* The acting party as defined in <a href="https://tools.ietf.org/html/rfc8693">OAuth 2.0 Token
* Exchange</a>.
* The acting party as defined in <a
* href="https://datatracker.ietf.org/doc/html/rfc8693#section-2.1">OAuth 2.0 Token Exchange (RFC
* 8693, Section 2.1)</a>.
*/
@NullMarked
final class ActingParty {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
* <p>Fetches access tokens from the Google Compute Engine metadata server. When a workload
* certificate for an agent identity is available, requests certificate-bound access tokens and ID
* tokens by default (see {@code IdTokenProvider.Option.DISABLE_BOUND_ID_TOKEN} and the <a
* href="https://cloud.google.com/java/getting-started/getting-started-with-google-auth-library#certificate-bound-tokens-for-agent-identities">Google
* href="https://docs.cloud.google.com/java/getting-started/getting-started-with-google-auth-library#certificate-bound-tokens-for-agent-identities">Google
* Auth Library guide</a>).
*
* <p>These credentials use the IAM API to sign data. See {@link #sign(byte[])} for more details.
Expand Down Expand Up @@ -879,7 +879,7 @@ public String getAccount() {
* @return signed bytes
* @throws SigningException if the attempt to sign the provided bytes failed
* @see <a
* href="https://cloud.google.com/iam/credentials/reference/rest/v1/projects.serviceAccounts/signBlob">Blob
* href="https://docs.cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/signBlob">Blob
* Signing</a>
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@
* Defines an upper bound of permissions available for a GCP credential via {@link
* AccessBoundaryRule}s.
*
* <p>See <a href='https://cloud.google.com/iam/docs/downscoping-short-lived-credentials'>for more
* information.</a>
* <p>See <a
* href="https://docs.cloud.google.com/iam/docs/downscoping-short-lived-credentials">Downscoping
* with Credential Access Boundaries</a> for more information.
*/
@NullMarked
public final class CredentialAccessBoundary implements Serializable {
Expand Down Expand Up @@ -394,8 +395,8 @@ private Builder() {}
* format.
*
* <p>This expression specifies the Cloud Storage object where permissions are available.
* See <a href='https://cloud.google.com/iam/docs/conditions-overview#cel'>for more
* information.</a>
* See <a href="https://docs.cloud.google.com/iam/docs/conditions-overview#cel">IAM
* Conditions Overview</a> for more information.
*
* @param expression the expression to set
* @return this {@code Builder} object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ class DefaultCredentialsProvider {
"You are authenticating using user credentials. "
+ "For production, we recommend using service account credentials.\n\n"
+ "To learn more about service account credentials, see "
+ "http://cloud.google.com/docs/authentication/external/set-up-adc-on-cloud";
+ "https://docs.cloud.google.com/docs/authentication/set-up-adc-attached-service-account";

static final String CLOUDSDK_MISSING_CREDENTIALS =
"Your default credentials were not found. To set up Application Default Credentials "
+ "for your environment, see "
+ "https://cloud.google.com/docs/authentication/external/set-up-adc.";
+ "https://docs.cloud.google.com/docs/authentication/provide-credentials-adc#how-to";
public static final String SUPPRESS_GCLOUD_CREDS_WARNING_ENV_VAR =
"SUPPRESS_GCLOUD_CREDS_WARNING";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@
import org.jspecify.annotations.NullMarked;

/**
* Implements PKCE using only the Java standard library. See https://www.rfc-editor.org/rfc/rfc7636.
* Implements PKCE using only the Java standard library. See <a
* href="https://datatracker.ietf.org/doc/html/rfc7636">RFC 7636</a>.
*
* <p>https://developers.google.com/identity/protocols/oauth2/native-app#step1-code-verifier.
* <p>See <a
* href="https://developers.google.com/identity/protocols/oauth2/native-app#step1-code-verifier">OAuth
* 2.0 for Desktop Apps</a>.
*/
@NullMarked
public class DefaultPKCEProvider implements PKCEProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@
* the upper bound of permissions that the credential can access. You must also provide a source
* credential which will be used to acquire the downscoped credential.
*
* <p>See <a href='https://cloud.google.com/iam/docs/downscoping-short-lived-credentials'>for more
* information.</a>
* <p>See <a
* href="https://docs.cloud.google.com/iam/docs/downscoping-short-lived-credentials">Downscoping
* with Credential Access Boundaries</a> for more information.
*
* <p>Usage:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@

/**
* The expected format version for GDCH credential profiles. Version "1" indicates the initial and
* currently supported JSON format for these credentials. See go/gdch-python-auth-lib for more
* info.
* currently supported JSON format for these credentials.
*/
@VisibleForTesting static final String SUPPORTED_JSON_FORMAT_VERSION = "1";

// Custom URN used by GDCH to identify service account tokens in token exchange requests.
// See go/gdch-python-auth-lib for more information.
private static final String SERVICE_ACCOUNT_TOKEN_TYPE =
"urn:k8s:params:oauth:token-type:serviceaccount";

Expand Down Expand Up @@ -144,7 +142,7 @@
* 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 145 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 @

Check failure on line 145 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 @
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
*
* @param credentialsStream the stream with the credential definition.
Expand All @@ -163,7 +161,7 @@
* 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 164 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 @

Check failure on line 164 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 @
* 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 @@ -737,14 +735,14 @@
* Signs the JWS header and payload using the ES256 algorithm (ECDSA with SHA-256).
*
* <p>The ES256 algorithm is defined in <a
* href="https://tools.ietf.org/html/rfc7518#section-3.4">RFC 7518 Section 3.4</a>. This method
* follows the JWS Compact Serialization format described in <a
* href="https://tools.ietf.org/html/rfc7515#section-3.1">RFC 7515 Section 3.1</a>.
* href="https://datatracker.ietf.org/doc/html/rfc7518#section-3.4">RFC 7518 Section 3.4</a>. This
* method follows the JWS Compact Serialization format described in <a
* href="https://datatracker.ietf.org/doc/html/rfc7515#section-3.1">RFC 7515 Section 3.1</a>.
*
* <p>Unlike RSA signatures, ECDSA signatures produced by the Java Cryptography Architecture (JCA)
* are DER-encoded. This method transcodes the DER-encoded signature into the concatenated R|S
* format required by the JWS standard, as specified in <a
* href="https://tools.ietf.org/html/rfc7515#appendix-A.3">RFC 7515 Appendix A.3</a>.
* href="https://datatracker.ietf.org/doc/html/rfc7515#appendix-A.3">RFC 7515 Appendix A.3</a>.
*
* @param privateKey The Elliptic Curve private key used for signing.
* @param jsonFactory The JSON factory to serialize header and payload.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class IamUtils {
private static final LoggerProvider LOGGER_PROVIDER = LoggerProvider.forClazz(IamUtils.class);

// Following guidance for IAM retries:
// https://cloud.google.com/iam/docs/retry-strategy#errors-to-retry
// https://docs.cloud.google.com/iam/docs/retry-strategy#errors-to-retry
static final Set<Integer> IAM_RETRYABLE_STATUS_CODES =
new HashSet<>(Arrays.asList(500, 502, 503, 504));

Expand Down Expand Up @@ -504,7 +504,8 @@ static IdToken getIdToken(
* @return IdToken issed to the serviceAccount
* @throws IOException if the IdToken cannot be issued.
* @see <a
* href="https://cloud.google.com/iam/credentials/reference/rest/v1/projects.serviceAccounts/generateIdToken">...</a>
* href="https://docs.cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/generateIdToken">IAM
* Credentials API: generateIdToken</a>
*/
static IdToken getIdToken(
String idTokenUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public class ImpersonatedCredentials extends GoogleCredentials
* @param scopes scopes to request during the authorization grant
* @param lifetime number of seconds the delegated credential should be valid. By default this
* value should be at most 3600. However, you can follow <a
* href='https://cloud.google.com/iam/docs/creating-short-lived-service-account-credentials#sa-credentials-oauth'>these
* href="https://docs.cloud.google.com/organization-policy/restrict-service-accounts#extend_oauth_ttl">these
* instructions</a> to set up the service account and extend the maximum lifetime to 43200 (12
* hours). If the given lifetime is 0, default value 3600 will be used instead when creating
* the credentials.
Expand Down Expand Up @@ -186,7 +186,7 @@ public static ImpersonatedCredentials create(
* @param scopes scopes to request during the authorization grant
* @param lifetime number of seconds the delegated credential should be valid. By default this
* value should be at most 3600. However, you can follow <a
* href='https://cloud.google.com/iam/docs/creating-short-lived-service-account-credentials#sa-credentials-oauth'>these
* href="https://docs.cloud.google.com/organization-policy/restrict-service-accounts#extend_oauth_ttl">these
* instructions</a> to set up the service account and extend the maximum lifetime to 43200 (12
* hours). If the given lifetime is 0, default value 3600 will be used instead when creating
* the credentials.
Expand Down Expand Up @@ -233,7 +233,7 @@ public static ImpersonatedCredentials create(
* @param scopes scopes to request during the authorization grant
* @param lifetime number of seconds the delegated credential should be valid. By default this
* value should be at most 3600. However, you can follow <a
* href='https://cloud.google.com/iam/docs/creating-short-lived-service-account-credentials#sa-credentials-oauth'>these
* href="https://docs.cloud.google.com/organization-policy/restrict-service-accounts#extend_oauth_ttl">these
* instructions</a> to set up the service account and extend the maximum lifetime to 43200 (12
* hours). If the given lifetime is 0, default value 3600 will be used instead when creating
* the credentials.
Expand Down Expand Up @@ -284,12 +284,10 @@ public static ImpersonatedCredentials create(
* @param scopes scopes to request during the authorization grant
* @param lifetime number of seconds the delegated credential should be valid. By default this
* value should be at most 3600. However, you can follow <a
* href='https://cloud.google.com/iam/docs/creating-short-lived-service-account-credentials#sa-credentials-oauth'>these
* href="https://docs.cloud.google.com/organization-policy/restrict-service-accounts#extend_oauth_ttl">these
* instructions</a> to set up the service account and extend the maximum lifetime to 43200 (12
* hours).
* https://cloud.google.com/iam/docs/creating-short-lived-service-account-credentials#sa-credentials-oauth
* If the given lifetime is 0, default value 3600 will be used instead when creating the
* credentials.
* hours). If the given lifetime is 0, default value 3600 will be used instead when creating
* the credentials.
* @return new credentials
*/
public static ImpersonatedCredentials create(
Expand Down Expand Up @@ -364,7 +362,7 @@ public void setTransportFactory(HttpTransportFactory httpTransportFactory) {
* @return signed bytes
* @throws SigningException if the attempt to sign the provided bytes failed
* @see <a
* href="https://cloud.google.com/iam/credentials/reference/rest/v1/projects.serviceAccounts/signBlob">Blob
* href="https://docs.cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/signBlob">Blob
* Signing</a>
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
import org.jspecify.annotations.Nullable;

/**
* Encapsulates the standard OAuth error response. See
* https://tools.ietf.org/html/rfc6749#section-5.2.
* Encapsulates the standard OAuth error response. See <a
* href="https://datatracker.ietf.org/doc/html/rfc6749#section-5.2">RFC 6749 Section 5.2</a>.
*/
@NullMarked
class OAuthException extends GoogleAuthException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@
* GOOGLE_EXTERNAL_ACCOUNT_INTERACTIVE, GOOGLE_EXTERNAL_ACCOUNT_IMPERSONATED_EMAIL, and
* GOOGLE_EXTERNAL_ACCOUNT_OUTPUT_FILE.
*
* <p>Please see this repositories README for a complete executable request/response specification.
* <p>See <a
* href="https://docs.cloud.google.com/iam/docs/workload-identity-federation-with-other-providers#create-credential-config">Create
* a credential configuration (Executable-sourced credentials)</a> for the complete executable
* request and response specification.
*/
@NullMarked
public class PluggableAuthCredentials extends ExternalAccountCredentials {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

/**
* Implements the OAuth 2.0 token exchange based on <a
* href="https://tools.ietf.org/html/rfc8693">RFC 8693</a>.
* href="https://datatracker.ietf.org/doc/html/rfc8693">RFC 8693</a>.
*
* <p>This class handles the process of exchanging one type of token for another using the Security
* Token Service (STS). It constructs and sends the token exchange request to the STS endpoint and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

/**
* Represents an OAuth 2.0 token exchange request, as defined in <a
* href="https://tools.ietf.org/html/rfc8693#section-2.1">RFC 8693, Section 2.1</a>.
* href="https://datatracker.ietf.org/doc/html/rfc8693#section-2.1">RFC 8693, Section 2.1</a>.
*
* <p>This class encapsulates the parameters necessary for making a token exchange request to Google
* Security Token Service (STS). It includes the subject token, subject token type, optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

/**
* Represents a successful OAuth 2.0 token exchange response from the Google Security Token Service
* (STS), as defined in <a href="https://tools.ietf.org/html/rfc8693#section-2.2.1">RFC 8693,
* Section 2.2.1</a>.
* (STS), as defined in <a href="https://datatracker.ietf.org/doc/html/rfc8693#section-2.2.1">RFC
* 8693, Section 2.2.1</a>.
*
* <p>This class provides access to the exchanged access token, issued token type, token type,
* expiration time, refresh token (optional), scopes (optional), and the access boundary session key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public class UserAuthorizer {
/**
* Represents the client authentication types as specified in RFC 7591.
*
* <p>For more details, see <a href="https://tools.ietf.org/html/rfc7591">RFC 7591</a>.
* <p>For more details, see <a href="https://datatracker.ietf.org/doc/html/rfc7591#section-2">RFC
* 7591, Section 2</a>.
*/
public enum ClientAuthenticationType {
CLIENT_SECRET_POST,
Expand Down
Loading