protected final ContentCryptoMaterial createContentCryptoMaterial ( AmazonWebServiceRequest req ) { if ( req instanceof EncryptionMaterialsFactory ) { // per request level encryption materials EncryptionMaterialsFactory f = ( EncryptionMaterialsFactory ) req ; final EncryptionMaterials materials = f . getEncryptionMaterials ( ) ; if ( materials != null ) { return buildContentCryptoMaterial ( materials , req ) ; } } if ( req instanceof MaterialsDescriptionProvider ) { // per request level material description MaterialsDescriptionProvider mdp = ( MaterialsDescriptionProvider ) req ; Map < String , String > matdesc_req = mdp . getMaterialsDescription ( ) ; ContentCryptoMaterial ccm = newContentCryptoMaterial ( kekMaterialsProvider , matdesc_req , cryptoConfig . getCryptoProvider ( ) , req ) ; if ( ccm != null ) return ccm ; if ( matdesc_req != null ) { // check to see if KMS is in use and if so we should fall thru // to the s3 client level encryption material EncryptionMaterials material = kekMaterialsProvider . getEncryptionMaterials ( ) ; if ( ! material . isKMSEnabled ( ) ) { throw new SdkClientException ( "No material available from the encryption material provider for description " + matdesc_req ) ; } } // 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 ) ; }
Creates and returns a non - null content crypto material for the given request .