Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to JDK 17 and JakartaEE 6.0 #138

Closed
wants to merge 4 commits into from
Closed
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
32 changes: 16 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ oss {
}
}

jacoco {
toolVersion = "0.8.8"
}

jacocoTestReport {
reports {
xml.enabled = true
Expand All @@ -40,22 +44,13 @@ jacocoTestReport {

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
// Needed because of broken gradle metadata, see https://github.com/google/guava/issues/6612#issuecomment-1614992368
sourceSets.all {
configurations.getByName(runtimeClasspathConfigurationName) {
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
}
configurations.getByName(compileClasspathConfigurationName) {
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
}
languageVersion = JavaLanguageVersion.of(17)
}
}

compileJava {
sourceCompatibility '1.8'
targetCompatibility '1.8'
sourceCompatibility '17'
targetCompatibility '17'
}

test {
Expand All @@ -67,7 +62,7 @@ test {
}

dependencies {
implementation 'javax.servlet:javax.servlet-api:3.1.0'
implementation 'jakarta.servlet:jakarta.servlet-api:6.0.0'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'com.google.guava:guava-annotations:r03'
implementation 'commons-codec:commons-codec:1.15'
Expand All @@ -79,9 +74,14 @@ dependencies {
testImplementation 'org.bouncycastle:bcprov-jdk15on:1.64'
testImplementation 'org.hamcrest:java-hamcrest:2.0.0.0'
testImplementation 'org.hamcrest:hamcrest-core:1.3'
testImplementation 'org.mockito:mockito-core:2.8.9'
// https://mvnrepository.com/artifact/org.mockito/mockito-core
testImplementation 'org.mockito:mockito-core:4.11.0'

testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
testImplementation 'org.springframework:spring-test:4.3.14.RELEASE'
// https://mvnrepository.com/artifact/org.springframework/spring-test
testImplementation 'org.springframework:spring-test:6.0.14'

testImplementation 'org.springframework:spring-web:6.0.14'
testImplementation 'com.squareup.okhttp3:okhttp:4.11.0'
}

Expand All @@ -91,4 +91,4 @@ task exportVersion() {
doLast {
new File(rootDir, "version.txt").text = "$version"
}
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
netbeans.hint.jdkPlatform=JDK_11__System_
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
8 changes: 4 additions & 4 deletions src/main/java/com/auth0/AuthenticationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang3.Validate;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;


/**
Expand Down Expand Up @@ -317,7 +317,7 @@ public Tokens handle(HttpServletRequest request, HttpServletResponse response) t
* when building the {@link AuthorizeUrl} that the user will be redirected to to login. Failure to do so may result
* in a broken login experience for the user.</p>
*
* @deprecated This method uses the {@link javax.servlet.http.HttpSession} for auth-based data, and is incompatible
* @deprecated This method uses the {@link jakarta.servlet.http.HttpSession} for auth-based data, and is incompatible
* with clients that are using the "id_token" or "token" responseType with browsers that enforce SameSite cookie
* restrictions. This method will be removed in version 2.0.0. Use
* {@link AuthenticationController#handle(HttpServletRequest, HttpServletResponse)} instead.
Expand All @@ -341,7 +341,7 @@ public Tokens handle(HttpServletRequest request) throws IdentityVerificationExce
* {@link AuthenticationController#handle(HttpServletRequest)} method. Failure to do so may result in a broken login
* experience for users.</p>
*
* @deprecated This method stores data in the {@link javax.servlet.http.HttpSession}, and is incompatible with clients
* @deprecated This method stores data in the {@link jakarta.servlet.http.HttpSession}, and is incompatible with clients
* that are using the "id_token" or "token" responseType with browsers that enforce SameSite cookie restrictions.
* This method will be removed in version 2.0.0. Use
* {@link AuthenticationController#buildAuthorizeUrl(HttpServletRequest, HttpServletResponse, String)} instead.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/auth0/AuthorizeUrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import com.auth0.exception.Auth0Exception;
import com.auth0.json.auth.PushedAuthorizationResponse;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.*;

import static com.auth0.IdentityVerificationException.API_ERROR;
Expand Down Expand Up @@ -39,7 +39,7 @@ public class AuthorizeUrl {
*
* Using this constructor with a non-null {@link HttpServletResponse} will store the state and nonce as
* cookies when the {@link AuthorizeUrl#build()} method is called, with the appropriate SameSite attribute depending
* on the responseType. State and nonce will also be stored in the {@link javax.servlet.http.HttpSession} as a fallback,
* on the responseType. State and nonce will also be stored in the {@link jakarta.servlet.http.HttpSession} as a fallback,
* but this behavior will be removed in a future release, and only cookies will be used.
*
* @param client the Auth0 Authentication API client
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/auth0/RandomStorage.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.auth0;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;

class RandomStorage extends SessionUtils {

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/auth0/RequestProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import com.auth0.json.auth.TokenHolder;
import org.apache.commons.lang3.Validate;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/auth0/SessionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import org.apache.commons.lang3.Validate;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;

/**
* Helper class to handle easy session key-value storage.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/auth0/TransientCookieStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import org.apache.commons.lang3.Validate;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
Expand Down
20 changes: 10 additions & 10 deletions src/test/java/com/auth0/AuthenticationControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -412,7 +412,7 @@ public void shouldSetLaxCookiesAndNoLegacyCookieWhenCodeFlow() {
List<String> headers = response.getHeaders("Set-Cookie");

assertThat(headers.size(), is(1));
assertThat(headers, everyItem(is("com.auth0.state=state; HttpOnly; Max-Age=600; SameSite=Lax")));
assertThat(headers, everyItem(matchesPattern("com\\.auth0\\.state=state; Max-Age=600; Expires=.*?; HttpOnly; SameSite=Lax")));
}

@Test
Expand All @@ -431,10 +431,10 @@ public void shouldSetSameSiteNoneCookiesAndLegacyCookieWhenIdTokenResponse() {
List<String> headers = response.getHeaders("Set-Cookie");

assertThat(headers.size(), is(4));
assertThat(headers, hasItem("com.auth0.state=state; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem("_com.auth0.state=state; HttpOnly; Max-Age=600"));
assertThat(headers, hasItem("com.auth0.nonce=nonce; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem("_com.auth0.nonce=nonce; HttpOnly; Max-Age=600"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.state=state; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
assertThat(headers, hasItem(matchesPattern("_com\\.auth0\\.state=state; Max-Age=600; Expires=.*?; HttpOnly")));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.nonce=nonce; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
assertThat(headers, hasItem(matchesPattern("_com\\.auth0\\.nonce=nonce; Max-Age=600; Expires=.*?; HttpOnly")));
}

@Test
Expand All @@ -454,8 +454,8 @@ public void shouldSetSameSiteNoneCookiesAndNoLegacyCookieWhenIdTokenResponse() {
List<String> headers = response.getHeaders("Set-Cookie");

assertThat(headers.size(), is(2));
assertThat(headers, hasItem("com.auth0.state=state; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem("com.auth0.nonce=nonce; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.state=state; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.nonce=nonce; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
}

@Test
Expand Down Expand Up @@ -581,6 +581,6 @@ public void shouldConfigureCookiePath() {
List<String> headers = response.getHeaders("Set-Cookie");

assertThat(headers.size(), is(1));
assertThat(headers, everyItem(is("com.auth0.state=state; HttpOnly; Max-Age=600; Path=/Path; SameSite=Lax")));
assertThat(headers, everyItem(matchesPattern("com\\.auth0\\.state=state; Path=/Path; Max-Age=600; Expires=.*?; HttpOnly; SameSite=Lax")));
}
}
23 changes: 12 additions & 11 deletions src/test/java/com/auth0/AuthorizeUrlTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Collection;
import java.util.Map;

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.matchesPattern;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.*;
Expand Down Expand Up @@ -91,8 +92,8 @@ public void shouldSetNonceSameSiteAndLegacyCookieByDefault() {

Collection<String> headers = response.getHeaders("Set-Cookie");
assertThat(headers.size(), is(2));
assertThat(headers, hasItem("com.auth0.nonce=asdfghjkl; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem("_com.auth0.nonce=asdfghjkl; HttpOnly; Max-Age=600"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.nonce=asdfghjkl; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
assertThat(headers, hasItem(matchesPattern("_com\\.auth0\\.nonce=asdfghjkl; Max-Age=600; Expires=.*?; HttpOnly")));
}

@Test
Expand All @@ -105,7 +106,7 @@ public void shouldSetNonceSameSiteAndNotLegacyCookieWhenConfigured() {

Collection<String> headers = response.getHeaders("Set-Cookie");
assertThat(headers.size(), is(1));
assertThat(headers, hasItem("com.auth0.nonce=asdfghjkl; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.nonce=asdfghjkl; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
}

@Test
Expand All @@ -117,8 +118,8 @@ public void shouldSetStateSameSiteAndLegacyCookieByDefault() {

Collection<String> headers = response.getHeaders("Set-Cookie");
assertThat(headers.size(), is(2));
assertThat(headers, hasItem("com.auth0.state=asdfghjkl; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem("_com.auth0.state=asdfghjkl; HttpOnly; Max-Age=600"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.state=asdfghjkl; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
assertThat(headers, hasItem(matchesPattern("_com\\.auth0\\.state=asdfghjkl; Max-Age=600; Expires=.*?; HttpOnly")));
}

@Test
Expand All @@ -131,7 +132,7 @@ public void shouldSetStateSameSiteAndNotLegacyCookieWhenConfigured() {

Collection<String> headers = response.getHeaders("Set-Cookie");
assertThat(headers.size(), is(1));
assertThat(headers, hasItem("com.auth0.state=asdfghjkl; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.state=asdfghjkl; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
}

@Test
Expand All @@ -144,7 +145,7 @@ public void shouldSetSecureCookieWhenConfiguredTrue() {

Collection<String> headers = response.getHeaders("Set-Cookie");
assertThat(headers.size(), is(1));
assertThat(headers, hasItem("com.auth0.state=asdfghjkl; HttpOnly; Max-Age=600; SameSite=Lax; Secure"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.state=asdfghjkl; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=Lax")));
}

@Test
Expand All @@ -157,8 +158,8 @@ public void shouldSetSecureCookieWhenConfiguredFalseAndSameSiteNone() {

Collection<String> headers = response.getHeaders("Set-Cookie");
assertThat(headers.size(), is(2));
assertThat(headers, hasItem("com.auth0.state=asdfghjkl; HttpOnly; Max-Age=600; SameSite=None; Secure"));
assertThat(headers, hasItem("_com.auth0.state=asdfghjkl; HttpOnly; Max-Age=600"));
assertThat(headers, hasItem(matchesPattern("com\\.auth0\\.state=asdfghjkl; Max-Age=600; Expires=.*?; Secure; HttpOnly; SameSite=None")));
assertThat(headers, hasItem(matchesPattern("_com\\.auth0\\.state=asdfghjkl; Max-Age=600; Expires=.*?; HttpOnly")));
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/auth0/RequestProcessorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand Down
Loading