Search in sources :

Example 1 with InvalidCiphertextException

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;
}
Also used : DecryptResult(com.amazonaws.services.kms.model.DecryptResult) InvalidCiphertextException(com.amazonaws.services.kms.model.InvalidCiphertextException)

Example 2 with InvalidCiphertextException

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());
    }
}
Also used : AwsParamsDto(org.finra.herd.model.dto.AwsParamsDto) InvalidCiphertextException(com.amazonaws.services.kms.model.InvalidCiphertextException) InvalidCiphertextException(com.amazonaws.services.kms.model.InvalidCiphertextException) Test(org.junit.Test)

Aggregations

InvalidCiphertextException (com.amazonaws.services.kms.model.InvalidCiphertextException)2 DecryptResult (com.amazonaws.services.kms.model.DecryptResult)1 AwsParamsDto (org.finra.herd.model.dto.AwsParamsDto)1 Test (org.junit.Test)1