diff --git a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java index e92c64bed90e..47cb398d26bf 100644 --- a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java +++ b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java @@ -36,7 +36,6 @@ import com.google.api.client.http.HttpHeaders; import com.google.api.client.json.GenericJson; import com.google.api.client.util.Data; -import com.google.api.core.InternalApi; import com.google.auth.RequestMetadataCallback; import com.google.auth.http.HttpTransportFactory; import com.google.common.base.MoreObjects; @@ -99,9 +98,6 @@ public abstract class ExternalAccountCredentials extends GoogleCredentials { private EnvironmentProvider environmentProvider; private PropertyProvider propertyProvider; - private int connectTimeout; - private int readTimeout; - /** * Constructor with minimum identifying information and custom HTTP transport. Does not support * workforce credentials. @@ -281,8 +277,6 @@ protected ExternalAccountCredentials(ExternalAccountCredentials.Builder builder) : builder.metricsHandler; this.name = GoogleCredentialsInfo.EXTERNAL_ACCOUNT_CREDENTIALS.getCredentialName(); - this.connectTimeout = builder.connectTimeout; - this.readTimeout = builder.readTimeout; } ImpersonatedCredentials buildImpersonatedCredentials() { @@ -317,8 +311,6 @@ ImpersonatedCredentials buildImpersonatedCredentials() { .setScopes(new ArrayList<>(scopes)) .setLifetime(this.serviceAccountImpersonationOptions.lifetime) .setIamEndpointOverride(serviceAccountImpersonationUrl) - .setConnectTimeout(connectTimeout) - .setReadTimeout(readTimeout) .build(); } @@ -547,9 +539,7 @@ protected AccessToken exchangeExternalCredentialForAccessToken( StsRequestHandler.Builder requestHandler = StsRequestHandler.newBuilder( - tokenUrl, stsTokenExchangeRequest, transportFactory.create().createRequestFactory()) - .setConnectTimeout(connectTimeout) - .setReadTimeout(readTimeout); + tokenUrl, stsTokenExchangeRequest, transportFactory.create().createRequestFactory()); // If this credential was initialized with a Workforce configuration then the // workforcePoolUserProject must be passed to the Security Token Service via the internal @@ -792,9 +782,6 @@ public abstract static class Builder extends GoogleCredentials.Builder { @Nullable protected String workforcePoolUserProject; @Nullable protected ServiceAccountImpersonationOptions serviceAccountImpersonationOptions; - protected int connectTimeout = 20000; // Default to 20000ms = 20s - protected int readTimeout = 20000; // Default to 20000ms = 20s - /* The field is not being used and value not set. Superseded by the same field in the {@link GoogleCredentials.Builder}. */ @@ -821,8 +808,6 @@ protected Builder(ExternalAccountCredentials credentials) { this.workforcePoolUserProject = credentials.workforcePoolUserProject; this.serviceAccountImpersonationOptions = credentials.serviceAccountImpersonationOptions; this.metricsHandler = credentials.metricsHandler; - this.connectTimeout = credentials.connectTimeout; - this.readTimeout = credentials.readTimeout; } /** @@ -1015,20 +1000,6 @@ public Builder setUniverseDomain(String universeDomain) { return this; } - /** Warning: Not for public use and can be removed at any time. */ - @InternalApi - public Builder setConnectTimeout(int connectTimeout) { - this.connectTimeout = connectTimeout; - return this; - } - - /** Warning: Not for public use and can be removed at any time. */ - @InternalApi - public Builder setReadTimeout(int readTimeout) { - this.readTimeout = readTimeout; - return this; - } - /** * Sets the optional Environment Provider. * diff --git a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java index 274f30ff9077..34716d92b552 100644 --- a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java +++ b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/ImpersonatedCredentials.java @@ -44,7 +44,6 @@ import com.google.api.client.json.GenericJson; import com.google.api.client.json.JsonObjectParser; import com.google.api.client.util.GenericData; -import com.google.api.core.InternalApi; import com.google.api.core.ObsoleteApi; import com.google.auth.CredentialTypeForMetrics; import com.google.auth.ServiceAccountSigner; @@ -118,9 +117,6 @@ public class ImpersonatedCredentials extends GoogleCredentials private transient Calendar calendar; - private int connectTimeout; - private int readTimeout; - /** * @param sourceCredentials the source credential used to acquire the impersonated credentials. It * should be either a user account credential or a service account credential. @@ -567,8 +563,6 @@ private ImpersonatedCredentials(Builder builder) throws IOException { + "does not match %s universe domain set for impersonated credentials.", this.sourceCredentials.getUniverseDomain(), builder.getUniverseDomain())); } - this.connectTimeout = builder.connectTimeout; - this.readTimeout = builder.readTimeout; } /** @@ -597,12 +591,6 @@ public AccessToken refreshAccessToken() throws IOException { || (isDefaultUniverseDomain() && ((ServiceAccountCredentials) this.sourceCredentials) .shouldUseAssertionFlowForGdu())) { - if (this.sourceCredentials instanceof IdentityPoolCredentials) { - this.sourceCredentials = - ((IdentityPoolCredentials) this.sourceCredentials) - .toBuilder().setConnectTimeout(connectTimeout).setReadTimeout(readTimeout).build(); - } - try { this.sourceCredentials.refreshIfExpired(); } catch (IOException e) { @@ -635,8 +623,6 @@ public AccessToken refreshAccessToken() throws IOException { // Disable automatic logging by google-http-java-client to prevent leakage of sensitive tokens. // Client Library Debug Logging via LoggingUtils is used instead. request.setLoggingEnabled(false); - request.setConnectTimeout(connectTimeout); - request.setReadTimeout(readTimeout); adapter.initialize(request); request.setParser(parser); MetricsUtils.setMetricsHeader( @@ -783,9 +769,6 @@ public static class Builder extends GoogleCredentials.Builder { private String iamEndpointOverride; private Calendar calendar = Calendar.getInstance(); - private int connectTimeout = 20000; // Default to 20000ms = 20s - private int readTimeout = 20000; // Default to 20000ms = 20s - protected Builder() {} /** @@ -809,8 +792,6 @@ protected Builder(ImpersonatedCredentials credentials) { this.lifetime = credentials.lifetime; this.transportFactory = credentials.transportFactory; this.iamEndpointOverride = credentials.iamEndpointOverride; - this.connectTimeout = credentials.connectTimeout; - this.readTimeout = credentials.readTimeout; } @CanIgnoreReturnValue @@ -912,20 +893,6 @@ public Builder setCalendar(Calendar calendar) { return this; } - /** Warning: Not for public use and can be removed at any time. */ - @InternalApi - public Builder setConnectTimeout(int connectTimeout) { - this.connectTimeout = connectTimeout; - return this; - } - - /** Warning: Not for public use and can be removed at any time. */ - @InternalApi - public Builder setReadTimeout(int readTimeout) { - this.readTimeout = readTimeout; - return this; - } - /** * This method is marked obsolete. There is no alternative to getting a custom calendar for the * Credential. diff --git a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/StsRequestHandler.java b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/StsRequestHandler.java index ee32b2cd6863..ecd33ca14cf6 100644 --- a/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/StsRequestHandler.java +++ b/google-auth-library-java/oauth2_http/java/com/google/auth/oauth2/StsRequestHandler.java @@ -42,7 +42,6 @@ import com.google.api.client.json.JsonObjectParser; import com.google.api.client.json.JsonParser; import com.google.api.client.util.GenericData; -import com.google.api.core.InternalApi; import com.google.common.base.Joiner; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; @@ -77,22 +76,12 @@ public final class StsRequestHandler { @Nullable private final HttpHeaders headers; @Nullable private final String internalOptions; - private final int connectTimeout; - private final int readTimeout; - - /** - * Internal constructor. - * - * @return an StsTokenExchangeResponse instance if the request was successful - */ private StsRequestHandler(Builder builder) { this.tokenExchangeEndpoint = builder.tokenExchangeEndpoint; this.request = builder.request; this.httpRequestFactory = builder.httpRequestFactory; this.headers = builder.headers; this.internalOptions = builder.internalOptions; - this.connectTimeout = builder.connectTimeout; - this.readTimeout = builder.readTimeout; } /** @@ -125,8 +114,6 @@ public StsTokenExchangeResponse exchangeToken() throws IOException { if (headers != null) { httpRequest.setHeaders(headers); } - httpRequest.setConnectTimeout(connectTimeout); - httpRequest.setReadTimeout(readTimeout); try { LoggingUtils.logRequest(httpRequest, LOGGER_PROVIDER, "Sending request for token exchange"); @@ -225,9 +212,6 @@ public static class Builder { @Nullable private HttpHeaders headers; @Nullable private String internalOptions; - private int connectTimeout = 20000; // Default to 20000ms = 20s - private int readTimeout = 20000; // Default to 20000ms = 20s - private Builder( String tokenExchangeEndpoint, StsTokenExchangeRequest stsTokenExchangeRequest, @@ -249,20 +233,6 @@ public StsRequestHandler.Builder setInternalOptions(String internalOptions) { return this; } - /** Warning: Not for public use and can be removed at any time. */ - @InternalApi - public StsRequestHandler.Builder setConnectTimeout(int connectTimeout) { - this.connectTimeout = connectTimeout; - return this; - } - - /** Warning: Not for public use and can be removed at any time. */ - @InternalApi - public StsRequestHandler.Builder setReadTimeout(int readTimeout) { - this.readTimeout = readTimeout; - return this; - } - public StsRequestHandler build() { return new StsRequestHandler(this); }