Skip to content

Commit

Permalink
Merge branch 'master' into lifespan_srv
Browse files Browse the repository at this point in the history
  • Loading branch information
chingor13 authored Jan 12, 2021
2 parents 28ad538 + af21727 commit 6ed887a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@
*/
public class AppEngineCredentials extends GoogleCredentials implements ServiceAccountSigner {

private static final Logger LOGGER = Logger.getLogger(AppEngineCredentials.class.getName());
private static final String APPLICATION_DEFAULT_CREDENTIALS_WARNING =
"You are attempting to "
+ "fetch Application Default Credentials from com.google.auth.appengine.AppEngineCredentials."
+ " This method will not return a com.google.auth.appengine.AppEngineCredentials instance.";
private static final Logger logger = Logger.getLogger(AppEngineCredentials.class.getName());
private static final long serialVersionUID = -2627708355455064660L;

private final String appIdentityServiceClassName;
Expand All @@ -75,7 +71,10 @@ public class AppEngineCredentials extends GoogleCredentials implements ServiceAc
*/
@Deprecated
public static GoogleCredentials getApplicationDefault() throws IOException {
LOGGER.warning(APPLICATION_DEFAULT_CREDENTIALS_WARNING);
logger.warning(
"You are attempting to "
+ "fetch Application Default Credentials from com.google.auth.appengine.AppEngineCredentials."
+ " This method will not return a com.google.auth.appengine.AppEngineCredentials instance.");
return GoogleCredentials.getApplicationDefault();
}

Expand All @@ -86,7 +85,10 @@ public static GoogleCredentials getApplicationDefault() throws IOException {
@Deprecated
public static GoogleCredentials getApplicationDefault(HttpTransportFactory transportFactory)
throws IOException {
LOGGER.warning(APPLICATION_DEFAULT_CREDENTIALS_WARNING);
logger.warning(
"You are attempting to fetch "
+ "Application Default Credentials from com.google.auth.appengine.AppEngineCredentials. "
+ "This method does not return a com.google.auth.appengine.AppEngineCredentials instance.");
return GoogleCredentials.getApplicationDefault(transportFactory);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.google.common.collect.ImmutableList;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -153,7 +154,7 @@ public static GoogleCredentials fromStream(
JsonFactory jsonFactory = OAuth2Utils.JSON_FACTORY;
JsonObjectParser parser = new JsonObjectParser(jsonFactory);
GenericJson fileContents =
parser.parseAndClose(credentialsStream, OAuth2Utils.UTF_8, GenericJson.class);
parser.parseAndClose(credentialsStream, StandardCharsets.UTF_8, GenericJson.class);

String fileType = (String) fileContents.get("type");
if (fileType == null) {
Expand Down
3 changes: 1 addition & 2 deletions oauth2_http/java/com/google/auth/oauth2/JwtProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public interface JwtProvider {
/**
* Returns a new JwtCredentials instance with modified claims.
*
* @param newClaims new claims. Any unspecified claim fields will default to the the current
* values.
* @param newClaims new claims. Any unspecified claim fields default to the current values.
* @return new credentials
*/
JwtCredentials jwtWithClaims(JwtClaims newClaims);
Expand Down
3 changes: 0 additions & 3 deletions oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URI;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Map;
Expand All @@ -68,8 +67,6 @@ class OAuth2Utils {

static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();

static final Charset UTF_8 = Charset.forName("UTF-8");

private static String VALUE_NOT_FOUND_MESSAGE = "%sExpected value %s not found.";
private static String VALUE_WRONG_TYPE_MESSAGE = "%sExpected %s value %s of wrong type.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import java.io.StringReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
Expand Down Expand Up @@ -390,7 +391,7 @@ public static ServiceAccountCredentials fromStream(
JsonFactory jsonFactory = OAuth2Utils.JSON_FACTORY;
JsonObjectParser parser = new JsonObjectParser(jsonFactory);
GenericJson fileContents =
parser.parseAndClose(credentialsStream, OAuth2Utils.UTF_8, GenericJson.class);
parser.parseAndClose(credentialsStream, StandardCharsets.UTF_8, GenericJson.class);

String fileType = (String) fileContents.get("type");
if (fileType == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
Expand Down Expand Up @@ -250,7 +251,7 @@ public static ServiceAccountJwtAccessCredentials fromStream(
JsonFactory jsonFactory = OAuth2Utils.JSON_FACTORY;
JsonObjectParser parser = new JsonObjectParser(jsonFactory);
GenericJson fileContents =
parser.parseAndClose(credentialsStream, OAuth2Utils.UTF_8, GenericJson.class);
parser.parseAndClose(credentialsStream, StandardCharsets.UTF_8, GenericJson.class);

String fileType = (String) fileContents.get("type");
if (fileType == null) {
Expand Down
6 changes: 3 additions & 3 deletions oauth2_http/java/com/google/auth/oauth2/UserCredentials.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
package com.google.auth.oauth2;

import static com.google.auth.oauth2.OAuth2Utils.JSON_FACTORY;
import static com.google.auth.oauth2.OAuth2Utils.UTF_8;
import static com.google.common.base.MoreObjects.firstNonNull;

import com.google.api.client.http.GenericUrl;
Expand All @@ -52,6 +51,7 @@
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -167,7 +167,7 @@ public static UserCredentials fromStream(
JsonFactory jsonFactory = JSON_FACTORY;
JsonObjectParser parser = new JsonObjectParser(jsonFactory);
GenericJson fileContents =
parser.parseAndClose(credentialsStream, OAuth2Utils.UTF_8, GenericJson.class);
parser.parseAndClose(credentialsStream, StandardCharsets.UTF_8, GenericJson.class);

String fileType = (String) fileContents.get("type");
if (fileType == null) {
Expand Down Expand Up @@ -263,7 +263,7 @@ private InputStream getUserCredentialsStream() throws IOException {
}
json.setFactory(JSON_FACTORY);
String text = json.toPrettyString();
return new ByteArrayInputStream(text.getBytes(UTF_8));
return new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8));
}

/**
Expand Down

0 comments on commit 6ed887a

Please sign in to comment.