From 09b77894cb2acc58456d227469239634531e333c Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Tue, 12 Jan 2021 14:16:39 -0500 Subject: [PATCH 1/2] remove deprecated methods --- .../auth/appengine/AppEngineCredentials.java | 30 --------- .../appengine/AppEngineCredentialsTest.java | 62 ------------------- 2 files changed, 92 deletions(-) diff --git a/appengine/java/com/google/auth/appengine/AppEngineCredentials.java b/appengine/java/com/google/auth/appengine/AppEngineCredentials.java index 4d4b6009d..5b3024cf2 100644 --- a/appengine/java/com/google/auth/appengine/AppEngineCredentials.java +++ b/appengine/java/com/google/auth/appengine/AppEngineCredentials.java @@ -35,7 +35,6 @@ import com.google.appengine.api.appidentity.AppIdentityService.GetAccessTokenResult; import com.google.appengine.api.appidentity.AppIdentityServiceFactory; import com.google.auth.ServiceAccountSigner; -import com.google.auth.http.HttpTransportFactory; import com.google.auth.oauth2.AccessToken; import com.google.auth.oauth2.GoogleCredentials; import com.google.common.base.MoreObjects; @@ -46,7 +45,6 @@ import java.util.Collection; import java.util.Date; import java.util.Objects; -import java.util.logging.Logger; /** * OAuth2 credentials representing the built-in service account for Google App Engine. You should @@ -56,7 +54,6 @@ */ public class AppEngineCredentials extends GoogleCredentials implements ServiceAccountSigner { - private static final Logger logger = Logger.getLogger(AppEngineCredentials.class.getName()); private static final long serialVersionUID = -2627708355455064660L; private final String appIdentityServiceClassName; @@ -65,33 +62,6 @@ public class AppEngineCredentials extends GoogleCredentials implements ServiceAc private transient AppIdentityService appIdentityService; - /** - * @deprecated AppEngineCredentials should be instantiated via its Builder. See - * https://github.com/googleapis/google-auth-library-java#google-auth-library-appengine - */ - @Deprecated - public static GoogleCredentials getApplicationDefault() throws IOException { - 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(); - } - - /** - * @deprecated AppEngineCredentials should be instantiated via its Builder. See - * https://github.com/googleapis/google-auth-library-java#google-auth-library-appengine - */ - @Deprecated - public static GoogleCredentials getApplicationDefault(HttpTransportFactory transportFactory) - throws IOException { - 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); - } - private AppEngineCredentials(Collection scopes, AppIdentityService appIdentityService) { this.scopes = scopes == null ? ImmutableSet.of() : ImmutableList.copyOf(scopes); this.appIdentityService = diff --git a/appengine/javatests/com/google/auth/appengine/AppEngineCredentialsTest.java b/appengine/javatests/com/google/auth/appengine/AppEngineCredentialsTest.java index 3c121215c..d37038d5e 100644 --- a/appengine/javatests/com/google/auth/appengine/AppEngineCredentialsTest.java +++ b/appengine/javatests/com/google/auth/appengine/AppEngineCredentialsTest.java @@ -39,9 +39,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import com.google.api.client.http.HttpTransport; import com.google.auth.Credentials; -import com.google.auth.http.HttpTransportFactory; import com.google.auth.oauth2.AccessToken; import com.google.auth.oauth2.BaseSerializationTest; import com.google.auth.oauth2.GoogleCredentials; @@ -53,9 +51,6 @@ import java.util.Date; import java.util.List; import java.util.Map; -import java.util.logging.Handler; -import java.util.logging.LogRecord; -import java.util.logging.Logger; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -264,61 +259,4 @@ private static void assertContainsBearerToken(Map> metadata } assertTrue("Bearer token not found", found); } - - @Test - @SuppressWarnings("deprecation") - public void warnsDefaultCredentials() { - Logger logger = Logger.getLogger(AppEngineCredentials.class.getName()); - LogHandler handler = new LogHandler(); - logger.addHandler(handler); - - try { - Credentials unused = AppEngineCredentials.getApplicationDefault(); - } catch (IOException ex) { - // ignore - this may just fail for not being in a supported environment - } - - LogRecord message = handler.getRecord(); - assertTrue(message.getMessage().contains("You are attempting to")); - } - - @Test - @SuppressWarnings("deprecation") - public void warnsDefaultCredentialsWithTransport() { - Logger logger = Logger.getLogger(AppEngineCredentials.class.getName()); - LogHandler handler = new LogHandler(); - logger.addHandler(handler); - - try { - Credentials unused = - AppEngineCredentials.getApplicationDefault( - new HttpTransportFactory() { - @Override - public HttpTransport create() { - return null; - } - }); - } catch (IOException ex) { - // ignore - this may just fail for not being in a supported environment - } - - LogRecord message = handler.getRecord(); - assertTrue(message.getMessage().contains("You are attempting to")); - } - - private class LogHandler extends Handler { - LogRecord lastRecord; - - public void publish(LogRecord record) { - lastRecord = record; - } - - public LogRecord getRecord() { - return lastRecord; - } - - public void close() {} - - public void flush() {} - } } From 3fe4973cc56a40b1a611e5b24375e547a0189d71 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Thu, 14 Jan 2021 13:55:52 -0500 Subject: [PATCH 2/2] remoive dependency --- appengine/pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/appengine/pom.xml b/appengine/pom.xml index 99bb18a01..492c36930 100644 --- a/appengine/pom.xml +++ b/appengine/pom.xml @@ -58,10 +58,6 @@ com.google.auth google-auth-library-oauth2-http - - com.google.http-client - google-http-client - com.google.appengine appengine-api-1.0-sdk