twalthr commented on code in PR #27394:
URL: https://github.com/apache/flink/pull/27394#discussion_r2759785912


##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/TableEnvironmentImpl.java:
##########
@@ -263,6 +265,19 @@ public static TableEnvironmentImpl 
create(EnvironmentSettings settings) {
                         ? settings.getCatalogStore()
                         : catalogStoreFactory.createCatalogStore();
 
+        final SecretStoreFactory secretStoreFactory =
+                TableFactoryUtil.findAndCreateSecretStoreFactory(
+                        settings.getConfiguration(), userClassLoader);
+        final SecretStoreFactory.Context secretStoreContext =
+                TableFactoryUtil.buildSecretStoreFactoryContext(
+                        settings.getConfiguration(), userClassLoader);
+        secretStoreFactory.open(secretStoreContext);
+        // TODO (FLINK-38261): pass secret store to catalog manager for 
encryption/decryption
+        final SecretStore secretStore =
+                settings.getSecretStore() != null
+                        ? settings.getSecretStore()

Review Comment:
   We should not discover a factory if a secret store is already provided. 
Please also update the CatalogStoreFactory above which has the same issue. Also 
the `TableFactoryUtil` class is kind of deprecated. Move the methods for both 
secret and catalog store to a new 
`org.apache.flink.table.api.internal.ApiFactoryUtil`



##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/EnvironmentSettings.java:
##########
@@ -154,6 +158,12 @@ public Optional<SqlFactory> getSqlFactory() {
         return Optional.ofNullable(sqlFactory);
     }
 
+    @Internal
+    @Nullable
+    public SecretStore getSecretStore() {

Review Comment:
   Use Optional, maybe also for CatalogStore for consistency.



##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/secret/GenericInMemorySecretStore.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.flink.table.secret;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.secret.exceptions.SecretException;
+import org.apache.flink.table.secret.exceptions.SecretNotFoundException;
+
+import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException;
+import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.type.TypeReference;
+import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * A generic in-memory implementation of both {@link ReadableSecretStore} and 
{@link
+ * WritableSecretStore}.
+ *
+ * <p>This implementation stores secrets in memory as plaintext JSON strings. 
It is suitable for
+ * testing and development purposes but should not be used in production 
environments as secrets are
+ * not encrypted.
+ */
+@Internal
+public class GenericInMemorySecretStore implements ReadableSecretStore, 
WritableSecretStore {
+
+    private static final ObjectMapper objectMapper = new ObjectMapper();

Review Comment:
   No need for Jackson deps here. We can store Java objects and avoid ser/de.



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

Reply via email to