Skip to content

Commit cb38e8f

Browse files
committed
upgraded auth0-java version
1 parent 27b96e3 commit cb38e8f

File tree

7 files changed

+456
-488
lines changed

7 files changed

+456
-488
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ dependencies {
8080
implementation 'com.google.guava:guava-annotations:r03'
8181
implementation 'commons-codec:commons-codec:1.15'
8282

83-
api 'com.auth0:auth0:1.45.1'
83+
api 'com.auth0:auth0:2.16.0'
8484
api 'com.auth0:java-jwt:3.19.4'
8585
api 'com.auth0:jwks-rsa:0.22.1'
8686

src/main/java/com/auth0/AuthenticationController.java

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.auth0;
22

3-
import com.auth0.client.HttpOptions;
43
import com.auth0.client.auth.AuthAPI;
54
import com.auth0.jwk.JwkProvider;
6-
import com.auth0.net.Telemetry;
5+
import com.auth0.net.client.Auth0HttpClient;
6+
import com.auth0.net.client.DefaultHttpClient;
77
import com.google.common.annotations.VisibleForTesting;
88
import org.apache.commons.lang3.Validate;
99

@@ -61,7 +61,6 @@ public static class Builder {
6161
private boolean useLegacySameSiteCookie;
6262
private String organization;
6363
private String invitation;
64-
private HttpOptions httpOptions;
6564
private String cookiePath;
6665

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

79-
/**
80-
* Customize certain aspects of the underlying HTTP client networking library, such as timeouts and proxy configuration.
81-
*
82-
* @param httpOptions a non-null {@code HttpOptions}
83-
* @return this same builder instance.
84-
*/
85-
public Builder withHttpOptions(HttpOptions httpOptions) {
86-
Validate.notNull(httpOptions);
87-
this.httpOptions = httpOptions;
88-
return this;
89-
}
90-
9178
/**
9279
* Specify that transient authentication-based cookies such as state and nonce are created with the specified
9380
* {@code Path} cookie attribute.
@@ -196,8 +183,7 @@ public Builder withInvitation(String invitation) {
196183
* @throws UnsupportedOperationException if the Implicit Grant is chosen and the environment doesn't support UTF-8 encoding.
197184
*/
198185
public AuthenticationController build() throws UnsupportedOperationException {
199-
AuthAPI apiClient = createAPIClient(domain, clientId, clientSecret, httpOptions);
200-
setupTelemetry(apiClient);
186+
AuthAPI apiClient = createAPIClient(domain, clientId, clientSecret);
201187

202188
final boolean expectedAlgorithmIsExplicitlySetAndAsymmetric = jwkProvider != null;
203189
final SignatureVerifier signatureVerifier;
@@ -234,17 +220,15 @@ IdTokenVerifier.Options createIdTokenVerificationOptions(String issuer, String a
234220
}
235221

236222
@VisibleForTesting
237-
AuthAPI createAPIClient(String domain, String clientId, String clientSecret, HttpOptions httpOptions) {
238-
if (httpOptions != null) {
239-
return new AuthAPI(domain, clientId, clientSecret, httpOptions);
240-
}
241-
return new AuthAPI(domain, clientId, clientSecret);
242-
}
223+
AuthAPI createAPIClient(String domain, String clientId, String clientSecret) {
224+
Auth0HttpClient http = DefaultHttpClient.newBuilder()
225+
.telemetryEnabled(true)
226+
.build();
243227

244-
@VisibleForTesting
245-
void setupTelemetry(AuthAPI client) {
246-
Telemetry telemetry = new Telemetry("auth0-java-mvc-common", obtainPackageVersion());
247-
client.setTelemetry(telemetry);
228+
229+
return AuthAPI.newBuilder(domain, clientId, clientSecret)
230+
.withHttpClient(http)
231+
.build();
248232
}
249233

250234
@VisibleForTesting
@@ -265,23 +249,6 @@ private String getIssuer(String domain) {
265249
}
266250
}
267251

268-
/**
269-
* Whether to enable or not the HTTP Logger for every Request and Response.
270-
* Enabling this can expose sensitive information.
271-
*
272-
* @param enabled whether to enable the HTTP logger or not.
273-
*/
274-
public void setLoggingEnabled(boolean enabled) {
275-
requestProcessor.getClient().setLoggingEnabled(enabled);
276-
}
277-
278-
/**
279-
* Disable sending the Telemetry header on every request to the Auth0 API
280-
*/
281-
public void doNotSendTelemetry() {
282-
requestProcessor.getClient().doNotSendTelemetry();
283-
}
284-
285252
/**
286253
* Process a request to obtain a set of {@link Tokens} that represent successful authentication or authorization.
287254
*

src/main/java/com/auth0/AuthorizeUrl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public String fromPushedAuthorizationRequest() throws InvalidRequestException {
224224
storeTransient();
225225

226226
try {
227-
PushedAuthorizationResponse pushedAuthResponse = authAPI.pushedAuthorizationRequest(redirectUri, responseType, params).execute();
227+
PushedAuthorizationResponse pushedAuthResponse = authAPI.pushedAuthorizationRequest(redirectUri, responseType, params).execute().getBody();
228228
String requestUri = pushedAuthResponse.getRequestURI();
229229
if (requestUri == null || requestUri.isEmpty()) {
230230
throw new InvalidRequestException(API_ERROR, "The PAR request returned a missing or empty request_uri value");

src/main/java/com/auth0/RequestProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ private void checkSessionState(HttpServletRequest request, String stateFromReque
346346
private Tokens exchangeCodeForTokens(String authorizationCode, String redirectUri) throws Auth0Exception {
347347
TokenHolder holder = client
348348
.exchangeCode(authorizationCode, redirectUri)
349-
.execute();
349+
.execute()
350+
.getBody();
350351
return new Tokens(holder.getAccessToken(), holder.getIdToken(), holder.getRefreshToken(), holder.getTokenType(), holder.getExpiresIn());
351352
}
352353

0 commit comments

Comments
 (0)