use of com.nimbusds.jose.crypto.MACVerifier in project ratauth by alfa-laboratory.
the class HS256TokenProcessor method extractInfo.
@Override
@SneakyThrows
public Map<String, Object> extractInfo(String jwt, String secret) {
SignedJWT signedJWT = SignedJWT.parse(jwt);
final JWSVerifier verifier = new MACVerifier(Base64.getDecoder().decode(secret));
if (!signedJWT.verify(verifier))
throw new JWTVerificationException("User info extraction error");
return signedJWT.getJWTClaimsSet().getClaims();
}
use of com.nimbusds.jose.crypto.MACVerifier in project gravitee-management-rest-api by gravitee-io.
the class ReferenceSerializer method deserialize.
public IdentityReference deserialize(String token) throws Exception {
String sToken = new String(Base64.getDecoder().decode(token));
// Parse the JWE string
JWEObject jweObject = JWEObject.parse(sToken);
// Decrypt with shared key
jweObject.decrypt(new DirectDecrypter(secretKey.getEncoded()));
// Extract payload
SignedJWT signedJWT = jweObject.getPayload().toSignedJWT();
// Check the HMAC
signedJWT.verify(new MACVerifier(secretKey.getEncoded()));
// Retrieve the JWT claims
return new IdentityReference(signedJWT.getJWTClaimsSet().getIssuer(), signedJWT.getJWTClaimsSet().getSubject());
}
Aggregations