Skip to content

Commit b504081

Browse files
committed
fix(auth): restore scopes null check and normalize getter nullability annotations
1 parent fe7d2c9 commit b504081

3 files changed

Lines changed: 17 additions & 24 deletions

File tree

google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -608,44 +608,37 @@ private void readObject(ObjectInputStream input) throws IOException, ClassNotFou
608608
transportFactory = newInstance(transportFactoryClassName);
609609
}
610610

611-
@Nullable
612-
public String getServiceAccountImpersonationUrl() {
611+
public @Nullable String getServiceAccountImpersonationUrl() {
613612
return serviceAccountImpersonationUrl;
614613
}
615614

616615
/**
617616
* @return The service account email to be impersonated, if available
618617
*/
619-
@Nullable
620-
public String getServiceAccountEmail() {
618+
public @Nullable String getServiceAccountEmail() {
621619
if (serviceAccountImpersonationUrl == null || serviceAccountImpersonationUrl.isEmpty()) {
622620
return null;
623621
}
624622
return ImpersonatedCredentials.extractTargetPrincipal(serviceAccountImpersonationUrl);
625623
}
626624

627-
@Nullable
628-
public String getClientId() {
625+
public @Nullable String getClientId() {
629626
return clientId;
630627
}
631628

632-
@Nullable
633-
public String getClientSecret() {
629+
public @Nullable String getClientSecret() {
634630
return clientSecret;
635631
}
636632

637-
@Nullable
638-
public Collection<String> getScopes() {
633+
public @Nullable Collection<String> getScopes() {
639634
return scopes;
640635
}
641636

642-
@Nullable
643-
public String getWorkforcePoolUserProject() {
637+
public @Nullable String getWorkforcePoolUserProject() {
644638
return workforcePoolUserProject;
645639
}
646640

647-
@Nullable
648-
public ServiceAccountImpersonationOptions getServiceAccountImpersonationOptions() {
641+
public @Nullable ServiceAccountImpersonationOptions getServiceAccountImpersonationOptions() {
649642
return serviceAccountImpersonationOptions;
650643
}
651644

google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentialSource.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ public void setCredentialLocation(String credentialLocation) {
8080
* @return The {@link CertificateConfig} object, or {@code null} if not configured for
8181
* certificate-based credentials.
8282
*/
83-
@Nullable
84-
public CertificateConfig getCertificateConfig() {
83+
public @Nullable CertificateConfig getCertificateConfig() {
8584
return certificateConfig;
8685
}
8786

@@ -208,11 +207,13 @@ public static class CertificateConfig implements java.io.Serializable {
208207

209208
checkArgument(
210209
(useDefault || locationIsPresent),
211-
"Invalid 'certificate' configuration in credential source: Must specify either 'certificate_config_location' or set 'use_default_certificate_config' to true.");
210+
"Invalid 'certificate' configuration in credential source: Must specify either"
211+
+ " 'certificate_config_location' or set 'use_default_certificate_config' to true.");
212212

213213
checkArgument(
214214
!(useDefault && locationIsPresent),
215-
"Invalid 'certificate' configuration in credential source: Cannot specify both 'certificate_config_location' and set 'use_default_certificate_config' to true.");
215+
"Invalid 'certificate' configuration in credential source: Cannot specify both"
216+
+ " 'certificate_config_location' and set 'use_default_certificate_config' to true.");
216217

217218
this.useDefaultCertificateConfig = useDefault;
218219
this.certificateConfigLocation = certificateConfigLocation;
@@ -225,14 +226,12 @@ public boolean useDefaultCertificateConfig() {
225226
}
226227

227228
/** Returns the path to the client certificate file, or null if not set. */
228-
@Nullable
229-
public String getCertificateConfigLocation() {
229+
public @Nullable String getCertificateConfigLocation() {
230230
return certificateConfigLocation;
231231
}
232232

233233
/** Returns the path to the trust chain file, or null if not set. */
234-
@Nullable
235-
public String getTrustChainPath() {
234+
public @Nullable String getTrustChainPath() {
236235
return trustChainPath;
237236
}
238237
}
@@ -279,7 +278,8 @@ public IdentityPoolCredentialSource(Map<String, Object> credentialSourceMap) {
279278
this.certificateConfig = certificateConfigFromSourceMap(credentialSourceMap);
280279
} else {
281280
throw new IllegalArgumentException(
282-
"Missing credential source file location, URL, or certificate. At least one must be specified.");
281+
"Missing credential source file location, URL, or certificate. At least one must be"
282+
+ " specified.");
283283
}
284284

285285
Map<String, String> headersMap = (Map<String, String>) credentialSourceMap.get("headers");

google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/IdentityPoolCredentials.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public AccessToken refreshAccessToken() throws IOException {
123123
.setAudience(getAudience());
124124

125125
Collection<String> scopes = getScopes();
126-
if (!scopes.isEmpty()) {
126+
if (scopes != null && !scopes.isEmpty()) {
127127
stsTokenExchangeRequest.setScopes(new ArrayList<>(scopes));
128128
}
129129

0 commit comments

Comments
 (0)