[
https://issues.apache.org/jira/browse/BEAM-3813?focusedWorklogId=106700&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-106700
]
ASF GitHub Bot logged work on BEAM-3813:
----------------------------------------
Author: ASF GitHub Bot
Created on: 29/May/18 16:32
Start Date: 29/May/18 16:32
Worklog Time Spent: 10m
Work Description: lukecwik commented on a change in pull request #5491:
[BEAM-3813] Support (de)serialization of S3 encryption options via JSON
URL: https://github.com/apache/beam/pull/5491#discussion_r191490563
##########
File path:
sdks/java/io/amazon-web-services/src/main/java/org/apache/beam/sdk/io/aws/options/S3Module.java
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.beam.sdk.io.aws.options;
+
+import com.amazonaws.services.s3.model.SSEAwsKeyManagementParams;
+import com.amazonaws.services.s3.model.SSECustomerKey;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.Module;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.google.auto.service.AutoService;
+import java.io.IOException;
+
+/**
+ * A Jackson {@link Module} that registers a {@link JsonDeserializer} for
{@link SSECustomerKey} and
+ * {@link SSEAwsKeyManagementParams}. The serialized form is based on a Bean
serialization.
+ */
+@AutoService(Module.class)
+public class S3Module extends SimpleModule {
+
+ public S3Module() {
+ super("S3Module");
+ setMixInAnnotation(SSECustomerKey.class, SSECustomerKeyMixin.class);
+ setMixInAnnotation(SSEAwsKeyManagementParams.class,
SSEAwsKeyManagementParamsMixin.class);
+ }
+
+ /** A mixin to add Jackson annotations to {@link SSECustomerKey}. */
+ @JsonDeserialize(using = SSECustomerKeyDeserializer.class)
+ private static class SSECustomerKeyMixin {}
+
+ private static class SSECustomerKeyDeserializer extends
JsonDeserializer<SSECustomerKey> {
+ @Override
+ public SSECustomerKey deserialize(JsonParser parser,
DeserializationContext context)
+ throws IOException {
+ JsonNode node = parser.getCodec().readTree(parser);
Review comment:
Might be easier to read if you convert the value into a `Map<String,
String>` using:
```
Map<String, String> asMap =
jsonParser.readValueAs(new TypeReference<Map<String, String>>() {
});
```
ditto on below.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 106700)
Time Spent: 2h 40m (was: 2.5h)
> Support encryption for S3FileSystem (SSE-S3, SSE-C and SSE-KMS)
> ---------------------------------------------------------------
>
> Key: BEAM-3813
> URL: https://issues.apache.org/jira/browse/BEAM-3813
> Project: Beam
> Issue Type: Improvement
> Components: io-java-aws
> Reporter: Ismaël Mejía
> Assignee: Ismaël Mejía
> Priority: Minor
> Fix For: 2.5.0
>
> Time Spent: 2h 40m
> Remaining Estimate: 0h
>
> We should enable AWS S3 users to use encryption when reading or writing by
> provide encryption keys or using server side encryption via an algorithm, or
> a key management system (KMS)..
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)