diff --git a/oauth2_http/java/com/google/auth/oauth2/ServiceAccountCredentials.java b/oauth2_http/java/com/google/auth/oauth2/ServiceAccountCredentials.java index e5a63c0db..0e0905672 100644 --- a/oauth2_http/java/com/google/auth/oauth2/ServiceAccountCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/ServiceAccountCredentials.java @@ -110,7 +110,7 @@ public class ServiceAccountCredentials extends GoogleCredentials private final Collection defaultScopes; private final String quotaProjectId; private final int lifetime; - private final boolean useJWTAccessWithScope; + private final boolean useJwtAccessWithScope; private transient HttpTransportFactory transportFactory; @@ -134,7 +134,7 @@ public class ServiceAccountCredentials extends GoogleCredentials * most 43200 (12 hours). If the token is used for calling a Google API, then the value should * be at most 3600 (1 hour). If the given value is 0, then the default value 3600 will be used * when creating the credentials. - * @param useJWTAccessWithScope whether self signed JWT with scopes should be always used. + * @param useJwtAccessWithScope whether self signed JWT with scopes should be always used. */ ServiceAccountCredentials( String clientId, @@ -149,7 +149,7 @@ public class ServiceAccountCredentials extends GoogleCredentials String projectId, String quotaProjectId, int lifetime, - boolean useJWTAccessWithScope) { + boolean useJwtAccessWithScope) { this.clientId = clientId; this.clientEmail = Preconditions.checkNotNull(clientEmail); this.privateKey = Preconditions.checkNotNull(privateKey); @@ -170,7 +170,7 @@ public class ServiceAccountCredentials extends GoogleCredentials throw new IllegalStateException("lifetime must be less than or equal to 43200"); } this.lifetime = lifetime; - this.useJWTAccessWithScope = useJWTAccessWithScope; + this.useJwtAccessWithScope = useJwtAccessWithScope; } /** @@ -692,7 +692,7 @@ public GoogleCredentials createScoped( projectId, quotaProjectId, lifetime, - useJWTAccessWithScope); + useJwtAccessWithScope); } /** @@ -709,13 +709,13 @@ public ServiceAccountCredentials createWithCustomLifetime(int lifetime) { } /** - * Clones the service account with a new useJWTAccessWithScope value. + * Clones the service account with a new useJwtAccessWithScope value. * - * @param useJWTAccessWithScope whether self signed JWT with scopes should be used - * @return the cloned service account credentials with the given useJWTAccessWithScope + * @param useJwtAccessWithScope whether self signed JWT with scopes should be used + * @return the cloned service account credentials with the given useJwtAccessWithScope */ - public ServiceAccountCredentials createWithUseJWTAccessWithScope(boolean useJWTAccessWithScope) { - return this.toBuilder().setUseJWTAccessWithScope(useJWTAccessWithScope).build(); + public ServiceAccountCredentials createWithUseJwtAccessWithScope(boolean useJwtAccessWithScope) { + return this.toBuilder().setUseJwtAccessWithScope(useJwtAccessWithScope).build(); } @Override @@ -733,7 +733,7 @@ public GoogleCredentials createDelegated(String user) { projectId, quotaProjectId, lifetime, - useJWTAccessWithScope); + useJwtAccessWithScope); } public final String getClientId() { @@ -781,8 +781,8 @@ int getLifetime() { return lifetime; } - public boolean getUseJWTAccessWithScope() { - return useJWTAccessWithScope; + public boolean getUseJwtAccessWithScope() { + return useJwtAccessWithScope; } @Override @@ -843,7 +843,7 @@ public int hashCode() { defaultScopes, quotaProjectId, lifetime, - useJWTAccessWithScope); + useJwtAccessWithScope); } @Override @@ -859,7 +859,7 @@ public String toString() { .add("serviceAccountUser", serviceAccountUser) .add("quotaProjectId", quotaProjectId) .add("lifetime", lifetime) - .add("useJWTAccessWithScope", useJWTAccessWithScope) + .add("useJwtAccessWithScope", useJwtAccessWithScope) .toString(); } @@ -879,7 +879,7 @@ public boolean equals(Object obj) { && Objects.equals(this.defaultScopes, other.defaultScopes) && Objects.equals(this.quotaProjectId, other.quotaProjectId) && Objects.equals(this.lifetime, other.lifetime) - && Objects.equals(this.useJWTAccessWithScope, other.useJWTAccessWithScope); + && Objects.equals(this.useJwtAccessWithScope, other.useJwtAccessWithScope); } String createAssertion(JsonFactory jsonFactory, long currentTime, String audience) @@ -973,7 +973,7 @@ JwtCredentials createSelfSignedJwtCredentials() { @Override public void getRequestMetadata( final URI uri, Executor executor, final RequestMetadataCallback callback) { - if (useJWTAccessWithScope) { + if (useJwtAccessWithScope) { // This will call getRequestMetadata(URI uri), which handles self signed JWT logic. // Self signed JWT doesn't use network, so here we do a blocking call to improve // efficiency. executor will be ignored since it is intended for async operation. @@ -991,7 +991,7 @@ public Map> getRequestMetadata(URI uri) throws IOException "Scopes are not configured for service account. Specify the scopes" + " by calling createScoped or passing scopes to constructor."); } - if (useJWTAccessWithScope) { + if (useJwtAccessWithScope) { JwtCredentials jwtCredentials = createSelfSignedJwtCredentials(); Map> requestMetadata = jwtCredentials.getRequestMetadata(null); return addQuotaProjectIdToRequestMetadata(quotaProjectId, requestMetadata); @@ -1034,7 +1034,7 @@ public static class Builder extends GoogleCredentials.Builder { private HttpTransportFactory transportFactory; private String quotaProjectId; private int lifetime = DEFAULT_LIFETIME_IN_SECONDS; - private boolean useJWTAccessWithScope = false; + private boolean useJwtAccessWithScope = false; protected Builder() {} @@ -1051,7 +1051,7 @@ protected Builder(ServiceAccountCredentials credentials) { this.projectId = credentials.projectId; this.quotaProjectId = credentials.quotaProjectId; this.lifetime = credentials.lifetime; - this.useJWTAccessWithScope = credentials.useJWTAccessWithScope; + this.useJwtAccessWithScope = credentials.useJwtAccessWithScope; } public Builder setClientId(String clientId) { @@ -1116,8 +1116,8 @@ public Builder setLifetime(int lifetime) { return this; } - public Builder setUseJWTAccessWithScope(boolean useJWTAccessWithScope) { - this.useJWTAccessWithScope = useJWTAccessWithScope; + public Builder setUseJwtAccessWithScope(boolean useJwtAccessWithScope) { + this.useJwtAccessWithScope = useJwtAccessWithScope; return this; } @@ -1169,8 +1169,8 @@ public int getLifetime() { return lifetime; } - public boolean getUseJWTAccessWithScope() { - return useJWTAccessWithScope; + public boolean getUseJwtAccessWithScope() { + return useJwtAccessWithScope; } public ServiceAccountCredentials build() { @@ -1187,7 +1187,7 @@ public ServiceAccountCredentials build() { projectId, quotaProjectId, lifetime, - useJWTAccessWithScope); + useJwtAccessWithScope); } } } diff --git a/oauth2_http/javatests/com/google/auth/oauth2/ServiceAccountCredentialsTest.java b/oauth2_http/javatests/com/google/auth/oauth2/ServiceAccountCredentialsTest.java index 6f8115bad..69406878f 100644 --- a/oauth2_http/javatests/com/google/auth/oauth2/ServiceAccountCredentialsTest.java +++ b/oauth2_http/javatests/com/google/auth/oauth2/ServiceAccountCredentialsTest.java @@ -1069,7 +1069,7 @@ public void toString_containsFields() throws IOException { String.format( "ServiceAccountCredentials{clientId=%s, clientEmail=%s, privateKeyId=%s, " + "transportFactoryClassName=%s, tokenServerUri=%s, scopes=%s, defaultScopes=%s, serviceAccountUser=%s, " - + "quotaProjectId=%s, lifetime=3600, useJWTAccessWithScope=false}", + + "quotaProjectId=%s, lifetime=3600, useJwtAccessWithScope=false}", CLIENT_ID, CLIENT_EMAIL, PRIVATE_KEY_ID, @@ -1335,7 +1335,7 @@ public void getRequestMetadata_selfSignedJWT_withScopes() throws IOException { .setServiceAccountUser(USER) .setProjectId(PROJECT_ID) .setHttpTransportFactory(new MockTokenServerTransportFactory()) - .setUseJWTAccessWithScope(true) + .setUseJwtAccessWithScope(true) .build(); Map> metadata = credentials.getRequestMetadata(CALL_URI); @@ -1355,7 +1355,7 @@ public void getRequestMetadata_selfSignedJWT_withDefaultScopes() throws IOExcept .setServiceAccountUser(USER) .setProjectId(PROJECT_ID) .setHttpTransportFactory(new MockTokenServerTransportFactory()) - .setUseJWTAccessWithScope(true) + .setUseJwtAccessWithScope(true) .build(); Map> metadata = credentials.getRequestMetadata(null); @@ -1375,7 +1375,7 @@ public void getRequestMetadataWithCallback_selfSignedJWT() throws IOException { .setProjectId(PROJECT_ID) .setQuotaProjectId("my-quota-project-id") .setHttpTransportFactory(new MockTokenServerTransportFactory()) - .setUseJWTAccessWithScope(true) + .setUseJwtAccessWithScope(true) .setScopes(SCOPES) .build();