use of com.amazonaws.services.kms.model.InvalidCiphertextException in project herd by FINRAOS.
the class MockKmsOperationsImpl method decrypt.
@Override
public DecryptResult decrypt(AWSKMSClient awsKmsClient, DecryptRequest decryptRequest) {
// Check the cipher text.
if (decryptRequest.getCiphertextBlob().equals(ByteBuffer.wrap(Base64.decodeBase64(MOCK_CIPHER_TEXT_INVALID)))) {
throw new InvalidCiphertextException("(Service: AWSKMS; Status Code: 400; Error Code: InvalidCiphertextException; Request ID: NONE)");
}
DecryptResult decryptResult = new DecryptResult();
// Convert the test plain text to byte buffer and set the plain text return value.
decryptResult.setPlaintext(ByteBuffer.wrap(MOCK_PLAIN_TEXT.getBytes()));
return decryptResult;
}
use of com.amazonaws.services.kms.model.InvalidCiphertextException in project herd by FINRAOS.
the class KmsDaoTest method testDecryptInvalidCipher.
@Test
public void testDecryptInvalidCipher() {
try {
// Try to decrypt an invalid ciphertext.
kmsDao.decrypt(new AwsParamsDto(), MockKmsOperationsImpl.MOCK_CIPHER_TEXT_INVALID);
fail("Suppose to throw an InvalidCiphertextException when cipher text is invalid.");
} catch (Exception e) {
assertEquals(InvalidCiphertextException.class, e.getClass());
}
}
Aggregations