Skip to content

Commit ffaee73

Browse files
mimaisonmanoj-mathivanan
authored andcommitted
KAFKA-18520: Remove ZooKeeper logic from JaasUtils (apache#18530)
Reviewers: Chia-Ping Tsai <[email protected]>
1 parent 838efce commit ffaee73

File tree

1 file changed

+0
-55
lines changed

1 file changed

+0
-55
lines changed

clients/src/main/java/org/apache/kafka/common/security/JaasUtils.java

-55
Original file line numberDiff line numberDiff line change
@@ -16,67 +16,12 @@
1616
*/
1717
package org.apache.kafka.common.security;
1818

19-
import org.apache.kafka.common.KafkaException;
20-
21-
import org.slf4j.Logger;
22-
import org.slf4j.LoggerFactory;
23-
24-
import javax.security.auth.login.Configuration;
25-
2619
public final class JaasUtils {
27-
private static final Logger LOG = LoggerFactory.getLogger(JaasUtils.class);
2820
public static final String JAVA_LOGIN_CONFIG_PARAM = "java.security.auth.login.config";
2921
public static final String DISALLOWED_LOGIN_MODULES_CONFIG = "org.apache.kafka.disallowed.login.modules";
3022
public static final String DISALLOWED_LOGIN_MODULES_DEFAULT = "com.sun.security.auth.module.JndiLoginModule";
3123
public static final String SERVICE_NAME = "serviceName";
3224

33-
public static final String ZK_SASL_CLIENT = "zookeeper.sasl.client";
34-
public static final String ZK_LOGIN_CONTEXT_NAME_KEY = "zookeeper.sasl.clientconfig";
35-
36-
private static final String DEFAULT_ZK_LOGIN_CONTEXT_NAME = "Client";
37-
private static final String DEFAULT_ZK_SASL_CLIENT = "true";
38-
3925
private JaasUtils() {}
4026

41-
public static String zkSecuritySysConfigString() {
42-
String loginConfig = System.getProperty(JAVA_LOGIN_CONFIG_PARAM);
43-
String clientEnabled = System.getProperty(ZK_SASL_CLIENT, "default:" + DEFAULT_ZK_SASL_CLIENT);
44-
String contextName = System.getProperty(ZK_LOGIN_CONTEXT_NAME_KEY, "default:" + DEFAULT_ZK_LOGIN_CONTEXT_NAME);
45-
return "[" +
46-
JAVA_LOGIN_CONFIG_PARAM + "=" + loginConfig +
47-
", " +
48-
ZK_SASL_CLIENT + "=" + clientEnabled +
49-
", " +
50-
ZK_LOGIN_CONTEXT_NAME_KEY + "=" + contextName +
51-
"]";
52-
}
53-
54-
public static boolean isZkSaslEnabled() {
55-
// Technically a client must also check if TLS mutual authentication has been configured,
56-
// but we will leave that up to the client code to determine since direct connectivity to ZooKeeper
57-
// has been deprecated in many clients and we don't wish to re-introduce a ZooKeeper jar dependency here.
58-
boolean zkSaslEnabled = Boolean.parseBoolean(System.getProperty(ZK_SASL_CLIENT, DEFAULT_ZK_SASL_CLIENT));
59-
String zkLoginContextName = System.getProperty(ZK_LOGIN_CONTEXT_NAME_KEY, DEFAULT_ZK_LOGIN_CONTEXT_NAME);
60-
61-
LOG.debug("Checking login config for Zookeeper JAAS context {}", zkSecuritySysConfigString());
62-
63-
boolean foundLoginConfigEntry;
64-
try {
65-
Configuration loginConf = Configuration.getConfiguration();
66-
foundLoginConfigEntry = loginConf.getAppConfigurationEntry(zkLoginContextName) != null;
67-
} catch (Exception e) {
68-
throw new KafkaException("Exception while loading Zookeeper JAAS login context " +
69-
zkSecuritySysConfigString(), e);
70-
}
71-
72-
if (foundLoginConfigEntry && !zkSaslEnabled) {
73-
LOG.error("JAAS configuration is present, but system property " +
74-
ZK_SASL_CLIENT + " is set to false, which disables " +
75-
"SASL in the ZooKeeper client");
76-
throw new KafkaException("Exception while determining if ZooKeeper is secure " +
77-
zkSecuritySysConfigString());
78-
}
79-
80-
return foundLoginConfigEntry;
81-
}
8227
}

0 commit comments

Comments
 (0)