diff --git a/appengine/java/com/google/auth/appengine/AppEngineCredentials.java b/appengine/java/com/google/auth/appengine/AppEngineCredentials.java index dbae97052..4d4b6009d 100644 --- a/appengine/java/com/google/auth/appengine/AppEngineCredentials.java +++ b/appengine/java/com/google/auth/appengine/AppEngineCredentials.java @@ -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; @@ -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(); } @@ -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); } diff --git a/oauth2_http/java/com/google/auth/oauth2/GoogleCredentials.java b/oauth2_http/java/com/google/auth/oauth2/GoogleCredentials.java index c32e72f47..c9ea810fb 100644 --- a/oauth2_http/java/com/google/auth/oauth2/GoogleCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/GoogleCredentials.java @@ -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; @@ -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) { diff --git a/oauth2_http/java/com/google/auth/oauth2/JwtProvider.java b/oauth2_http/java/com/google/auth/oauth2/JwtProvider.java index eadee9600..7a2352ac5 100644 --- a/oauth2_http/java/com/google/auth/oauth2/JwtProvider.java +++ b/oauth2_http/java/com/google/auth/oauth2/JwtProvider.java @@ -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); diff --git a/oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java b/oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java index f23232cca..54e6bb941 100644 --- a/oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java +++ b/oauth2_http/java/com/google/auth/oauth2/OAuth2Utils.java @@ -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; @@ -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."; diff --git a/oauth2_http/java/com/google/auth/oauth2/ServiceAccountCredentials.java b/oauth2_http/java/com/google/auth/oauth2/ServiceAccountCredentials.java index b0d580336..64b5d0af2 100644 --- a/oauth2_http/java/com/google/auth/oauth2/ServiceAccountCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/ServiceAccountCredentials.java @@ -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; @@ -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) { diff --git a/oauth2_http/java/com/google/auth/oauth2/ServiceAccountJwtAccessCredentials.java b/oauth2_http/java/com/google/auth/oauth2/ServiceAccountJwtAccessCredentials.java index 6a5805ef4..707b657a7 100644 --- a/oauth2_http/java/com/google/auth/oauth2/ServiceAccountJwtAccessCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/ServiceAccountJwtAccessCredentials.java @@ -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; @@ -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) { diff --git a/oauth2_http/java/com/google/auth/oauth2/UserCredentials.java b/oauth2_http/java/com/google/auth/oauth2/UserCredentials.java index bd8dcfd61..b8a05bcd1 100644 --- a/oauth2_http/java/com/google/auth/oauth2/UserCredentials.java +++ b/oauth2_http/java/com/google/auth/oauth2/UserCredentials.java @@ -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; @@ -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; @@ -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) { @@ -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)); } /**