use of org.apache.cxf.rs.security.jose.jwk.KeyType in project cxf by apache.
the class JweUtils method getContentEncryptionProvider.
public static ContentEncryptionProvider getContentEncryptionProvider(JsonWebKey jwk, ContentAlgorithm defaultAlgorithm) {
ContentAlgorithm ctAlgo = jwk.getAlgorithm() == null ? defaultAlgorithm : getContentAlgo(jwk.getAlgorithm());
KeyType keyType = jwk.getKeyType();
if (KeyType.OCTET == keyType) {
return getContentEncryptionProvider(JwkUtils.toSecretKey(jwk), ctAlgo);
}
return null;
}
use of org.apache.cxf.rs.security.jose.jwk.KeyType in project cxf by apache.
the class JwsUtils method getSignatureVerifier.
public static JwsSignatureVerifier getSignatureVerifier(JsonWebKey jwk, SignatureAlgorithm defaultAlgorithm) {
SignatureAlgorithm sigAlgo = jwk.getAlgorithm() == null ? defaultAlgorithm : SignatureAlgorithm.getAlgorithm(jwk.getAlgorithm());
JwsSignatureVerifier theVerifier = null;
KeyType keyType = jwk.getKeyType();
if (KeyType.RSA == keyType) {
theVerifier = getPublicKeySignatureVerifier(JwkUtils.toRSAPublicKey(jwk, true), sigAlgo);
} else if (KeyType.OCTET == keyType) {
byte[] key = JoseUtils.decode((String) jwk.getProperty(JsonWebKey.OCTET_KEY_VALUE));
theVerifier = getHmacSignatureVerifier(key, sigAlgo);
} else if (KeyType.EC == keyType) {
theVerifier = getPublicKeySignatureVerifier(JwkUtils.toECPublicKey(jwk), sigAlgo);
}
return theVerifier;
}
Aggregations