nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [nifi] alopresto commented on a change in pull request #3574: NIFI-4256 Adds AWS Encryption Controller Service
Date Fri, 02 Aug 2019 21:39:20 GMT
alopresto commented on a change in pull request #3574: NIFI-4256 Adds AWS Encryption Controller
Service
URL: https://github.com/apache/nifi/pull/3574#discussion_r310297751
 
 

 ##########
 File path: nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/encryption/ClientSideKMSEncryptionStrategy.java
 ##########
 @@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.processors.aws.s3.encryption;
+
+/**
+ * See https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingClientSideEncryption.html#client-side-encryption-kms-managed-master-key-intro
+ *
+ */
+
+import com.amazonaws.ClientConfiguration;
+import com.amazonaws.auth.AWSCredentialsProvider;
+import com.amazonaws.regions.Region;
+import com.amazonaws.regions.Regions;
+import com.amazonaws.services.s3.AmazonS3Client;
+import com.amazonaws.services.s3.AmazonS3EncryptionClient;
+import com.amazonaws.services.s3.model.CryptoConfiguration;
+import com.amazonaws.services.s3.model.KMSEncryptionMaterialsProvider;
+import org.apache.commons.lang3.StringUtils;
+
+public class ClientSideKMSEncryptionStrategy implements S3EncryptionStrategy {
+    @Override
+    public AmazonS3Client createEncryptionClient(AWSCredentialsProvider credentialsProvider,
ClientConfiguration clientConfiguration, String region, String keyIdOrMaterial) {
+        KMSEncryptionMaterialsProvider materialProvider = new KMSEncryptionMaterialsProvider(keyIdOrMaterial);
+        boolean haveRegion = StringUtils.isNotBlank(region);
+
+        CryptoConfiguration cryptoConfig = new CryptoConfiguration();
+        if (haveRegion) {
+            cryptoConfig.setAwsKmsRegion(Region.getRegion(Regions.fromName(region)));
 
 Review comment:
   Same comment on reducing duplicate lookup. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message