Package com.github.ambry.cloud
Class CloudBlobCryptoAgentImpl
- java.lang.Object
-
- com.github.ambry.cloud.CloudBlobCryptoAgentImpl
-
- All Implemented Interfaces:
CloudBlobCryptoAgent
public class CloudBlobCryptoAgentImpl extends java.lang.Object implements CloudBlobCryptoAgent
Implementation of CloudBlobCryptoAgent, encrypts byte buffers by 1. generating a random encryption key 2. encrypting that random key with a key from KeyManagementService that is associated with the given context string 3. encrypting a data byte buffer with the generated random key 4. returning a byte buffer containing the serialized encrypted key and encrypted data (seeCloudBlobCryptoAgentImpl.EncryptedDataPayload
below for serialization description
-
-
Constructor Summary
Constructors Constructor Description CloudBlobCryptoAgentImpl(com.github.ambry.router.CryptoService cryptoService, com.github.ambry.router.KeyManagementService kms, java.lang.String context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBuffer
decrypt(java.nio.ByteBuffer buffer)
Decrypts the blob buffer being downloaded from cloud storage.java.nio.ByteBuffer
encrypt(java.nio.ByteBuffer buffer)
Encrypts the blob buffer being uploaded to cloud storage.java.lang.String
getEncryptionContext()
Returns the encryption context (if any)
-
-
-
Method Detail
-
encrypt
public java.nio.ByteBuffer encrypt(java.nio.ByteBuffer buffer) throws java.security.GeneralSecurityException
Description copied from interface:CloudBlobCryptoAgent
Encrypts the blob buffer being uploaded to cloud storage.- Specified by:
encrypt
in interfaceCloudBlobCryptoAgent
- Parameters:
buffer
- TheByteBuffer
that needs to be encrypted.- Returns:
- The encrypted buffer.
- Throws:
java.security.GeneralSecurityException
-
decrypt
public java.nio.ByteBuffer decrypt(java.nio.ByteBuffer buffer) throws java.security.GeneralSecurityException
Description copied from interface:CloudBlobCryptoAgent
Decrypts the blob buffer being downloaded from cloud storage.- Specified by:
decrypt
in interfaceCloudBlobCryptoAgent
- Parameters:
buffer
- TheByteBuffer
that needs to be decrypted.- Returns:
- The decrypted buffer.
- Throws:
java.security.GeneralSecurityException
-
getEncryptionContext
public java.lang.String getEncryptionContext()
Description copied from interface:CloudBlobCryptoAgent
Returns the encryption context (if any)- Specified by:
getEncryptionContext
in interfaceCloudBlobCryptoAgent
- Returns:
-
-