Search in sources :

Example 36 with JWTVerifier

use of com.auth0.jwt.JWTVerifier in project balcaovirtual by trf2-jus-br.

the class ProcessoValidarGet method verify.

public static Map<String, Object> verify(String jwt) throws InvalidKeyException, NoSuchAlgorithmException, IllegalStateException, SignatureException, IOException, JWTVerifyException {
    final JWTVerifier verifier = new JWTVerifier(Utils.getApiPassword());
    Map<String, Object> map;
    map = verifier.verify(jwt);
    return map;
}
Also used : JWTVerifier(com.auth0.jwt.JWTVerifier)

Example 37 with JWTVerifier

use of com.auth0.jwt.JWTVerifier in project balcaovirtual by trf2-jus-br.

the class CertidaoObterTokenGet method verify.

public static Map<String, Object> verify(String jwt) throws InvalidKeyException, NoSuchAlgorithmException, IllegalStateException, SignatureException, IOException, JWTVerifyException {
    final JWTVerifier verifier = new JWTVerifier(Utils.getApiPassword());
    Map<String, Object> map;
    map = verifier.verify(jwt);
    return map;
}
Also used : JWTVerifier(com.auth0.jwt.JWTVerifier)

Example 38 with JWTVerifier

use of com.auth0.jwt.JWTVerifier in project balcaovirtual by trf2-jus-br.

the class AutenticarPost method verify.

public static Map<String, Object> verify(String jwt) throws SwaggerAuthorizationException {
    final JWTVerifier verifier = new JWTVerifier(Utils.getJwtPassword());
    Map<String, Object> map;
    try {
        map = verifier.verify(jwt);
    } catch (InvalidKeyException | NoSuchAlgorithmException | IllegalStateException | SignatureException | IOException | JWTVerifyException e) {
        throw new SwaggerAuthorizationException(e);
    }
    return map;
}
Also used : JWTVerifyException(com.auth0.jwt.JWTVerifyException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SignatureException(java.security.SignatureException) IOException(java.io.IOException) InvalidKeyException(java.security.InvalidKeyException) JWTVerifier(com.auth0.jwt.JWTVerifier) SwaggerAuthorizationException(com.crivano.swaggerservlet.SwaggerAuthorizationException)

Example 39 with JWTVerifier

use of com.auth0.jwt.JWTVerifier in project iet-hf-2022-k-k-k-k-k-k by BME-MIT-IET.

the class JwtUtil method getDecodedJWT.

public static DecodedJWT getDecodedJWT(String authorizationHeader) {
    String token = authorizationHeader.substring("Bearer ".length());
    Algorithm algorithm = Algorithm.HMAC256(SecurityConfig.getSecretKey().getBytes());
    JWTVerifier verifier = JWT.require(algorithm).build();
    return verifier.verify(token);
}
Also used : Algorithm(com.auth0.jwt.algorithms.Algorithm) JWTVerifier(com.auth0.jwt.JWTVerifier)

Example 40 with JWTVerifier

use of com.auth0.jwt.JWTVerifier in project brapi-Java-TestServer by plantbreeding.

the class BrapiTestServerJWTAuthFilter method validateOAuthToken.

private String validateOAuthToken(HttpServletRequest request) {
    try {
        String token = request.getHeader("Authorization");
        if (token != null) {
            token = token.replaceFirst("Bearer ", "");
            RSAPublicKey pubKey = getPublicKey(oidcDiscoveryUrl);
            Algorithm algorithm = Algorithm.RSA256(pubKey, null);
            JWTVerifier verifier = JWT.require(algorithm).withIssuer("https://auth.brapi.org/auth/realms/brapi").build();
            DecodedJWT jwt = verifier.verify(token);
            return jwt.getClaim("email").asString();
        }
        return null;
    } catch (Exception e) {
        return null;
    }
}
Also used : RSAPublicKey(java.security.interfaces.RSAPublicKey) Algorithm(com.auth0.jwt.algorithms.Algorithm) JWTVerifier(com.auth0.jwt.interfaces.JWTVerifier) DecodedJWT(com.auth0.jwt.interfaces.DecodedJWT) ServletException(javax.servlet.ServletException) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

JWTVerifier (com.auth0.jwt.JWTVerifier)115 Algorithm (com.auth0.jwt.algorithms.Algorithm)104 DecodedJWT (com.auth0.jwt.interfaces.DecodedJWT)100 Test (org.junit.Test)42 JWTVerificationException (com.auth0.jwt.exceptions.JWTVerificationException)30 IOException (java.io.IOException)23 JWTVerifier (com.auth0.jwt.interfaces.JWTVerifier)18 RSAPublicKey (java.security.interfaces.RSAPublicKey)15 JWTDecodeException (com.auth0.jwt.exceptions.JWTDecodeException)14 Claim (com.auth0.jwt.interfaces.Claim)10 Date (java.util.Date)9 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)8 HashMap (java.util.HashMap)8 ECKey (java.security.interfaces.ECKey)7 ServletException (javax.servlet.ServletException)7 UnsupportedEncodingException (java.io.UnsupportedEncodingException)6 TokenExpiredException (com.auth0.jwt.exceptions.TokenExpiredException)5 RSAKeyProvider (com.auth0.jwt.interfaces.RSAKeyProvider)5 URL (java.net.URL)5 KeyFactory (java.security.KeyFactory)5