You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/06/23 07:22:38 UTC

[GitHub] [iceberg] felixYyu commented on a diff in pull request #3471: Core: Envelope encryption

felixYyu commented on code in PR #3471:
URL: https://github.com/apache/iceberg/pull/3471#discussion_r904664786


##########
core/src/main/java/org/apache/iceberg/encryption/EnvelopeConfiguration.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.iceberg.encryption;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.apache.iceberg.relocated.com.google.common.base.MoreObjects;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+
+/**
+ * Configuration parameters for standard envelope encryption (where information is encrypted with a "data
+ * encryption key" - DEK, and the dek is encrypted with a "key encryption key" - KEK).
+ * Currently, supports only basic (single) envelope encryption and one KEK per table.
+ * Future versions will add support for double envelope encryption (where KEKs are encrypted with a "master
+ * encryption key"), and for multiple keys per table (column keys).
+ */
+public class EnvelopeConfiguration implements Serializable {
+
+  private final String kekId;
+  private final EncryptionAlgorithm algorithm;
+
+  private EnvelopeConfiguration(String kekId, EncryptionAlgorithm algorithm) {
+    Preconditions.checkNotNull(kekId,
+            "Cannot construct envelope config because KEK ID is not specified");
+    this.kekId = kekId;
+
+    Preconditions.checkNotNull(algorithm,
+            "Cannot construct envelope config because encryption algorithm is not specified");
+    this.algorithm = algorithm;
+  }
+
+  public String kekId() {
+    return kekId;
+  }
+
+  public EncryptionAlgorithm algorithm() {
+    return algorithm;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+
+    EnvelopeConfiguration config = (EnvelopeConfiguration) o;
+    return  Objects.equals(kekId, config.kekId) && algorithm == config.algorithm;
+  }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(kekId, algorithm);
+  }
+
+  @Override
+  public String toString() {
+    return MoreObjects.toStringHelper(this)
+            .add("kekId", kekId)
+            .add("algorithm", algorithm)
+            .toString();
+  }
+
+  public static Builder builder() {
+    return new Builder();
+  }
+
+  /**
+   * A builder used to create valid {@link EnvelopeConfiguration}.
+   */
+  public static class Builder {
+    private String kekId;
+    private EncryptionAlgorithm algorithm;
+

Review Comment:
   Missing private constructor,Static Analysis warning.
   
   private Builder() {
       }



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org