use of org.apereo.cas.token.cipher.JwtTicketCipherExecutor in project cas by apereo.
the class TokenWebApplicationServiceResponseBuilderTests method verifyDecrypt.
@Test
public void verifyDecrypt() {
val signingSecret = "EihBwA3OuDQMm4gdWzkqRJ87596G7o7a_naJAJipxFoRJbXK7APRcnCA91Y30rJdh4q-C2dmpfV6eNhQT0bR5A";
val encryptionSecret = "dJ2YpUd-r_Qd7e3nDm79WiIHkqaLT8yZt6nN5eG0YnE";
val cipher = new JwtTicketCipherExecutor(encryptionSecret, signingSecret, true, 0, 0);
val result = cipher.decode(cipher.encode("ThisIsValue"));
assertEquals("ThisIsValue", result);
}
use of org.apereo.cas.token.cipher.JwtTicketCipherExecutor in project cas by apereo.
the class OidcRegisteredServiceJwtAccessTokenCipherExecutor method createCipherExecutorInstance.
@Override
protected JwtTicketCipherExecutor createCipherExecutorInstance(final String encryptionKey, final String signingKey, final RegisteredService registeredService, final CipherOperationsStrategyType type) {
val cipher = new InternalJwtAccessTokenCipherExecutor(encryptionKey, signingKey);
Unchecked.consumer(c -> {
if (EncodingUtils.isJsonWebKey(encryptionKey)) {
val jsonWebKey = toJsonWebKey(encryptionKey);
cipher.setEncryptionKey(jsonWebKey.getPublicKey());
cipher.setEncryptionWebKey(jsonWebKey);
}
if (EncodingUtils.isJsonWebKey(signingKey)) {
val jsonWebKey = toJsonWebKey(signingKey);
cipher.setSigningKey(jsonWebKey.getPrivateKey());
cipher.setSigningWebKey(jsonWebKey);
}
}).accept(cipher);
if (EncodingUtils.isJsonWebKey(encryptionKey) || EncodingUtils.isJsonWebKey(signingKey)) {
cipher.setEncryptionAlgorithm(KeyManagementAlgorithmIdentifiers.RSA_OAEP_256);
}
cipher.setCustomHeaders(CollectionUtils.wrap(CUSTOM_HEADER_REGISTERED_SERVICE_ID, registeredService.getId()));
cipher.setStrategyType(type);
return cipher;
}
Aggregations