Skip to content

Commit

Permalink
Merge pull request #19 from Ferlab-Ste-Justine/zeppelin-0.11
Browse files Browse the repository at this point in the history
feat: BG-36 Update to zeppelin 0.11
  • Loading branch information
jecos authored Mar 18, 2024
2 parents 3da82db + 2678154 commit 01b9744
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target
.idea
.idea
*.iml
36 changes: 22 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.7.0</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -29,22 +30,22 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>3.2.5</version>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.0</version>
<version>5.10.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<version>3.1.1</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.0-M1</version>
<version>3.0.1</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
</configuration>
Expand All @@ -66,7 +67,7 @@
<dependency>
<groupId>org.apache.zeppelin</groupId>
<artifactId>zeppelin-server</artifactId>
<version>0.10.0</version>
<version>0.11.0</version>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
Expand All @@ -93,24 +94,31 @@
<dependency>
<groupId>io.buji</groupId>
<artifactId>buji-pac4j</artifactId>
<version>6.0.0</version>
<version>8.1.0</version>
</dependency>
<dependency>
<groupId>org.pac4j</groupId>
<artifactId>pac4j-oidc</artifactId>
<version>5.1.3</version>
<version>5.7.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.pac4j/jakartaee-pac4j -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.0</version>
<groupId>org.pac4j</groupId>
<artifactId>jakartaee-pac4j</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.0</version>
<scope>test</scope>
<version>5.3.10</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
Expand All @@ -133,7 +141,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-kms</artifactId>
<version>1.11.736</version>
<version>1.12.681</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -41,20 +41,20 @@ public Optional<UserProfile> 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()));
}
}
}
Expand Down
13 changes: 6 additions & 7 deletions src/test/java/bio/ferlab/ForceDefaultURLCallbackLogicTests.java
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -37,9 +38,7 @@ private static Stream<Arguments> 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;
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/bio/ferlab/UsernameAuthorizerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 01b9744

Please sign in to comment.