Search in sources :

Example 1 with NextprotSecurityException

use of org.nextprot.api.security.service.exception.NextprotSecurityException in project nextprot-api by calipho-sib.

the class JWTCodecImpl method decodeJWT.

@Override
public Map<String, Object> decodeJWT(String token) {
    JWTVerifier jwtVerifier = new JWTVerifier(clientSecret, clientId);
    Map<String, Object> verify;
    try {
        verify = jwtVerifier.verify(token);
        String payload = (String) verify.get("payload");
        Map<String, Object> map = new ObjectMapper().readValue(payload, Map.class);
        return map;
    } catch (InvalidKeyException e) {
        throw new NextprotSecurityException(e);
    } catch (NoSuchAlgorithmException e) {
        throw new NextprotSecurityException(e);
    } catch (IllegalStateException e) {
        throw new NextprotSecurityException(e);
    } catch (SignatureException e) {
        throw new NextprotSecurityException(e);
    } catch (IOException e) {
        throw new NextprotSecurityException(e);
    }
}
Also used : NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SignatureException(java.security.SignatureException) IOException(java.io.IOException) InvalidKeyException(java.security.InvalidKeyException) JWTVerifier(com.auth0.jwt.JWTVerifier) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) NextprotSecurityException(org.nextprot.api.security.service.exception.NextprotSecurityException)

Aggregations

JWTVerifier (com.auth0.jwt.JWTVerifier)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 InvalidKeyException (java.security.InvalidKeyException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 SignatureException (java.security.SignatureException)1 NextprotSecurityException (org.nextprot.api.security.service.exception.NextprotSecurityException)1