use of org.apereo.cas.util.crypto.DecryptionException in project cas by apereo.
the class SamlIdPObjectEncrypter method decode.
/**
* Decode name id.
*
* @param encryptedId the encrypted id
* @param service the service
* @param adaptor the adaptor
* @return the name id
*/
public NameID decode(final EncryptedID encryptedId, final SamlRegisteredService service, final SamlRegisteredServiceServiceProviderMetadataFacade adaptor) {
try {
Security.addProvider(new BouncyCastleProvider());
val config = configureDecryptionSecurityConfiguration(service);
configureKeyDecryptionCredential(adaptor.getEntityId(), adaptor, service, config);
val parameters = resolveDecryptionParameters(service, config);
val decrypter = getDecrypter(encryptedId, service, adaptor, parameters);
return (NameID) decrypter.decrypt(encryptedId);
} catch (final Exception e) {
throw new DecryptionException(e);
}
}
use of org.apereo.cas.util.crypto.DecryptionException in project cas by apereo.
the class BaseBinaryCipherExecutor method decode.
@Override
public byte[] decode(final byte[] value, final Object[] parameters) {
try {
val verifiedValue = verifySignature(value, getSigningKey());
val aesCipher = Cipher.getInstance(CIPHER_ALGORITHM);
aesCipher.init(Cipher.DECRYPT_MODE, this.encryptionKey, this.parameterSpec);
return aesCipher.doFinal(verifiedValue);
} catch (final Exception e) {
throw LOGGER.isTraceEnabled() ? new DecryptionException(e) : new DecryptionException();
}
}
use of org.apereo.cas.util.crypto.DecryptionException in project cas by apereo.
the class EncodingUtils method decryptJwtValue.
/**
* Decrypt value based on the key created.
*
* @param secretKeyEncryptionKey the secret key encryption key
* @param value the value
* @return the decrypted value
*/
public static String decryptJwtValue(final Key secretKeyEncryptionKey, final String value) {
try {
val jwe = new JsonWebEncryption();
jwe.setKey(secretKeyEncryptionKey);
jwe.setCompactSerialization(value);
LOGGER.trace("Decrypting value...");
return jwe.getPayload();
} catch (final Exception e) {
if (LOGGER.isTraceEnabled()) {
throw new DecryptionException(e);
}
throw new DecryptionException();
}
}
Aggregations