Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
Issue #17
  • Loading branch information
rsoika committed Apr 23, 2023
1 parent 638168e commit d57043c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 48 deletions.
46 changes: 27 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
</license>
</licenses>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jakarta.version>10.0.0</jakarta.version>
</properties>

<repositories>
<repository>
<id>snapshots-repo</id>
Expand All @@ -78,8 +83,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>

Expand Down Expand Up @@ -218,15 +223,15 @@
</profiles>

<dependencies>
<!-- JEE dependencies -->

<!-- Jakarta EE -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakarta.version}</version>
<scope>provided</scope>
</dependency>


<!-- JUnit Tests -->
<dependency>
<groupId>junit</groupId>
Expand All @@ -235,21 +240,24 @@
<scope>test</scope>
</dependency>


<!-- JSON Parser -->
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.1</version>
<scope>provided</scope>
<groupId>org.eclipse.parsson</groupId>
<artifactId>jakarta.json</artifactId>
<version>1.1.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1</version>
<scope>test</scope>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<!-- Distributen Management oss.sonatype.org -->
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/imixs/jwt/JWTBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
import java.util.Map;
import java.util.Map.Entry;
import javax.crypto.SecretKey;
import javax.json.Json;
import javax.json.JsonNumber;
import javax.json.JsonObject;
import javax.json.JsonReader;
import jakarta.json.Json;
import jakarta.json.JsonNumber;
import jakarta.json.JsonObject;
import jakarta.json.JsonReader;

/**
* The JWTBuilder can be used to construct a JSON Web Token. The Builder expects a valid SecrectKey
Expand Down
44 changes: 22 additions & 22 deletions src/main/java/org/imixs/jwt/jaspic/JWTAuthModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,27 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.crypto.SecretKey;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonException;
import javax.json.JsonNumber;
import javax.json.JsonObject;
import javax.json.JsonReader;
import jakarta.json.Json;
import jakarta.json.JsonArray;
import jakarta.json.JsonException;
import jakarta.json.JsonNumber;
import jakarta.json.JsonObject;
import jakarta.json.JsonReader;
import javax.security.auth.Subject;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.message.AuthException;
import javax.security.auth.message.AuthStatus;
import javax.security.auth.message.MessageInfo;
import javax.security.auth.message.MessagePolicy;
import javax.security.auth.message.callback.CallerPrincipalCallback;
import javax.security.auth.message.callback.GroupPrincipalCallback;
import javax.security.auth.message.config.ServerAuthContext;
import javax.security.auth.message.module.ServerAuthModule;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import jakarta.security.auth.message.AuthException;
import jakarta.security.auth.message.AuthStatus;
import jakarta.security.auth.message.MessageInfo;
import jakarta.security.auth.message.MessagePolicy;
import jakarta.security.auth.message.callback.CallerPrincipalCallback;
import jakarta.security.auth.message.callback.GroupPrincipalCallback;
import jakarta.security.auth.message.config.ServerAuthContext;
import jakarta.security.auth.message.module.ServerAuthModule;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.imixs.jwt.HMAC;
import org.imixs.jwt.JWSAlgorithm;
import org.imixs.jwt.JWTException;
Expand All @@ -82,7 +82,7 @@ public class JWTAuthModule implements ServerAuthModule, ServerAuthContext {

@SuppressWarnings("rawtypes")
protected static final Class[] supportedMessageTypes = new Class[] {
javax.servlet.http.HttpServletRequest.class, javax.servlet.http.HttpServletResponse.class};
jakarta.servlet.http.HttpServletRequest.class, jakarta.servlet.http.HttpServletResponse.class};

@SuppressWarnings("rawtypes")
protected Map options;
Expand All @@ -91,8 +91,8 @@ public class JWTAuthModule implements ServerAuthModule, ServerAuthContext {
protected MessagePolicy responsePolicy;

private static final String IS_MANDATORY_INFO_KEY =
"javax.security.auth.message.MessagePolicy.isMandatory";
private static final String AUTH_TYPE_INFO_KEY = "javax.servlet.http.authType";
"jakarta.security.auth.message.MessagePolicy.isMandatory";
private static final String AUTH_TYPE_INFO_KEY = "jakarta.servlet.http.authType";
private static final String QUERY_PARAM_SESSION = "jwt";
private static final String MODULE_OPTION_SECRET = "secret";
private static final String MODULE_OPTION_EXPIRE = "expire";
Expand Down Expand Up @@ -495,7 +495,7 @@ String consumeJWTPayload(HttpServletRequest request, HttpServletResponse respons
// store groups into session
request.getSession().setAttribute(JWT_GROUPS, stringGroups);

} catch (javax.json.stream.JsonParsingException j1) {
} catch (jakarta.json.stream.JsonParsingException j1) {
logger.severe("invalid payload=" + _payload);
logger
.severe("JSON object or array cannot be created due to i/o error: " + j1.getMessage());
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/imixs/jwt/JWTBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import java.util.Date;
import java.util.logging.Logger;
import javax.crypto.SecretKey;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonReader;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.json.JsonReader;
import org.junit.Before;
import org.junit.Test;
import junit.framework.Assert;
Expand Down

0 comments on commit d57043c

Please sign in to comment.