This is an automated email from the ASF dual-hosted git repository.
stoty pushed a commit to branch 5.2
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/5.2 by this push:
new dd5facb89b PHOENIX-7470 Simplify Kerberos login in ConnectionInfo
(#2085)
dd5facb89b is described below
commit dd5facb89b3dddc1035bc736340ca24492aeb7ce
Author: Istvan Toth <[email protected]>
AuthorDate: Tue Mar 11 15:18:34 2025 +0100
PHOENIX-7470 Simplify Kerberos login in ConnectionInfo (#2085)
---
.../org/apache/phoenix/jdbc/ConnectionInfo.java | 32 ++--------------------
.../org/apache/phoenix/query/QueryServices.java | 2 ++
2 files changed, 5 insertions(+), 29 deletions(-)
diff --git
a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java
b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java
index 5744bc9e05..faaa9841ec 100644
---
a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java
+++
b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ConnectionInfo.java
@@ -29,6 +29,7 @@ import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.util.VersionInfo;
+import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authentication.util.KerberosUtil;
import org.apache.phoenix.exception.SQLExceptionCode;
@@ -481,11 +482,8 @@ public abstract class ConnectionInfo {
LOGGER.info("Trying to connect to a secure
cluster as {} "
+ "with keytab {}",
principal, keytab);
- final Configuration newConfig =
getConfiguration(principal, keytab);
- // We are intentionally changing the passed in
Configuration object
-
UserGroupInformation.setConfiguration(newConfig);
- User.login(newConfig,
QueryServices.HBASE_CLIENT_KEYTAB,
- QueryServices.HBASE_CLIENT_PRINCIPAL,
null);
+ User.login(keytab,
+ SecurityUtil.getServerPrincipal(principal,
(String) null));
user = User.getCurrent();
LOGGER.info("Successful login to secure
cluster");
}
@@ -504,30 +502,6 @@ public abstract class ConnectionInfo {
}
}
- private Configuration getConfiguration( String principal, String
keytab) {
- final Configuration config =
HBaseFactoryProvider.getConfigurationFactory().getConfiguration();
- // Add QueryServices properties
- if (props != null) {
- for (Entry<String,String> entry : props) {
- config.set(entry.getKey(), entry.getValue());
- }
- }
- // Add any user-provided properties (via DriverManager)
- if (info != null) {
- for (Object key : info.keySet()) {
- config.set((String) key, info.getProperty((String) key));
- }
- }
- // Set the principal and keytab if provided from the URL
(overriding those provided in Properties)
- if (null != principal) {
- config.set(QueryServices.HBASE_CLIENT_PRINCIPAL, principal);
- }
- if (null != keytab) {
- config.set(QueryServices.HBASE_CLIENT_KEYTAB, keytab);
- }
- return config;
- }
-
protected String normalizeHostsList(String quorum, Integer defaultPort)
throws SQLException {
// The input host:port separator char is "=" (after unescaping)
diff --git
a/phoenix-core-client/src/main/java/org/apache/phoenix/query/QueryServices.java
b/phoenix-core-client/src/main/java/org/apache/phoenix/query/QueryServices.java
index 79fadf603e..fe09c6d4d8 100644
---
a/phoenix-core-client/src/main/java/org/apache/phoenix/query/QueryServices.java
+++
b/phoenix-core-client/src/main/java/org/apache/phoenix/query/QueryServices.java
@@ -54,7 +54,9 @@ public interface QueryServices extends SQLCloseable {
"phoenix.query.client.join.spooling.enabled";
public static final String SERVER_ORDERBY_SPOOLING_ENABLED_ATTRIB =
"phoenix.query.server.orderBy.spooling.enabled";
+ @Deprecated
public static final String HBASE_CLIENT_KEYTAB = "hbase.myclient.keytab";
+ @Deprecated
public static final String HBASE_CLIENT_PRINCIPAL =
"hbase.myclient.principal";
String QUERY_SERVICES_NAME = "phoenix.query.services.name";
public static final String SPOOL_DIRECTORY = "phoenix.spool.directory";