Example usage for com.amazonaws.services.kms.model DecryptResult DecryptResult

List of usage examples for com.amazonaws.services.kms.model DecryptResult DecryptResult

Introduction

In this page you can find the example usage for com.amazonaws.services.kms.model DecryptResult DecryptResult.

Prototype

DecryptResult

Source Link

Usage

From source file:de.zalando.spring.cloud.config.aws.kms.MockAwsKmsConfig.java

License:Apache License

@Bean
AWSKMS kms() {//from  ww w .j a v  a 2s . co m
    final AWSKMS mock = mock(AWSKMS.class);
    when(mock.decrypt(any(DecryptRequest.class))).thenAnswer(new Answer<DecryptResult>() {
        @Override
        public DecryptResult answer(InvocationOnMock invocation) throws Throwable {
            return new DecryptResult().withPlaintext(
                    ByteBuffer.wrap(KmsEncryptionIntegrationConfigurationTest.PLAINTEXT.getBytes()));
        }
    });
    return mock;
}

From source file:org.finra.dm.dao.impl.MockKmsOperationsImpl.java

License:Apache License

@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)");
    }//from   w  w  w .j av  a2 s  . c  o m

    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;
}