use of com.nimbusds.jose.crypto.DirectDecrypter in project perry by ca-cwds.
the class JwtService method decrypt.
private SignedJWT decrypt(String token) throws JwtException {
try {
SignedJWT signedJWT;
JWEObject jweObject = JWEObject.parse(token);
jweObject.decrypt(new DirectDecrypter(keyProvider.getEncryptingKey().getEncoded()));
signedJWT = jweObject.getPayload().toSignedJWT();
return signedJWT;
} catch (Exception e) {
throw new JwtException(e);
}
}
use of com.nimbusds.jose.crypto.DirectDecrypter 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