Class 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 (see CloudBlobCryptoAgentImpl.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)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CloudBlobCryptoAgentImpl

        public CloudBlobCryptoAgentImpl​(com.github.ambry.router.CryptoService cryptoService,
                                        com.github.ambry.router.KeyManagementService kms,
                                        java.lang.String context)
                                 throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
    • 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 interface CloudBlobCryptoAgent
        Parameters:
        buffer - The ByteBuffer 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 interface CloudBlobCryptoAgent
        Parameters:
        buffer - The ByteBuffer that needs to be decrypted.
        Returns:
        The decrypted buffer.
        Throws:
        java.security.GeneralSecurityException