use of org.keycloak.crypto.ClientSignatureVerifierProvider in project keycloak by keycloak.
the class DefaultTokenManager method verifyJWS.
private <T> T verifyJWS(ClientModel client, Class<T> clazz, JWSInput jws) {
try {
String signatureAlgorithm = jws.getHeader().getAlgorithm().name();
ClientSignatureVerifierProvider signatureProvider = session.getProvider(ClientSignatureVerifierProvider.class, signatureAlgorithm);
if (signatureProvider == null) {
if (jws.getHeader().getAlgorithm().equals(org.keycloak.jose.jws.Algorithm.none)) {
return jws.readJsonContent(clazz);
}
return null;
}
boolean valid = signatureProvider.verifier(client, jws).verify(jws.getEncodedSignatureInput().getBytes("UTF-8"), jws.getSignature());
return valid ? jws.readJsonContent(clazz) : null;
} catch (Exception e) {
logger.debug("Failed to decode token", e);
return null;
}
}
Aggregations