roryqi commented on code in PR #10975:
URL: https://github.com/apache/gravitino/pull/10975#discussion_r3246238116
##########
clients/client-java/src/main/java/org/apache/gravitino/client/HTTPClient.java:
##########
@@ -730,9 +735,65 @@ private static HttpClientConnectionManager
configureConnectionManager(
ConnectionConfig connectionConfig =
configureConnectionConfig(clientConfiguration);
connectionManagerBuilder.setDefaultConnectionConfig(connectionConfig);
+
+ // Configure custom TLS settings, if provided
+ TLSConfigurer tlsConfigurer = loadTlsConfigurer(properties);
Review Comment:
Properties are flexible. It can't give enough constraint to client.
I prefer add a `withTlsConfigurer` method for the builder instead of using
reflection.
##########
clients/client-java/src/main/java/org/apache/gravitino/client/TLSConfigurer.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.gravitino.client;
+
+import java.util.Map;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLContext;
+import org.apache.hc.client5.http.ssl.HttpsSupport;
+import org.apache.hc.core5.ssl.SSLContexts;
+
+/** Configures TLS settings for the HTTP client. */
+public interface TLSConfigurer {
+
+ /**
+ * Initializes the TLS configurer with client properties.
+ *
+ * @param properties client configuration properties
+ */
+ default void initialize(Map<String, String> properties) {}
+
+ /**
+ * Returns the SSL context used for TLS connections.
+ *
+ * @return SSL context
+ */
+ default SSLContext sslContext() {
+ return SSLContexts.createDefault();
+ }
+
+ /**
+ * Returns the hostname verifier used for TLS connections.
+ *
+ * @return hostname verifier
+ */
+ default HostnameVerifier hostnameVerifier() {
+ return HttpsSupport.getDefaultHostnameVerifier();
+ }
+
+ /**
+ * Returns the supported TLS protocols.
+ *
+ * @return supported TLS protocols
+ */
+ default String[] supportedProtocols() {
+ return null;
Review Comment:
Could u return a empty array instead of null value? It's hard to handle null
value.
##########
clients/client-java/src/main/java/org/apache/gravitino/client/TLSConfigurer.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.gravitino.client;
+
+import java.util.Map;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLContext;
+import org.apache.hc.client5.http.ssl.HttpsSupport;
+import org.apache.hc.core5.ssl.SSLContexts;
+
+/** Configures TLS settings for the HTTP client. */
+public interface TLSConfigurer {
+
+ /**
+ * Initializes the TLS configurer with client properties.
+ *
+ * @param properties client configuration properties
+ */
+ default void initialize(Map<String, String> properties) {}
Review Comment:
Could we avoid use initialize methods? The reason is like above. Our
TLSConfugurer shouldn't initialize by properties.
##########
clients/client-java/src/main/java/org/apache/gravitino/client/TLSConfigurer.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.gravitino.client;
+
+import java.util.Map;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLContext;
+import org.apache.hc.client5.http.ssl.HttpsSupport;
+import org.apache.hc.core5.ssl.SSLContexts;
+
+/** Configures TLS settings for the HTTP client. */
+public interface TLSConfigurer {
+
+ /**
+ * Initializes the TLS configurer with client properties.
+ *
+ * @param properties client configuration properties
+ */
+ default void initialize(Map<String, String> properties) {}
+
+ /**
+ * Returns the SSL context used for TLS connections.
+ *
+ * @return SSL context
+ */
+ default SSLContext sslContext() {
+ return SSLContexts.createDefault();
+ }
+
+ /**
+ * Returns the hostname verifier used for TLS connections.
+ *
+ * @return hostname verifier
+ */
+ default HostnameVerifier hostnameVerifier() {
+ return HttpsSupport.getDefaultHostnameVerifier();
+ }
+
+ /**
+ * Returns the supported TLS protocols.
+ *
+ * @return supported TLS protocols
+ */
+ default String[] supportedProtocols() {
+ return null;
+ }
+
+ /**
+ * Returns the supported cipher suites.
+ *
+ * @return supported cipher suites
+ */
+ default String[] supportedCipherSuites() {
Review Comment:
Ditto.
--
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]