Search in sources :

Example 6 with KeyType

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;
}
Also used : KeyType(org.apache.cxf.rs.security.jose.jwk.KeyType) ContentAlgorithm(org.apache.cxf.rs.security.jose.jwa.ContentAlgorithm)

Example 7 with KeyType

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;
}
Also used : KeyType(org.apache.cxf.rs.security.jose.jwk.KeyType) SignatureAlgorithm(org.apache.cxf.rs.security.jose.jwa.SignatureAlgorithm)

Aggregations

KeyType (org.apache.cxf.rs.security.jose.jwk.KeyType)7 ContentAlgorithm (org.apache.cxf.rs.security.jose.jwa.ContentAlgorithm)2 KeyAlgorithm (org.apache.cxf.rs.security.jose.jwa.KeyAlgorithm)2 SignatureAlgorithm (org.apache.cxf.rs.security.jose.jwa.SignatureAlgorithm)2 List (java.util.List)1 Message (org.apache.cxf.message.Message)1 JsonWebKey (org.apache.cxf.rs.security.jose.jwk.JsonWebKey)1 JsonWebKeys (org.apache.cxf.rs.security.jose.jwk.JsonWebKeys)1 Test (org.junit.Test)1