Package ch.admin.bit.jeap.crypto.s3
Class JeapCryptoS3Template
java.lang.Object
ch.admin.bit.jeap.crypto.s3.JeapCryptoS3Template
The JeapCryptoS3Template can be used to put or get objects to/from S3 without
concerning about encryption or decryption.
-
Constructor Summary
ConstructorsConstructorDescriptionJeapCryptoS3Template(software.amazon.awssdk.services.s3.S3Client s3Client, CryptoService cryptoService) Construct a new JeapCryptoS3Template, given a AmazonS3-Client and a CryptoService.JeapCryptoS3Template(software.amazon.awssdk.services.s3.S3Client s3Client, KeyReferenceCryptoService keyReferenceCryptoService, KeyReference keyReference) Construct a new JeapCryptoS3Template, given a AmazonS3-Client and a KeyReferenceCryptoService. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves objects from S3 and decrypt the content if userMetaData 'is_encrypted: true' is set.Retrieves objects from S3 and decrypt the content if userMetaData 'is_encrypted: true' is set.voidUploads a new object to the specified Amazon S3 bucket.voidputObject(String bucketName, String keyName, byte[] plainTextByteArray, Map<String, String> userMetaDataMap) Uploads a new object to the specified Amazon S3 bucket.
-
Constructor Details
-
JeapCryptoS3Template
public JeapCryptoS3Template(software.amazon.awssdk.services.s3.S3Client s3Client, KeyReferenceCryptoService keyReferenceCryptoService, KeyReference keyReference) Construct a new JeapCryptoS3Template, given a AmazonS3-Client and a KeyReferenceCryptoService. Implementations will typically store a reference to the used encryption key together with the ciphertext. As S3 objects are usually not sensitive to a few more bytes being stored, prefer this constructor as it provides the benefit of additional safety concerning decryption in a disaster-recovery scenario where the information about the key used for encryption might be damaged.- Parameters:
s3Client- the AmazonS3-Client where the Objects are storedkeyReferenceCryptoService- handles the encryption and decryptionkeyReference- the key to use for encryption
-
JeapCryptoS3Template
public JeapCryptoS3Template(software.amazon.awssdk.services.s3.S3Client s3Client, CryptoService cryptoService) Construct a new JeapCryptoS3Template, given a AmazonS3-Client and a CryptoService.- Parameters:
s3Client- the AmazonS3-Client where the Objects are storedcryptoService- which handles the encryption and decryption
-
-
Method Details
-
putObject
Uploads a new object to the specified Amazon S3 bucket. Encrypts the Content and set a userMetaData 'is_encrypted: true'.- Parameters:
bucketName- - The name of an existing bucket, to which you have Permission.Write permissionobjectKey- - The key under which to store the specified file.plainTextByteArray- - Plaintext as byte[], which will be encrypted
-
putObject
public void putObject(String bucketName, String keyName, byte[] plainTextByteArray, Map<String, String> userMetaDataMap) Uploads a new object to the specified Amazon S3 bucket. Encrypts the Content and add the userMetaDataMap to the userMetaData. additionally the userMetaData 'is_encrypted: true' is set.- Parameters:
bucketName- - The name of an existing bucket, to which you have Permission.Write permissionkeyName- - The key under which to store the specified file.plainTextByteArray- - Plaintext as byte[], which will be encrypteduserMetaDataMap- Additional metaData as Mapinvalid input: '<'String, String>. For example 'author'
-
getObject
Retrieves objects from S3 and decrypt the content if userMetaData 'is_encrypted: true' is set. If userMetaData 'is_encrypted: true' is not set, the content will not be decrypted.- Parameters:
bucketName- - The name of the bucket containing the object to retrieve.keyName- - The key of the object to retrieve.- Returns:
- JeapDecryptedS3Object - holds the decrypted content of an object
-
getObject
Retrieves objects from S3 and decrypt the content if userMetaData 'is_encrypted: true' is set. If userMetaData 'is_encrypted: true' is not set, the content will not be decrypted.- Parameters:
bucketName- - The name of the bucket containing the object to retrieve.keyName- - The key of the object to retrieve.versionId- - The versionId of the object to retrieve.- Returns:
- JeapDecryptedS3Object - holds the decrypted content of an object
-