Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ dependencies {
implementation 'com.google.guava:guava-annotations:r03'
implementation 'commons-codec:commons-codec:1.15'

api 'com.auth0:auth0:1.45.1'
api 'com.auth0:auth0:2.16.0'
api 'com.auth0:java-jwt:3.19.4'
api 'com.auth0:jwks-rsa:0.22.1'

Expand Down
55 changes: 11 additions & 44 deletions src/main/java/com/auth0/AuthenticationController.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.auth0;

import com.auth0.client.HttpOptions;
import com.auth0.client.auth.AuthAPI;
import com.auth0.jwk.JwkProvider;
import com.auth0.net.Telemetry;
import com.auth0.net.client.Auth0HttpClient;
import com.auth0.net.client.DefaultHttpClient;
import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang3.Validate;

Expand Down Expand Up @@ -61,7 +61,6 @@ public static class Builder {
private boolean useLegacySameSiteCookie;
private String organization;
private String invitation;
private HttpOptions httpOptions;
private String cookiePath;

Builder(String domain, String clientId, String clientSecret) {
Expand All @@ -76,18 +75,6 @@ public static class Builder {
this.useLegacySameSiteCookie = true;
}

/**
* Customize certain aspects of the underlying HTTP client networking library, such as timeouts and proxy configuration.
*
* @param httpOptions a non-null {@code HttpOptions}
* @return this same builder instance.
*/
public Builder withHttpOptions(HttpOptions httpOptions) {
Validate.notNull(httpOptions);
this.httpOptions = httpOptions;
return this;
}

/**
* Specify that transient authentication-based cookies such as state and nonce are created with the specified
* {@code Path} cookie attribute.
Expand Down Expand Up @@ -196,8 +183,7 @@ public Builder withInvitation(String invitation) {
* @throws UnsupportedOperationException if the Implicit Grant is chosen and the environment doesn't support UTF-8 encoding.
*/
public AuthenticationController build() throws UnsupportedOperationException {
AuthAPI apiClient = createAPIClient(domain, clientId, clientSecret, httpOptions);
setupTelemetry(apiClient);
AuthAPI apiClient = createAPIClient(domain, clientId, clientSecret);

final boolean expectedAlgorithmIsExplicitlySetAndAsymmetric = jwkProvider != null;
final SignatureVerifier signatureVerifier;
Expand Down Expand Up @@ -234,17 +220,15 @@ IdTokenVerifier.Options createIdTokenVerificationOptions(String issuer, String a
}

@VisibleForTesting
AuthAPI createAPIClient(String domain, String clientId, String clientSecret, HttpOptions httpOptions) {
if (httpOptions != null) {
return new AuthAPI(domain, clientId, clientSecret, httpOptions);
}
return new AuthAPI(domain, clientId, clientSecret);
}
AuthAPI createAPIClient(String domain, String clientId, String clientSecret) {
Auth0HttpClient http = DefaultHttpClient.newBuilder()
.telemetryEnabled(true)
.build();

@VisibleForTesting
void setupTelemetry(AuthAPI client) {
Telemetry telemetry = new Telemetry("auth0-java-mvc-common", obtainPackageVersion());
client.setTelemetry(telemetry);

return AuthAPI.newBuilder(domain, clientId, clientSecret)
.withHttpClient(http)
.build();
}

@VisibleForTesting
Expand All @@ -265,23 +249,6 @@ private String getIssuer(String domain) {
}
}

/**
* Whether to enable or not the HTTP Logger for every Request and Response.
* Enabling this can expose sensitive information.
*
* @param enabled whether to enable the HTTP logger or not.
*/
public void setLoggingEnabled(boolean enabled) {
requestProcessor.getClient().setLoggingEnabled(enabled);
}

/**
* Disable sending the Telemetry header on every request to the Auth0 API
*/
public void doNotSendTelemetry() {
requestProcessor.getClient().doNotSendTelemetry();
}

/**
* Process a request to obtain a set of {@link Tokens} that represent successful authentication or authorization.
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/auth0/AuthorizeUrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public String fromPushedAuthorizationRequest() throws InvalidRequestException {
storeTransient();

try {
PushedAuthorizationResponse pushedAuthResponse = authAPI.pushedAuthorizationRequest(redirectUri, responseType, params).execute();
PushedAuthorizationResponse pushedAuthResponse = authAPI.pushedAuthorizationRequest(redirectUri, responseType, params).execute().getBody();
String requestUri = pushedAuthResponse.getRequestURI();
if (requestUri == null || requestUri.isEmpty()) {
throw new InvalidRequestException(API_ERROR, "The PAR request returned a missing or empty request_uri value");
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/auth0/RequestProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ private void checkSessionState(HttpServletRequest request, String stateFromReque
private Tokens exchangeCodeForTokens(String authorizationCode, String redirectUri) throws Auth0Exception {
TokenHolder holder = client
.exchangeCode(authorizationCode, redirectUri)
.execute();
.execute()
.getBody();
return new Tokens(holder.getAccessToken(), holder.getIdToken(), holder.getRefreshToken(), holder.getTokenType(), holder.getExpiresIn());
}

Expand Down
Loading
Loading