Skip to content
Permalink
Browse files
fix: remove deprecated methods (#537)
* remove deprecated methods

* remoive dependency

Co-authored-by: Jeff Ching <chingor@google.com>
  • Loading branch information
elharo and chingor13 committed Jan 14, 2021
1 parent f2ab4f1 commit 427963e04702d8b73eca5ed555539b11bbe97342
@@ -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<String> scopes, AppIdentityService appIdentityService) {
this.scopes = scopes == null ? ImmutableSet.<String>of() : ImmutableList.copyOf(scopes);
this.appIdentityService =
@@ -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<String, List<String>> 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() {}
}
}
@@ -58,10 +58,6 @@
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>

0 comments on commit 427963e

Please sign in to comment.