Skip to content

Commit

Permalink
fix: remove deprecated methods (googleapis#537)
Browse files Browse the repository at this point in the history
* remove deprecated methods

* remoive dependency

Co-authored-by: Jeff Ching <[email protected]>
  • Loading branch information
elharo and chingor13 authored Jan 14, 2021
1 parent f2ab4f1 commit 427963e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 96 deletions.
30 changes: 0 additions & 30 deletions appengine/java/com/google/auth/appengine/AppEngineCredentials.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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() {}
}
}
4 changes: 0 additions & 4 deletions appengine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 427963e

Please sign in to comment.