mrendi29 commented on code in PR #16075: URL: https://github.com/apache/iceberg/pull/16075#discussion_r3198831303
########## hashicorp/src/main/java/org/apache/iceberg/hashicorp/VaultKeyManagementClient.java: ########## @@ -0,0 +1,191 @@ +/* + * 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.hashicorp; + +import java.io.Closeable; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.Map; +import org.apache.iceberg.encryption.KeyManagementClient; +import org.apache.iceberg.relocated.com.google.common.base.Preconditions; +import org.apache.iceberg.relocated.com.google.common.base.Strings; +import org.apache.iceberg.util.SerializableMap; + +/** + * KMS client implementation using HashiCorp Vault Transit secrets engine with AppRole + * authentication. + */ +public class VaultKeyManagementClient implements KeyManagementClient, Closeable { + @SuppressWarnings("unused") + private SerializableMap<String, String> properties; + + private String vaultAddress; + private String transitMount; + private String appRolePath; + private String appRoleId; + private String appSecretId; + private boolean rotateToken; + + private transient volatile String vaultToken; + private transient volatile long tokenExpiry; + private transient volatile VaultClient client; + + @Override + public void initialize(Map<String, String> newProperties) { + this.properties = SerializableMap.copyOf(newProperties); + + vaultAddress = newProperties.get(VaultProperties.VAULT_ADDRESS_PROP); + Preconditions.checkArgument( + !Strings.isNullOrEmpty(vaultAddress), + "%s must be set in newProperties", + VaultProperties.VAULT_ADDRESS_PROP); + + transitMount = newProperties.getOrDefault(VaultProperties.VAULT_TRANSIT_MOUNT_PROP, "transit"); + appRolePath = newProperties.getOrDefault(VaultProperties.VAULT_APPROLE_PATH_PROP, "approle"); + rotateToken = + Boolean.parseBoolean( + newProperties.getOrDefault(VaultProperties.VAULT_ROTATE_TOKEN_PROP, "false")); + + String configuredVaultToken = newProperties.get(VaultProperties.VAULT_TOKEN_PROP); + appRoleId = newProperties.get(VaultProperties.VAULT_ROLE_ID_PROP); + appSecretId = newProperties.get(VaultProperties.VAULT_SECRET_ID_PROP); Review Comment: sounds good to me, this way we are supporting both query engines. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
