From ffa73911ac82a56f701d8408bd23e260c58c01bf Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Fri, 21 Aug 2026 22:07:29 +0000 Subject: [PATCH] fix(auth): refine JSpecify nullability annotations for external account credentials Refine JSpecify nullability annotations across ExternalAccountCredentials and subclasses: - Annotate optional fields, getters, and builder setters/fields with @Nullable across ExternalAccountCredentials, IdentityPoolCredentials, AwsCredentials, PluggableAuthCredentials, and ExternalAccountAuthorizedUserCredentials. - Ensure correct JSpecify type-use annotation placements on fields, return types, and parameters. - Migrate Preconditions imports to com.google.common.base.Preconditions. - Ensure builder copy constructors properly preserve all fields. --- .../google/auth/oauth2/AwsCredentials.java | 54 ++++++++----- ...ernalAccountAuthorizedUserCredentials.java | 80 +++++++++---------- .../oauth2/ExternalAccountCredentials.java | 37 +++++---- .../auth/oauth2/IdentityPoolCredentials.java | 56 ++++++++----- .../auth/oauth2/PluggableAuthCredentials.java | 46 +++++++---- 5 files changed, 159 insertions(+), 114 deletions(-) diff --git a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/AwsCredentials.java b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/AwsCredentials.java index ce8ed886f608..5ae919f130ef 100644 --- a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/AwsCredentials.java +++ b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/AwsCredentials.java @@ -83,7 +83,8 @@ public class AwsCredentials extends ExternalAccountCredentials { // Check that one and only one of supplier or credential source are provided. if (builder.awsSecurityCredentialsSupplier != null && builder.credentialSource != null) { throw new IllegalArgumentException( - "AwsCredentials cannot have both an awsSecurityCredentialsSupplier and a credentialSource."); + "AwsCredentials cannot have both an awsSecurityCredentialsSupplier and a" + + " credentialSource."); } if (builder.awsSecurityCredentialsSupplier == null && builder.credentialSource == null) { throw new IllegalArgumentException( @@ -203,8 +204,7 @@ AwsSecurityCredentialsSupplier getAwsSecurityCredentialsSupplier() { return this.awsSecurityCredentialsSupplier; } - @Nullable - public String getRegionalCredentialVerificationUrlOverride() { + public @Nullable String getRegionalCredentialVerificationUrlOverride() { return this.regionalCredentialVerificationUrlOverride; } @@ -237,9 +237,9 @@ public Builder toBuilder() { public static class Builder extends ExternalAccountCredentials.Builder { - private AwsSecurityCredentialsSupplier awsSecurityCredentialsSupplier; + private @Nullable AwsSecurityCredentialsSupplier awsSecurityCredentialsSupplier; - private String regionalCredentialVerificationUrlOverride; + private @Nullable String regionalCredentialVerificationUrlOverride; Builder() {} @@ -261,7 +261,7 @@ public static class Builder extends ExternalAccountCredentials.Builder { */ @CanIgnoreReturnValue public Builder setAwsSecurityCredentialsSupplier( - AwsSecurityCredentialsSupplier awsSecurityCredentialsSupplier) { + @Nullable AwsSecurityCredentialsSupplier awsSecurityCredentialsSupplier) { this.awsSecurityCredentialsSupplier = awsSecurityCredentialsSupplier; return this; } @@ -277,37 +277,42 @@ public Builder setAwsSecurityCredentialsSupplier( */ @CanIgnoreReturnValue public Builder setRegionalCredentialVerificationUrlOverride( - String regionalCredentialVerificationUrlOverride) { + @Nullable String regionalCredentialVerificationUrlOverride) { this.regionalCredentialVerificationUrlOverride = regionalCredentialVerificationUrlOverride; return this; } + @Override @CanIgnoreReturnValue - public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) { + public Builder setHttpTransportFactory(@Nullable HttpTransportFactory transportFactory) { super.setHttpTransportFactory(transportFactory); return this; } + @Override @CanIgnoreReturnValue public Builder setAudience(String audience) { super.setAudience(audience); return this; } + @Override @CanIgnoreReturnValue public Builder setSubjectTokenType(String subjectTokenType) { super.setSubjectTokenType(subjectTokenType); return this; } + @Override @CanIgnoreReturnValue public Builder setSubjectTokenType(SubjectTokenTypes subjectTokenType) { super.setSubjectTokenType(subjectTokenType); return this; } + @Override @CanIgnoreReturnValue - public Builder setTokenUrl(String tokenUrl) { + public Builder setTokenUrl(@Nullable String tokenUrl) { super.setTokenUrl(tokenUrl); return this; } @@ -318,62 +323,73 @@ public Builder setCredentialSource(AwsCredentialSource credentialSource) { return this; } + @Override @CanIgnoreReturnValue - public Builder setServiceAccountImpersonationUrl(String serviceAccountImpersonationUrl) { + public Builder setServiceAccountImpersonationUrl( + @Nullable String serviceAccountImpersonationUrl) { super.setServiceAccountImpersonationUrl(serviceAccountImpersonationUrl); return this; } + @Override @CanIgnoreReturnValue - public Builder setTokenInfoUrl(String tokenInfoUrl) { + public Builder setTokenInfoUrl(@Nullable String tokenInfoUrl) { super.setTokenInfoUrl(tokenInfoUrl); return this; } + @Override @CanIgnoreReturnValue - public Builder setQuotaProjectId(String quotaProjectId) { + public Builder setQuotaProjectId(@Nullable String quotaProjectId) { super.setQuotaProjectId(quotaProjectId); return this; } + @Override @CanIgnoreReturnValue - public Builder setClientId(String clientId) { + public Builder setClientId(@Nullable String clientId) { super.setClientId(clientId); return this; } + @Override @CanIgnoreReturnValue - public Builder setClientSecret(String clientSecret) { + public Builder setClientSecret(@Nullable String clientSecret) { super.setClientSecret(clientSecret); return this; } + @Override @CanIgnoreReturnValue - public Builder setScopes(Collection scopes) { + public Builder setScopes(@Nullable Collection scopes) { super.setScopes(scopes); return this; } + @Override @CanIgnoreReturnValue - public Builder setWorkforcePoolUserProject(String workforcePoolUserProject) { + public Builder setWorkforcePoolUserProject(@Nullable String workforcePoolUserProject) { super.setWorkforcePoolUserProject(workforcePoolUserProject); return this; } + @Override @CanIgnoreReturnValue - public Builder setServiceAccountImpersonationOptions(Map optionsMap) { + public Builder setServiceAccountImpersonationOptions(@Nullable Map optionsMap) { super.setServiceAccountImpersonationOptions(optionsMap); return this; } + @Override @CanIgnoreReturnValue - public Builder setUniverseDomain(String universeDomain) { + public Builder setUniverseDomain(@Nullable String universeDomain) { super.setUniverseDomain(universeDomain); return this; } + @Override @CanIgnoreReturnValue - Builder setEnvironmentProvider(EnvironmentProvider environmentProvider) { + Builder setEnvironmentProvider(@Nullable EnvironmentProvider environmentProvider) { super.setEnvironmentProvider(environmentProvider); return this; } diff --git a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountAuthorizedUserCredentials.java b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountAuthorizedUserCredentials.java index 61ca133cf1d6..c86f4127188a 100644 --- a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountAuthorizedUserCredentials.java +++ b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountAuthorizedUserCredentials.java @@ -42,9 +42,9 @@ import com.google.api.client.json.GenericJson; import com.google.api.client.json.JsonObjectParser; import com.google.api.client.util.GenericData; -import com.google.api.client.util.Preconditions; import com.google.auth.http.HttpTransportFactory; import com.google.common.base.MoreObjects; +import com.google.common.base.Preconditions; import com.google.common.io.BaseEncoding; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; @@ -84,17 +84,17 @@ public class ExternalAccountAuthorizedUserCredentials extends GoogleCredentials private static final long serialVersionUID = -2181779590486283287L; - private final String transportFactoryClassName; - private final String audience; - private final String tokenUrl; - private final String tokenInfoUrl; - private final String revokeUrl; - private final String clientId; - private final String clientSecret; + private final @Nullable String transportFactoryClassName; + private final @Nullable String audience; + private final @Nullable String tokenUrl; + private final @Nullable String tokenInfoUrl; + private final @Nullable String revokeUrl; + private final @Nullable String clientId; + private final @Nullable String clientSecret; - private String refreshToken; + private @Nullable String refreshToken; - private transient HttpTransportFactory transportFactory; + private transient @Nullable HttpTransportFactory transportFactory; /** * Internal constructor. @@ -231,38 +231,31 @@ public AccessToken refreshAccessToken() throws IOException { .build(); } - @Nullable - public String getAudience() { + public @Nullable String getAudience() { return audience; } - @Nullable - public String getClientId() { + public @Nullable String getClientId() { return clientId; } - @Nullable - public String getClientSecret() { + public @Nullable String getClientSecret() { return clientSecret; } - @Nullable - public String getRevokeUrl() { + public @Nullable String getRevokeUrl() { return revokeUrl; } - @Nullable - public String getTokenUrl() { + public @Nullable String getTokenUrl() { return tokenUrl; } - @Nullable - public String getTokenInfoUrl() { + public @Nullable String getTokenInfoUrl() { return tokenInfoUrl; } - @Nullable - public String getRefreshToken() { + public @Nullable String getRefreshToken() { return refreshToken; } @@ -363,7 +356,6 @@ static ExternalAccountAuthorizedUserCredentials fromJson( .setRevokeUrl(revokeUrl) .setClientId(clientId) .setClientSecret(clientSecret) - .setRefreshToken(refreshToken) .setHttpTransportFactory(transportFactory) .setQuotaProjectId(quotaProjectId) .setUniverseDomain(universeDomain) @@ -417,14 +409,14 @@ private HttpRequest buildRefreshRequest() throws IOException { /** Builder for {@link ExternalAccountAuthorizedUserCredentials}. */ public static class Builder extends GoogleCredentials.Builder { - private HttpTransportFactory transportFactory; - private String audience; - private String refreshToken; - private String tokenUrl; - private String tokenInfoUrl; - private String revokeUrl; - private String clientId; - private String clientSecret; + private @Nullable HttpTransportFactory transportFactory; + private @Nullable String audience; + private @Nullable String refreshToken; + private @Nullable String tokenUrl; + private @Nullable String tokenInfoUrl; + private @Nullable String revokeUrl; + private @Nullable String clientId; + private @Nullable String clientSecret; protected Builder() {} @@ -447,7 +439,7 @@ protected Builder(ExternalAccountAuthorizedUserCredentials credentials) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) { + public Builder setHttpTransportFactory(@Nullable HttpTransportFactory transportFactory) { this.transportFactory = transportFactory; return this; } @@ -460,7 +452,7 @@ public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setAudience(String audience) { + public Builder setAudience(@Nullable String audience) { this.audience = audience; return this; } @@ -472,7 +464,7 @@ public Builder setAudience(String audience) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setTokenUrl(String tokenUrl) { + public Builder setTokenUrl(@Nullable String tokenUrl) { this.tokenUrl = tokenUrl; return this; } @@ -484,7 +476,7 @@ public Builder setTokenUrl(String tokenUrl) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setTokenInfoUrl(String tokenInfoUrl) { + public Builder setTokenInfoUrl(@Nullable String tokenInfoUrl) { this.tokenInfoUrl = tokenInfoUrl; return this; } @@ -496,7 +488,7 @@ public Builder setTokenInfoUrl(String tokenInfoUrl) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setRevokeUrl(String revokeUrl) { + public Builder setRevokeUrl(@Nullable String revokeUrl) { this.revokeUrl = revokeUrl; return this; } @@ -508,7 +500,7 @@ public Builder setRevokeUrl(String revokeUrl) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setRefreshToken(String refreshToken) { + public Builder setRefreshToken(@Nullable String refreshToken) { this.refreshToken = refreshToken; return this; } @@ -520,7 +512,7 @@ public Builder setRefreshToken(String refreshToken) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setClientId(String clientId) { + public Builder setClientId(@Nullable String clientId) { this.clientId = clientId; return this; } @@ -532,7 +524,7 @@ public Builder setClientId(String clientId) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setClientSecret(String clientSecret) { + public Builder setClientSecret(@Nullable String clientSecret) { this.clientSecret = clientSecret; return this; } @@ -545,7 +537,7 @@ public Builder setClientSecret(String clientSecret) { */ @Override @CanIgnoreReturnValue - public Builder setQuotaProjectId(String quotaProjectId) { + public Builder setQuotaProjectId(@Nullable String quotaProjectId) { super.setQuotaProjectId(quotaProjectId); return this; } @@ -558,7 +550,7 @@ public Builder setQuotaProjectId(String quotaProjectId) { */ @Override @CanIgnoreReturnValue - public Builder setAccessToken(AccessToken accessToken) { + public Builder setAccessToken(@Nullable AccessToken accessToken) { super.setAccessToken(accessToken); return this; } @@ -571,7 +563,7 @@ public Builder setAccessToken(AccessToken accessToken) { */ @CanIgnoreReturnValue @Override - public Builder setUniverseDomain(String universeDomain) { + public Builder setUniverseDomain(@Nullable String universeDomain) { super.setUniverseDomain(universeDomain); return this; } diff --git a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java index 917f01fe89e0..1c9040809a76 100644 --- a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java +++ b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java @@ -122,7 +122,7 @@ public abstract class ExternalAccountCredentials extends GoogleCredentials { * @param scopes the scopes to request during the authorization grant. May be null. */ protected ExternalAccountCredentials( - HttpTransportFactory transportFactory, + @Nullable HttpTransportFactory transportFactory, String audience, String subjectTokenType, String tokenUrl, @@ -172,7 +172,7 @@ protected ExternalAccountCredentials( * SystemEnvironmentProvider}. */ protected ExternalAccountCredentials( - HttpTransportFactory transportFactory, + @Nullable HttpTransportFactory transportFactory, String audience, String subjectTokenType, String tokenUrl, @@ -265,7 +265,8 @@ protected ExternalAccountCredentials(ExternalAccountCredentials.Builder builder) this.workforcePoolUserProject = builder.workforcePoolUserProject; if (workforcePoolUserProject != null && !isWorkforcePoolConfiguration()) { throw new IllegalArgumentException( - "The workforce_pool_user_project parameter should only be provided for a Workforce Pool configuration."); + "The workforce_pool_user_project parameter should only be provided for a Workforce Pool" + + " configuration."); } validateTokenUrl(tokenUrl); @@ -819,7 +820,7 @@ protected Builder(ExternalAccountCredentials credentials) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) { + public Builder setHttpTransportFactory(@Nullable HttpTransportFactory transportFactory) { this.transportFactory = transportFactory; return this; } @@ -870,7 +871,7 @@ public Builder setSubjectTokenType(SubjectTokenTypes subjectTokenType) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setTokenUrl(String tokenUrl) { + public Builder setTokenUrl(@Nullable String tokenUrl) { this.tokenUrl = tokenUrl; return this; } @@ -896,7 +897,8 @@ public Builder setCredentialSource(CredentialSource credentialSource) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setServiceAccountImpersonationUrl(String serviceAccountImpersonationUrl) { + public Builder setServiceAccountImpersonationUrl( + @Nullable String serviceAccountImpersonationUrl) { this.serviceAccountImpersonationUrl = serviceAccountImpersonationUrl; return this; } @@ -909,7 +911,7 @@ public Builder setServiceAccountImpersonationUrl(String serviceAccountImpersonat * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setTokenInfoUrl(String tokenInfoUrl) { + public Builder setTokenInfoUrl(@Nullable String tokenInfoUrl) { this.tokenInfoUrl = tokenInfoUrl; return this; } @@ -922,7 +924,7 @@ public Builder setTokenInfoUrl(String tokenInfoUrl) { */ @Override @CanIgnoreReturnValue - public Builder setQuotaProjectId(String quotaProjectId) { + public Builder setQuotaProjectId(@Nullable String quotaProjectId) { super.setQuotaProjectId(quotaProjectId); return this; } @@ -934,7 +936,7 @@ public Builder setQuotaProjectId(String quotaProjectId) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setClientId(String clientId) { + public Builder setClientId(@Nullable String clientId) { this.clientId = clientId; return this; } @@ -946,7 +948,7 @@ public Builder setClientId(String clientId) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setClientSecret(String clientSecret) { + public Builder setClientSecret(@Nullable String clientSecret) { this.clientSecret = clientSecret; return this; } @@ -958,7 +960,7 @@ public Builder setClientSecret(String clientSecret) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setScopes(Collection scopes) { + public Builder setScopes(@Nullable Collection scopes) { this.scopes = scopes; return this; } @@ -972,7 +974,7 @@ public Builder setScopes(Collection scopes) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setWorkforcePoolUserProject(String workforcePoolUserProject) { + public Builder setWorkforcePoolUserProject(@Nullable String workforcePoolUserProject) { this.workforcePoolUserProject = workforcePoolUserProject; return this; } @@ -984,8 +986,9 @@ public Builder setWorkforcePoolUserProject(String workforcePoolUserProject) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setServiceAccountImpersonationOptions(Map optionsMap) { - this.serviceAccountImpersonationOptions = new ServiceAccountImpersonationOptions(optionsMap); + public Builder setServiceAccountImpersonationOptions(@Nullable Map optionsMap) { + this.serviceAccountImpersonationOptions = + optionsMap == null ? null : new ServiceAccountImpersonationOptions(optionsMap); return this; } @@ -997,7 +1000,7 @@ public Builder setServiceAccountImpersonationOptions(Map options */ @CanIgnoreReturnValue @Override - public Builder setUniverseDomain(String universeDomain) { + public Builder setUniverseDomain(@Nullable String universeDomain) { super.setUniverseDomain(universeDomain); return this; } @@ -1009,7 +1012,7 @@ public Builder setUniverseDomain(String universeDomain) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - Builder setEnvironmentProvider(EnvironmentProvider environmentProvider) { + Builder setEnvironmentProvider(@Nullable EnvironmentProvider environmentProvider) { this.environmentProvider = environmentProvider; return this; } @@ -1021,7 +1024,7 @@ Builder setEnvironmentProvider(EnvironmentProvider environmentProvider) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - Builder setPropertyProvider(PropertyProvider propertyProvider) { + Builder setPropertyProvider(@Nullable PropertyProvider propertyProvider) { this.propertyProvider = propertyProvider; return this; } diff --git a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentials.java b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentials.java index 10f216139d7b..7e4841aa25ce 100644 --- a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentials.java +++ b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentials.java @@ -77,7 +77,8 @@ public class IdentityPoolCredentials extends ExternalAccountCredentials { // Check that one and only one of supplier or credential source are provided. if (builder.subjectTokenSupplier != null && credentialSource != null) { throw new IllegalArgumentException( - "IdentityPoolCredentials cannot have both a subjectTokenSupplier and a credentialSource."); + "IdentityPoolCredentials cannot have both a subjectTokenSupplier and a" + + " credentialSource."); } if (builder.subjectTokenSupplier == null && credentialSource == null) { throw new IllegalArgumentException( @@ -104,7 +105,8 @@ public class IdentityPoolCredentials extends ExternalAccountCredentials { throw new RuntimeException( // Wrap IOException in RuntimeException because constructors cannot throw checked // exceptions. - "Failed to initialize IdentityPoolCredentials from certificate source due to an I/O error.", + "Failed to initialize IdentityPoolCredentials from certificate source due to an I/O" + + " error.", e); } this.metricsHeaderValue = CERTIFICATE_METRICS_HEADER_VALUE; @@ -121,7 +123,7 @@ public AccessToken refreshAccessToken() throws IOException { .setAudience(getAudience()); Collection scopes = getScopes(); - if (scopes != null && !scopes.isEmpty()) { + if (!scopes.isEmpty()) { stsTokenExchangeRequest.setScopes(new ArrayList<>(scopes)); } @@ -204,8 +206,8 @@ private X509Provider getX509Provider( public static class Builder extends ExternalAccountCredentials.Builder { - private IdentityPoolSubjectTokenSupplier subjectTokenSupplier; - private X509Provider x509Provider; + private @Nullable IdentityPoolSubjectTokenSupplier subjectTokenSupplier; + private @Nullable X509Provider x509Provider; Builder() {} @@ -227,7 +229,7 @@ public static class Builder extends ExternalAccountCredentials.Builder { */ @CanIgnoreReturnValue @VisibleForTesting - Builder setX509Provider(X509Provider x509Provider) { + Builder setX509Provider(@Nullable X509Provider x509Provider) { this.x509Provider = x509Provider; return this; } @@ -239,37 +241,43 @@ Builder setX509Provider(X509Provider x509Provider) { * @return this {@code Builder} object */ @CanIgnoreReturnValue - public Builder setSubjectTokenSupplier(IdentityPoolSubjectTokenSupplier subjectTokenSupplier) { + public Builder setSubjectTokenSupplier( + @Nullable IdentityPoolSubjectTokenSupplier subjectTokenSupplier) { this.subjectTokenSupplier = subjectTokenSupplier; return this; } + @Override @CanIgnoreReturnValue - public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) { + public Builder setHttpTransportFactory(@Nullable HttpTransportFactory transportFactory) { super.setHttpTransportFactory(transportFactory); return this; } + @Override @CanIgnoreReturnValue public Builder setAudience(String audience) { super.setAudience(audience); return this; } + @Override @CanIgnoreReturnValue public Builder setSubjectTokenType(String subjectTokenType) { super.setSubjectTokenType(subjectTokenType); return this; } + @Override @CanIgnoreReturnValue public Builder setSubjectTokenType(SubjectTokenTypes subjectTokenType) { super.setSubjectTokenType(subjectTokenType); return this; } + @Override @CanIgnoreReturnValue - public Builder setTokenUrl(String tokenUrl) { + public Builder setTokenUrl(@Nullable String tokenUrl) { super.setTokenUrl(tokenUrl); return this; } @@ -280,63 +288,73 @@ public Builder setCredentialSource(IdentityPoolCredentialSource credentialSource return this; } + @Override @CanIgnoreReturnValue - public Builder setServiceAccountImpersonationUrl(String serviceAccountImpersonationUrl) { + public Builder setServiceAccountImpersonationUrl( + @Nullable String serviceAccountImpersonationUrl) { super.setServiceAccountImpersonationUrl(serviceAccountImpersonationUrl); return this; } + @Override @CanIgnoreReturnValue - public Builder setTokenInfoUrl(String tokenInfoUrl) { + public Builder setTokenInfoUrl(@Nullable String tokenInfoUrl) { super.setTokenInfoUrl(tokenInfoUrl); return this; } + @Override @CanIgnoreReturnValue - public Builder setQuotaProjectId(String quotaProjectId) { + public Builder setQuotaProjectId(@Nullable String quotaProjectId) { super.setQuotaProjectId(quotaProjectId); return this; } + @Override @CanIgnoreReturnValue - public Builder setClientId(String clientId) { + public Builder setClientId(@Nullable String clientId) { super.setClientId(clientId); return this; } + @Override @CanIgnoreReturnValue - public Builder setClientSecret(String clientSecret) { + public Builder setClientSecret(@Nullable String clientSecret) { super.setClientSecret(clientSecret); return this; } + @Override @CanIgnoreReturnValue - public Builder setScopes(Collection scopes) { + public Builder setScopes(@Nullable Collection scopes) { super.setScopes(scopes); return this; } @Override @CanIgnoreReturnValue - public Builder setWorkforcePoolUserProject(String workforcePoolUserProject) { + public Builder setWorkforcePoolUserProject(@Nullable String workforcePoolUserProject) { super.setWorkforcePoolUserProject(workforcePoolUserProject); return this; } + @Override @CanIgnoreReturnValue - public Builder setServiceAccountImpersonationOptions(Map optionsMap) { + public Builder setServiceAccountImpersonationOptions(@Nullable Map optionsMap) { super.setServiceAccountImpersonationOptions(optionsMap); return this; } + @Override @CanIgnoreReturnValue - public Builder setUniverseDomain(String universeDomain) { + public Builder setUniverseDomain(@Nullable String universeDomain) { super.setUniverseDomain(universeDomain); return this; } + @Override @CanIgnoreReturnValue - Builder setEnvironmentProvider(EnvironmentProvider environmentProvider) { + Builder setEnvironmentProvider(@Nullable EnvironmentProvider environmentProvider) { super.setEnvironmentProvider(environmentProvider); return this; } diff --git a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/PluggableAuthCredentials.java b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/PluggableAuthCredentials.java index 7e02aee07cd9..6bd2b83cbc3b 100644 --- a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/PluggableAuthCredentials.java +++ b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/PluggableAuthCredentials.java @@ -211,13 +211,13 @@ public Builder toBuilder() { } @VisibleForTesting - @Nullable ExecutableHandler getExecutableHandler() { + ExecutableHandler getExecutableHandler() { return this.handler; } public static class Builder extends ExternalAccountCredentials.Builder { - private ExecutableHandler handler; + private @Nullable ExecutableHandler handler; Builder() {} @@ -227,37 +227,42 @@ public static class Builder extends ExternalAccountCredentials.Builder { } @CanIgnoreReturnValue - public Builder setExecutableHandler(ExecutableHandler handler) { + public Builder setExecutableHandler(@Nullable ExecutableHandler handler) { this.handler = handler; return this; } + @Override @CanIgnoreReturnValue - public Builder setHttpTransportFactory(HttpTransportFactory transportFactory) { + public Builder setHttpTransportFactory(@Nullable HttpTransportFactory transportFactory) { super.setHttpTransportFactory(transportFactory); return this; } + @Override @CanIgnoreReturnValue public Builder setAudience(String audience) { super.setAudience(audience); return this; } + @Override @CanIgnoreReturnValue public Builder setSubjectTokenType(String subjectTokenType) { super.setSubjectTokenType(subjectTokenType); return this; } + @Override @CanIgnoreReturnValue public Builder setSubjectTokenType(SubjectTokenTypes subjectTokenType) { super.setSubjectTokenType(subjectTokenType); return this; } + @Override @CanIgnoreReturnValue - public Builder setTokenUrl(String tokenUrl) { + public Builder setTokenUrl(@Nullable String tokenUrl) { super.setTokenUrl(tokenUrl); return this; } @@ -268,62 +273,73 @@ public Builder setCredentialSource(PluggableAuthCredentialSource credentialSourc return this; } + @Override @CanIgnoreReturnValue - public Builder setServiceAccountImpersonationUrl(String serviceAccountImpersonationUrl) { + public Builder setServiceAccountImpersonationUrl( + @Nullable String serviceAccountImpersonationUrl) { super.setServiceAccountImpersonationUrl(serviceAccountImpersonationUrl); return this; } + @Override @CanIgnoreReturnValue - public Builder setTokenInfoUrl(String tokenInfoUrl) { + public Builder setTokenInfoUrl(@Nullable String tokenInfoUrl) { super.setTokenInfoUrl(tokenInfoUrl); return this; } + @Override @CanIgnoreReturnValue - public Builder setQuotaProjectId(String quotaProjectId) { + public Builder setQuotaProjectId(@Nullable String quotaProjectId) { super.setQuotaProjectId(quotaProjectId); return this; } + @Override @CanIgnoreReturnValue - public Builder setClientId(String clientId) { + public Builder setClientId(@Nullable String clientId) { super.setClientId(clientId); return this; } + @Override @CanIgnoreReturnValue - public Builder setClientSecret(String clientSecret) { + public Builder setClientSecret(@Nullable String clientSecret) { super.setClientSecret(clientSecret); return this; } + @Override @CanIgnoreReturnValue - public Builder setScopes(Collection scopes) { + public Builder setScopes(@Nullable Collection scopes) { super.setScopes(scopes); return this; } + @Override @CanIgnoreReturnValue - public Builder setWorkforcePoolUserProject(String workforcePoolUserProject) { + public Builder setWorkforcePoolUserProject(@Nullable String workforcePoolUserProject) { super.setWorkforcePoolUserProject(workforcePoolUserProject); return this; } + @Override @CanIgnoreReturnValue - public Builder setServiceAccountImpersonationOptions(Map optionsMap) { + public Builder setServiceAccountImpersonationOptions(@Nullable Map optionsMap) { super.setServiceAccountImpersonationOptions(optionsMap); return this; } + @Override @CanIgnoreReturnValue - public Builder setUniverseDomain(String universeDomain) { + public Builder setUniverseDomain(@Nullable String universeDomain) { super.setUniverseDomain(universeDomain); return this; } + @Override @CanIgnoreReturnValue - Builder setEnvironmentProvider(EnvironmentProvider environmentProvider) { + Builder setEnvironmentProvider(@Nullable EnvironmentProvider environmentProvider) { super.setEnvironmentProvider(environmentProvider); return this; }