use of com.amazonaws.services.s3.model.EncryptionMaterialsFactory in project aws-sdk-android by aws-amplify.
the class S3CryptoModuleBase method createContentCryptoMaterial.
/**
* Creates and returns a non-null content crypto material for the given
* request.
*
* @throws AmazonClientException if no encryption material can be found.
*/
protected final ContentCryptoMaterial createContentCryptoMaterial(AmazonWebServiceRequest req) {
if (req instanceof EncryptionMaterialsFactory) {
// per request level encryption materials
final EncryptionMaterialsFactory f = (EncryptionMaterialsFactory) req;
final EncryptionMaterials materials = f.getEncryptionMaterials();
if (materials != null) {
return buildContentCryptoMaterial(materials, cryptoConfig.getCryptoProvider(), req);
}
}
if (req instanceof MaterialsDescriptionProvider) {
// per request level material description
final MaterialsDescriptionProvider mdp = (MaterialsDescriptionProvider) req;
final Map<String, String> matdescReq = mdp.getMaterialsDescription();
final ContentCryptoMaterial ccm = newContentCryptoMaterial(kekMaterialsProvider, matdescReq, cryptoConfig.getCryptoProvider(), req);
if (ccm != null) {
return ccm;
}
if (matdescReq != null) {
// check to see if KMS is in use and if so we should fall thru
// to the s3 client level encryption material
final EncryptionMaterials material = kekMaterialsProvider.getEncryptionMaterials();
if (!material.isKMSEnabled()) {
throw new AmazonClientException("No material available from the encryption material provider for description " + matdescReq);
}
}
// if there is no material description, fall thru to use
// the per s3 client level encryption materials
}
// per s3 client level encryption materials
return newContentCryptoMaterial(this.kekMaterialsProvider, cryptoConfig.getCryptoProvider(), req);
}
Aggregations