Skip to content

Commit

Permalink
update useJWTAccessWithScope name
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetic1728 committed Jul 9, 2021
1 parent 26dacb7 commit b09cef0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public class ServiceAccountCredentials extends GoogleCredentials
private final Collection<String> defaultScopes;
private final String quotaProjectId;
private final int lifetime;
private final boolean useJWTAccessWithScope;
private final boolean useJwtAccessWithScope;

private transient HttpTransportFactory transportFactory;

Expand All @@ -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,
Expand All @@ -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);
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -692,7 +692,7 @@ public GoogleCredentials createScoped(
projectId,
quotaProjectId,
lifetime,
useJWTAccessWithScope);
useJwtAccessWithScope);
}

/**
Expand All @@ -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
Expand All @@ -733,7 +733,7 @@ public GoogleCredentials createDelegated(String user) {
projectId,
quotaProjectId,
lifetime,
useJWTAccessWithScope);
useJwtAccessWithScope);
}

public final String getClientId() {
Expand Down Expand Up @@ -781,8 +781,8 @@ int getLifetime() {
return lifetime;
}

public boolean getUseJWTAccessWithScope() {
return useJWTAccessWithScope;
public boolean getUseJwtAccessWithScope() {
return useJwtAccessWithScope;
}

@Override
Expand Down Expand Up @@ -843,7 +843,7 @@ public int hashCode() {
defaultScopes,
quotaProjectId,
lifetime,
useJWTAccessWithScope);
useJwtAccessWithScope);
}

@Override
Expand All @@ -859,7 +859,7 @@ public String toString() {
.add("serviceAccountUser", serviceAccountUser)
.add("quotaProjectId", quotaProjectId)
.add("lifetime", lifetime)
.add("useJWTAccessWithScope", useJWTAccessWithScope)
.add("useJwtAccessWithScope", useJwtAccessWithScope)
.toString();
}

Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand All @@ -991,7 +991,7 @@ public Map<String, List<String>> 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<String, List<String>> requestMetadata = jwtCredentials.getRequestMetadata(null);
return addQuotaProjectIdToRequestMetadata(quotaProjectId, requestMetadata);
Expand Down Expand Up @@ -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() {}

Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -1169,8 +1169,8 @@ public int getLifetime() {
return lifetime;
}

public boolean getUseJWTAccessWithScope() {
return useJWTAccessWithScope;
public boolean getUseJwtAccessWithScope() {
return useJwtAccessWithScope;
}

public ServiceAccountCredentials build() {
Expand All @@ -1187,7 +1187,7 @@ public ServiceAccountCredentials build() {
projectId,
quotaProjectId,
lifetime,
useJWTAccessWithScope);
useJwtAccessWithScope);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<String, List<String>> metadata = credentials.getRequestMetadata(CALL_URI);
Expand All @@ -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<String, List<String>> metadata = credentials.getRequestMetadata(null);
Expand All @@ -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();

Expand Down

0 comments on commit b09cef0

Please sign in to comment.