Search in sources :

Example 1 with JsonWebKey

use of org.jose4j.jwk.JsonWebKey in project cas by apereo.

the class BaseStringCipherExecutor method prepareJsonWebTokenKey.

/**
     * Prepare json web token key.
     *
     * @param secret the secret
     * @return the key
     */
private static Key prepareJsonWebTokenKey(final String secret) {
    try {
        final Map<String, Object> keys = new HashMap<>(2);
        keys.put("kty", "oct");
        keys.put(EncodingUtils.JSON_WEB_KEY, secret);
        final JsonWebKey jwk = JsonWebKey.Factory.newJwk(keys);
        return jwk.getKey();
    } catch (final Exception e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
Also used : HashMap(java.util.HashMap) JsonWebKey(org.jose4j.jwk.JsonWebKey)

Aggregations

HashMap (java.util.HashMap)1 JsonWebKey (org.jose4j.jwk.JsonWebKey)1