Carl-Zhou-CN commented on code in PR #5903:
URL: https://github.com/apache/seatunnel/pull/5903#discussion_r1417380641


##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/hive/HiveJdbcConnectionProvider.java:
##########
@@ -76,4 +62,43 @@ public Connection getOrEstablishConnection() throws 
SQLException, ClassNotFoundE
         }
         return super.getConnection();
     }
+
+    private Connection getConnectionWithKerberos(
+            HiveConnectionProduceFunction hiveConnectionProduceFunction) {
+        try {
+            Configuration configuration = new Configuration();
+            configuration.set("hadoop.security.authentication", "kerberos");
+            return HadoopLoginFactory.loginWithKerberos(
+                    configuration,
+                    jdbcConfig.krb5Path,
+                    jdbcConfig.kerberosPrincipal,
+                    jdbcConfig.kerberosKeytabPath,
+                    (conf, userGroupInformation) -> 
hiveConnectionProduceFunction.produce());
+        } catch (Exception ex) {
+            throw new JdbcConnectorException(KERBEROS_AUTHENTICATION_FAILED, 
ex);
+        }
+    }
+
+    public static class HiveConnectionProduceFunction {
+
+        private final Driver driver;
+        private final JdbcConnectionConfig jdbcConnectionConfig;
+
+        public HiveConnectionProduceFunction(
+                Driver driver, JdbcConnectionConfig jdbcConnectionConfig) {
+            this.driver = driver;
+            this.jdbcConnectionConfig = jdbcConnectionConfig;
+        }
+
+        public Connection produce() throws SQLException {
+            final Properties info = new Properties();
+            jdbcConnectionConfig
+                    .getUsername()
+                    .ifPresent(username -> info.setProperty("user", username));
+            jdbcConnectionConfig
+                    .getPassword()
+                    .ifPresent(username -> info.setProperty("password", 
username));

Review Comment:
   I wonder if 'user','password' would be better with values from JdbcOptions?



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