diff --git a/pom.xml b/pom.xml
index 15d6441..cc87edd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
lutece-global-pom
fr.paris.lutece.tools
- 5.2.0
+ 5.2.1
4.0.0
@@ -40,12 +40,12 @@
io.jsonwebtoken
jjwt
- 0.5
+ 0.9.1
com.fasterxml.jackson.core
jackson-databind
- 2.11.0
+ 2.13.1
diff --git a/src/java/fr/paris/lutece/plugins/oauth2/jwt/JjwtJWTParser.java b/src/java/fr/paris/lutece/plugins/oauth2/jwt/JjwtJWTParser.java
index 98a4b7f..d6690c7 100644
--- a/src/java/fr/paris/lutece/plugins/oauth2/jwt/JjwtJWTParser.java
+++ b/src/java/fr/paris/lutece/plugins/oauth2/jwt/JjwtJWTParser.java
@@ -33,7 +33,7 @@
*/
package fr.paris.lutece.plugins.oauth2.jwt;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
import org.apache.log4j.Logger;
@@ -67,7 +67,7 @@ public void parseJWT( Token token, AuthClientConf clientConfig, AuthServerConf s
try
{
JwtParser parser = Jwts.parser( );
- parser.setSigningKey( clientConfig.getClientSecret( ).getBytes( "UTF-8" ) );
+ parser.setSigningKey( clientConfig.getClientSecret( ).getBytes( StandardCharsets.UTF_8 ) );
Jwt jwt = parser.parse( strCompactJwt );
Claims claims = (Claims) jwt.getBody( );
@@ -90,27 +90,10 @@ public void parseJWT( Token token, AuthClientConf clientConfig, AuthServerConf s
token.setIdToken( idToken );
}
- catch( SignatureException ex )
+ catch( SignatureException | ExpiredJwtException | IllegalArgumentException | MalformedJwtException ex )
{
throw new TokenValidationException( ex.getMessage( ), ex );
}
- catch( ExpiredJwtException ex )
- {
- throw new TokenValidationException( ex.getMessage( ), ex );
- }
- catch( UnsupportedEncodingException ex )
- {
- throw new TokenValidationException( ex.getMessage( ), ex );
- }
- catch( IllegalArgumentException ex )
- {
- throw new TokenValidationException( ex.getMessage( ), ex );
- }
- catch( MalformedJwtException ex )
- {
- throw new TokenValidationException( ex.getMessage( ), ex );
- }
-
}
/**
diff --git a/src/java/fr/paris/lutece/plugins/oauth2/web/CallbackHandler.java b/src/java/fr/paris/lutece/plugins/oauth2/web/CallbackHandler.java
index 4b603ee..45365e2 100644
--- a/src/java/fr/paris/lutece/plugins/oauth2/web/CallbackHandler.java
+++ b/src/java/fr/paris/lutece/plugins/oauth2/web/CallbackHandler.java
@@ -246,19 +246,7 @@ private void handleAuthorizationCodeResponse( HttpServletRequest request, HttpSe
Token token = getToken( strRedirectUri, strCode, session );
dataClient.handleToken( token, request, response );
}
- catch( IOException ex )
- {
- String strError = "Error retrieving token : " + ex.getMessage( );
- _logger.error( strError, ex );
- handleError( request, response, strError );
- }
- catch( HttpAccessException ex )
- {
- String strError = "Error retrieving token : " + ex.getMessage( );
- _logger.error( strError, ex );
- handleError( request, response, strError );
- }
- catch( TokenValidationException ex )
+ catch( IOException | HttpAccessException | TokenValidationException ex )
{
String strError = "Error retrieving token : " + ex.getMessage( );
_logger.error( strError, ex );
diff --git a/src/java/fr/paris/lutece/plugins/oauth2/web/OAuthCallbackServlet.java b/src/java/fr/paris/lutece/plugins/oauth2/web/OAuthCallbackServlet.java
index 2be652a..aabf12e 100644
--- a/src/java/fr/paris/lutece/plugins/oauth2/web/OAuthCallbackServlet.java
+++ b/src/java/fr/paris/lutece/plugins/oauth2/web/OAuthCallbackServlet.java
@@ -34,7 +34,6 @@
package fr.paris.lutece.plugins.oauth2.web;
import java.io.IOException;
-import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -44,7 +43,6 @@
import org.apache.commons.lang3.StringUtils;
import fr.paris.lutece.plugins.oauth2.service.CallbackHandlerService;
-import fr.paris.lutece.portal.service.spring.SpringContextService;
/**
* AuthLoginServlet
diff --git a/src/test/java/fr/paris/lutece/plugins/oauth2/service/TokenServiceTest.java b/src/test/java/fr/paris/lutece/plugins/oauth2/service/TokenServiceTest.java
index a5fbd4e..dbf6fd8 100644
--- a/src/test/java/fr/paris/lutece/plugins/oauth2/service/TokenServiceTest.java
+++ b/src/test/java/fr/paris/lutece/plugins/oauth2/service/TokenServiceTest.java
@@ -34,8 +34,7 @@
package fr.paris.lutece.plugins.oauth2.service;
import fr.paris.lutece.plugins.oauth2.business.Token;
-import fr.paris.lutece.plugins.oauth2.service.TokenService;
-import static org.junit.Assert.*;
+import fr.paris.lutece.test.LuteceTestCase;
import org.junit.Test;
@@ -44,9 +43,9 @@
/**
* TokenService Test
*/
-public class TokenServiceTest
+public class TokenServiceTest extends LuteceTestCase
{
- private static final String JSON_TOKEN = "{\"access_token\":\"608c2c4c250f9dcd118dc087cb23b2c4db2a848161044b03\",\"token_type\":\"Bearer\",\"expires_in\":3600,\"id_token\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vZmNwLmludGVnMDEuZGV2LWZyYW5jZWNvbm5lY3QuZnIiLCJzdWIiOiIwMTI2MzIzNDM2MjFjMjYwMGY0M2I1YWIxOTM2NzQzZGZjOGExOTljZWNhODUxYTciLCJhdWQiOiJhOWEyNTg5NWY5ZDc2ZjZjODlhYTIxODMwNTc1YmYzNGIzZjRmNjg0YTcyYTg0YzEzYWIxYzM4MTA2NDNkODU5IiwiZXhwIjoxNDMyOTM1MTM5LCJpYXQiOjE0MzI5MzE1MzksIm5vbmNlIjoiMTNjMWMyMDk5ODlmMSIsImlkcCI6ImRnZmlwIiwiYWNyIjoiZWlkYXMyIn0.RrzwbO0ygvMbFJYYvzsx530IiJpj3iQ44GQPcpTHIKM\"}";
+ private static final String JSON_TOKEN = "{ \"access_token\" : \"608c2c4c250f9dcd118dc087cb23b2c4db2a848161044b03\", \"token_type\" : \"Bearer\", \"expires_in\" : 3600, \"id_token\" : \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vZmNwLmludGVnMDEuZGV2LWZyYW5jZWNvbm5lY3QuZnIiLCJzdWIiOiIwMTI2MzIzNDM2MjFjMjYwMGY0M2I1YWIxOTM2NzQzZGZjOGExOTljZWNhODUxYTciLCJhdWQiOiJhOWEyNTg5NWY5ZDc2ZjZjODlhYTIxODMwNTc1YmYzNGIzZjRmNjg0YTcyYTg0YzEzYWIxYzM4MTA2NDNkODU5IiwiZXhwIjoxNDMyOTM1MTM5LCJpYXQiOjE0MzI5MzE1MzksIm5vbmNlIjoiMTNjMWMyMDk5ODlmMSIsImlkcCI6ImRnZmlwIiwiYWNyIjoiZWlkYXMyIn0.RrzwbO0ygvMbFJYYvzsx530IiJpj3iQ44GQPcpTHIKM\" }";
/**
* Test of parse method, of class TokenService.
@@ -56,10 +55,9 @@ public class TokenServiceTest
@Test
public void testParseToken( ) throws IOException
{
- System.out.println( "parse" );
+ System.out.println( "parseTokenJson" );
- String strJson = JSON_TOKEN;
- Token token = TokenService.getService( ).parseToken( strJson );
+ Token token = TokenService.getService( ).parseToken( JSON_TOKEN );
assertEquals( token.getAccessToken( ), "608c2c4c250f9dcd118dc087cb23b2c4db2a848161044b03" );
assertEquals( token.getExpiresIn( ), 3600 );
diff --git a/src/test/java/fr/paris/lutece/plugins/oauth2/service/jwt/JjwtJWTParserTest.java b/src/test/java/fr/paris/lutece/plugins/oauth2/service/jwt/JjwtJWTParserTest.java
index d74aef9..a60737c 100644
--- a/src/test/java/fr/paris/lutece/plugins/oauth2/service/jwt/JjwtJWTParserTest.java
+++ b/src/test/java/fr/paris/lutece/plugins/oauth2/service/jwt/JjwtJWTParserTest.java
@@ -102,7 +102,7 @@ private String buildJWT( )
// builder.setIssuedAt( dateIssueAt );
// builder.setExpiration( dateExpiration );
- Map mapClaims = new HashMap( );
+ Map mapClaims = new HashMap<>( );
mapClaims.put( Constants.CLAIM_NONCE, NONCE );
mapClaims.put( Constants.CLAIM_IDP, IDP );
mapClaims.put( Constants.CLAIM_ACR, ACR );
diff --git a/webapp/WEB-INF/conf/plugins/oauth2_context.xml b/webapp/WEB-INF/conf/plugins/oauth2_context.xml
index c9a1db8..987a3cf 100644
--- a/webapp/WEB-INF/conf/plugins/oauth2_context.xml
+++ b/webapp/WEB-INF/conf/plugins/oauth2_context.xml
@@ -16,7 +16,7 @@
-
+