diff --git a/src/main/java/com/corbado/services/SessionService.java b/src/main/java/com/corbado/services/SessionService.java index 301479d..f22e355 100644 --- a/src/main/java/com/corbado/services/SessionService.java +++ b/src/main/java/com/corbado/services/SessionService.java @@ -1,5 +1,10 @@ package com.corbado.services; +import java.security.interfaces.RSAPublicKey; +import java.util.concurrent.TimeUnit; + +import org.apache.commons.lang3.StringUtils; + import com.auth0.jwk.Jwk; import com.auth0.jwk.JwkException; import com.auth0.jwk.JwkProvider; @@ -12,9 +17,7 @@ import com.auth0.jwt.interfaces.DecodedJWT; import com.corbado.entities.SessionValidationResult; import com.corbado.utils.ValidationUtils; -import java.security.interfaces.RSAPublicKey; -import java.util.concurrent.TimeUnit; -import org.apache.commons.lang3.StringUtils; + import lombok.Getter; import lombok.NonNull; import lombok.Setter; @@ -31,25 +34,19 @@ public class SessionService { private static final int JWK_CACHE_SIZE = 100; /** The short session cookie name. */ - private final String shortSessionCookieName; + private String shortSessionCookieName; /** The issuer. */ - private final String issuer; + private String issuer; /** The jwks uri. */ - private final String jwksUri; + private String jwksUri; /** The last short session validation result. */ private String lastShortSessionValidationResult; - /** The short session length. */ - private int shortSessionLength = 300; // Default short session length in seconds - - /** The cache keys. */ - private boolean cacheKeys = false; - /** The jwk provider. */ - private final JwkProvider jwkProvider; + private JwkProvider jwkProvider; /** * Instantiates a new session service. @@ -72,8 +69,6 @@ public SessionService( this.shortSessionCookieName = shortSessionCookieName; this.issuer = issuer; this.jwksUri = jwksUri; - this.shortSessionLength = shortSessionLength; - this.cacheKeys = cacheKeys; final JwkProviderBuilder jwkProviderBuilder = new JwkProviderBuilder(this.jwksUri); if (cacheKeys) { @@ -107,7 +102,7 @@ private SessionValidationResult getAndValidateUserFromShortSessionValue( try { // Get the signing key DecodedJWT decodedJwt = JWT.decode(shortSession); - final Jwk jwk = jwkProvider.get(decodedJwt.getKeyId()); + final Jwk jwk = this.jwkProvider.get(decodedJwt.getKeyId()); if (jwk == null) { throw new SigningKeyNotFoundException(shortSession, null); } diff --git a/src/main/java/com/corbado/services/UserService.java b/src/main/java/com/corbado/services/UserService.java index 8683afd..ae6ea30 100644 --- a/src/main/java/com/corbado/services/UserService.java +++ b/src/main/java/com/corbado/services/UserService.java @@ -95,7 +95,7 @@ public UserEntity createActiveByName(@NonNull final String fullName) * @param userId the user id * @throws CorbadoServerException exception thrown on error or if user is not found */ - public void delete(final String userId) throws CorbadoServerException { + public void delete(@NonNull final String userId) throws CorbadoServerException { try { this.client.userDelete(userId); @@ -111,7 +111,7 @@ public void delete(final String userId) throws CorbadoServerException { * @return UserGetRsp Response * @throws CorbadoServerException If any server-side error occurs. */ - public UserEntity get(final String userId) throws CorbadoServerException { + public UserEntity get(@NonNull final String userId) throws CorbadoServerException { try { return new UserEntity(this.client.userGet(userId)); } catch (final ApiException e) { diff --git a/src/test/java/com/corbado/integration/UserServiceIT.java b/src/test/java/com/corbado/integration/UserServiceIT.java index 379e44b..ef31eaf 100644 --- a/src/test/java/com/corbado/integration/UserServiceIT.java +++ b/src/test/java/com/corbado/integration/UserServiceIT.java @@ -74,7 +74,6 @@ void test_UserDelete_ExpectSuccess() throws CorbadoServerException, StandardExce CorbadoServerException.class, () -> { final UserEntity ret = this.fixture.get(user.getUserID()); - System.out.println(ret.toString()); }); assertNotNull(e); assertEquals(400, e.getHttpStatusCode()); @@ -93,7 +92,6 @@ void test_UserGet_ExpectNotFound() { CorbadoServerException.class, () -> { final UserEntity ret = this.fixture.get("usr-1234567890"); - System.out.println(ret.toString()); }); assertNotNull(e); assertEquals(400, e.getHttpStatusCode());