From 2678154ff714f361378e22ed058e2578a3db0f02 Mon Sep 17 00:00:00 2001 From: jecos Date: Mon, 18 Mar 2024 13:31:24 -0400 Subject: [PATCH] feat: BG-36 Update to zeppelin 0.11 --- .gitignore | 3 +- pom.xml | 36 +++++++++++-------- .../KeycloakRolesAuthorizationGenerator.java | 14 ++++---- .../ForceDefaultURLCallbackLogicTests.java | 13 ++++--- .../bio/ferlab/UsernameAuthorizerTest.java | 8 ++--- 5 files changed, 41 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 5bd05d6..34e1547 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ target -.idea \ No newline at end of file +.idea +*.iml \ No newline at end of file diff --git a/pom.xml b/pom.xml index a21ce5c..0ef632d 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,7 @@ org.apache.maven.plugins maven-assembly-plugin + 3.7.0 package @@ -29,22 +30,22 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + 3.2.5 org.junit.jupiter junit-jupiter-engine - 5.8.0 + 5.10.2 maven-deploy-plugin - 3.0.0-M1 + 3.1.1 maven-release-plugin - 3.0.0-M1 + 3.0.1 v@{project.version} @@ -66,7 +67,7 @@ org.apache.zeppelin zeppelin-server - 0.10.0 + 0.11.0 javax.annotation @@ -93,24 +94,31 @@ io.buji buji-pac4j - 6.0.0 + 8.1.0 org.pac4j pac4j-oidc - 5.1.3 + 5.7.3 + - org.junit.jupiter - junit-jupiter-engine - 5.8.0 + org.pac4j + jakartaee-pac4j + 7.1.0 + test + + + jakarta.servlet + jakarta.servlet-api + 6.0.0 test - org.springframework - spring-test + org.junit.jupiter + junit-jupiter-engine + 5.8.0 test - 5.3.10 org.mockito @@ -133,7 +141,7 @@ com.amazonaws aws-java-sdk-kms - 1.11.736 + 1.12.681 commons-logging diff --git a/src/main/java/bio/ferlab/pac4j/authorization/generator/KeycloakRolesAuthorizationGenerator.java b/src/main/java/bio/ferlab/pac4j/authorization/generator/KeycloakRolesAuthorizationGenerator.java index 913bd15..0e7694e 100644 --- a/src/main/java/bio/ferlab/pac4j/authorization/generator/KeycloakRolesAuthorizationGenerator.java +++ b/src/main/java/bio/ferlab/pac4j/authorization/generator/KeycloakRolesAuthorizationGenerator.java @@ -1,7 +1,7 @@ package bio.ferlab.pac4j.authorization.generator; -import com.nimbusds.jose.shaded.json.JSONArray; -import com.nimbusds.jose.shaded.json.JSONObject; +import com.nimbusds.jose.shaded.gson.JsonArray; +import com.nimbusds.jose.shaded.gson.JsonObject; import com.nimbusds.jwt.JWT; import com.nimbusds.jwt.SignedJWT; import org.pac4j.core.authorization.generator.AuthorizationGenerator; @@ -41,20 +41,20 @@ public Optional generate(final WebContext context, final SessionSto final var realmRolesJsonObject = jwtClaimsSet.getJSONObjectClaim("realm_access"); if (realmRolesJsonObject != null) { - final var realmRolesJsonArray = (JSONArray) realmRolesJsonObject.get("roles"); + final var realmRolesJsonArray = (JsonArray) realmRolesJsonObject.get("roles"); if (realmRolesJsonArray != null) { - realmRolesJsonArray.forEach(role -> profile.addRole((String) role)); + realmRolesJsonArray.forEach(role -> profile.addRole(role.getAsString())); } } if (clientId != null) { final var resourceAccess = jwtClaimsSet.getJSONObjectClaim("resource_access"); if (resourceAccess != null) { - final var clientRolesJsonObject = (JSONObject) resourceAccess.get(clientId); + final var clientRolesJsonObject = (JsonObject) resourceAccess.get(clientId); if (clientRolesJsonObject != null) { - final var clientRolesJsonArray = (JSONArray) clientRolesJsonObject.get("roles"); + final var clientRolesJsonArray = (JsonArray) clientRolesJsonObject.get("roles"); if (clientRolesJsonArray != null) { - clientRolesJsonArray.forEach(role -> profile.addRole((String) role)); + clientRolesJsonArray.forEach(role -> profile.addRole(role.getAsString())); } } } diff --git a/src/test/java/bio/ferlab/ForceDefaultURLCallbackLogicTests.java b/src/test/java/bio/ferlab/ForceDefaultURLCallbackLogicTests.java index 5e06df4..425d3d2 100644 --- a/src/test/java/bio/ferlab/ForceDefaultURLCallbackLogicTests.java +++ b/src/test/java/bio/ferlab/ForceDefaultURLCallbackLogicTests.java @@ -1,22 +1,23 @@ package bio.ferlab; import bio.ferlab.pac4j.ForceDefaultURLCallbackLogic; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import org.pac4j.core.context.JEEContext; -import org.pac4j.core.context.session.JEESessionStore; import org.pac4j.core.context.session.SessionStore; import org.pac4j.core.exception.http.FoundAction; import org.pac4j.core.exception.http.HttpAction; import org.pac4j.core.util.Pac4jConstants; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; +import org.pac4j.jee.context.JEEContext; +import org.pac4j.jee.context.session.JEESessionStore; import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.mock; public final class ForceDefaultURLCallbackLogicTests { @@ -37,9 +38,7 @@ private static Stream provideURLs() { @BeforeEach void setup() { logic = new ForceDefaultURLCallbackLogic(); - MockHttpServletRequest request = new MockHttpServletRequest(); - MockHttpServletResponse response = new MockHttpServletResponse(); - context = new JEEContext(request, response); + context = new JEEContext(mock(HttpServletRequest.class), mock(HttpServletResponse.class)); sessionStore = JEESessionStore.INSTANCE; } diff --git a/src/test/java/bio/ferlab/UsernameAuthorizerTest.java b/src/test/java/bio/ferlab/UsernameAuthorizerTest.java index fd35aa2..904a8a4 100644 --- a/src/test/java/bio/ferlab/UsernameAuthorizerTest.java +++ b/src/test/java/bio/ferlab/UsernameAuthorizerTest.java @@ -6,14 +6,14 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import org.pac4j.core.context.JEEContext; -import org.pac4j.core.context.session.JEESessionStore; +import org.pac4j.jee.context.JEEContext; +import org.pac4j.jee.context.session.JEESessionStore; import org.pac4j.core.context.session.SessionStore; import org.pac4j.core.profile.CommonProfile; import org.pac4j.core.util.Pac4jConstants; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.util.Collections; import java.util.stream.Stream;