peacewong commented on a change in pull request #1117: URL: https://github.com/apache/incubator-linkis/pull/1117#discussion_r757279716
########## File path: linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/ConnectionManager.java ########## @@ -160,18 +205,148 @@ public Connection getConnection(Map<String, String> properties) throws SQLExcept return dataSource.getConnection(); } - public void close() { - for (DataSource dataSource: this.databaseToDataSources.values()) { + private String getJdbcUrl(Map<String, String> properties) throws SQLException { + String url = properties.get("jdbc.url"); + if (StringUtils.isEmpty(url)) { + throw new SQLException("jdbc.url is not empty."); + } + url = clearUrl(url); + validateURL(url); + return url.trim(); + } + + private boolean isUsernameAuthType(Map<String, String> properties) { + return "USERNAME".equals(getJdbcAuthType(properties)); + } + + private boolean isKerberosAuthType(Map<String, String> properties) { + return "KERBEROS".equals(getJdbcAuthType(properties)); Review comment: Can USERNAME/KERBEROS/SIMPLE be defined as a constant ########## File path: linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/ConnectionManager.java ########## @@ -160,18 +205,148 @@ public Connection getConnection(Map<String, String> properties) throws SQLExcept return dataSource.getConnection(); } - public void close() { - for (DataSource dataSource: this.databaseToDataSources.values()) { + private String getJdbcUrl(Map<String, String> properties) throws SQLException { + String url = properties.get("jdbc.url"); + if (StringUtils.isEmpty(url)) { + throw new SQLException("jdbc.url is not empty."); + } + url = clearUrl(url); + validateURL(url); + return url.trim(); + } + + private boolean isUsernameAuthType(Map<String, String> properties) { + return "USERNAME".equals(getJdbcAuthType(properties)); + } + + private boolean isKerberosAuthType(Map<String, String> properties) { + return "KERBEROS".equals(getJdbcAuthType(properties)); + } + + private String getJdbcAuthType(Map<String, String> properties) { + return properties.getOrDefault("jdbc.auth.type", "USERNAME").trim().toUpperCase(); + } + + private void createKerberosSecureConfiguration(Map<String, String> properties) { + Configuration conf = new Configuration(); + conf.set(HADOOP_SECURITY_AUTHENTICATION, KERBEROS.toString()); + UserGroupInformation.setConfiguration(conf); + try { + if (!UserGroupInformation.isSecurityEnabled() + || UserGroupInformation.getCurrentUser().getAuthenticationMethod() != KERBEROS Review comment: It is better to define Kerberos-related refresh and creation as a separate interface, without modifying the previous code file -- 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: dev-unsubscr...@linkis.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@linkis.apache.org For additional commands, e-mail: dev-h...@linkis.apache.org