Java Code Examples for com.amazonaws.encryptionsdk.CryptoResult#getResult()

The following examples show how to use com.amazonaws.encryptionsdk.CryptoResult#getResult() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KMSEncryptor.java    From strongbox with Apache License 2.0 6 votes vote down vote up
@Override
public byte[] decrypt(byte[] ciphertext, EncryptionContext context) {
    try {
        final CryptoResult<byte[], KmsMasterKey> decryptResult = crypto.decryptData(getProvider(), ciphertext);

        verify(decryptResult, context);

        return decryptResult.getResult();
    } catch (AwsCryptoException e) {
        if (isInvalidKeyException(e)) {
            throw new UnlimitedEncryptionNotSetException();
        } else {
            throw e;
        }
    }
}
 
Example 2
Source File: KMSEncryptor.java    From strongbox with Apache License 2.0 5 votes vote down vote up
@Override
public String decrypt(String ciphertext, EncryptionContext context) {
    final CryptoResult<String, KmsMasterKey> decryptResult = crypto.decryptString(getProvider(), ciphertext);

    verify(decryptResult, context);

    return decryptResult.getResult();
}
 
Example 3
Source File: AwsKmsEncryptionService.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public byte[] decrypt(byte[] data) {
    if (crypto == null || prov == null)
        throw new IgniteException("The init() method was not called.");

    CryptoResult<byte[], KmsMasterKey> decryptRes = crypto.decryptData(prov, data);

    List<String> keyIds = decryptRes.getMasterKeyIds();

    if (keyIds != null && !keyIds.contains(keyId))
        throw new IgniteException("Wrong KMS key ID!");

    return decryptRes.getResult();
}