KAFKA-18556: Remove JaasModule#zkDigestModule, JaasTestUtils#zkSections (#18568)

Reviewers: Mickael Maison <mickael.maison@gmail.com>
This commit is contained in:
TengYao Chi 2025-01-17 01:17:06 +08:00 committed by GitHub
parent 6eb44ad869
commit 60cc2a0dea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 3 additions and 40 deletions

View File

@ -23,15 +23,6 @@ import java.util.Optional;
import java.util.stream.Collectors;
public class JaasModule {
public static JaasModule zkDigestModule(boolean debug, Map<String, String> entries) {
String name = "org.apache.zookeeper.server.auth.DigestLoginModule";
return new JaasModule(
name,
debug,
entries
);
}
public static JaasModule krb5LoginModule(boolean useKeyTab, boolean storeKey, String keyTab, String principal, boolean debug, Optional<String> serviceName, boolean isIbmSecurity) {
String name = isIbmSecurity ? "com.ibm.security.auth.module.Krb5LoginModule" : "com.sun.security.auth.module.Krb5LoginModule";

View File

@ -31,7 +31,6 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@ -72,12 +71,6 @@ public class JaasTestUtils {
private static final boolean IS_IBM_SECURITY = Java.isIbmJdk() && !Java.isIbmJdkSemeru();
private static final String ZK_SERVER_CONTEXT_NAME = "Server";
private static final String ZK_CLIENT_CONTEXT_NAME = "Client";
private static final String ZK_USER_SUPER_PASSWD = "adminpasswd";
private static final String ZK_USER = "fpj";
private static final String ZK_USER_PASSWORD = "fpjsecret";
public static final String KAFKA_SERVER_CONTEXT_NAME = "KafkaServer";
public static final String KAFKA_SERVER_PRINCIPAL_UNQUALIFIED_NAME = "kafka";
private static final String KAFKA_SERVER_PRINCIPAL = KAFKA_SERVER_PRINCIPAL_UNQUALIFIED_NAME + "/localhost@EXAMPLE.COM";
@ -172,20 +165,6 @@ public class JaasTestUtils {
return JaasModule.scramLoginModule(tokenId, password, false, tokenProps).toString();
}
public static List<JaasSection> zkSections() {
Map<String, String> zkServerEntries = new HashMap<>();
zkServerEntries.put("user_super", ZK_USER_SUPER_PASSWD);
zkServerEntries.put("user_" + ZK_USER, ZK_USER_PASSWORD);
JaasSection zkServerSection = new JaasSection(ZK_SERVER_CONTEXT_NAME, Collections.singletonList(JaasModule.zkDigestModule(false, zkServerEntries)));
Map<String, String> zkClientEntries = new HashMap<>();
zkClientEntries.put("username", ZK_USER);
zkClientEntries.put("password", ZK_USER_PASSWORD);
JaasSection zkClientSection = new JaasSection(ZK_CLIENT_CONTEXT_NAME, Collections.singletonList(JaasModule.zkDigestModule(false, zkClientEntries)));
return Arrays.asList(zkServerSection, zkClientSection);
}
public static JaasSection kafkaServerSection(String contextName, List<String> mechanisms, Optional<File> keytabLocation) {
List<JaasModule> modules = new ArrayList<>();
for (String mechanism : mechanisms) {

View File

@ -104,14 +104,8 @@ trait SaslSetup {
(kafkaServerSaslMechanisms.contains("GSSAPI") || kafkaClientSaslMechanism.contains("GSSAPI"))
if (hasKerberos)
maybeCreateEmptyKeytabFiles()
mode match {
case ZkSasl => JaasTestUtils.zkSections.asScala
case KafkaSasl =>
Seq(JaasTestUtils.kafkaServerSection(kafkaServerEntryName, kafkaServerSaslMechanisms.asJava, serverKeytabFile.toJava),
JaasTestUtils.kafkaClientSection(kafkaClientSaslMechanism.toJava, clientKeytabFile.toJava))
case Both => Seq(JaasTestUtils.kafkaServerSection(kafkaServerEntryName, kafkaServerSaslMechanisms.asJava, serverKeytabFile.toJava),
JaasTestUtils.kafkaClientSection(kafkaClientSaslMechanism.toJava, clientKeytabFile.toJava)) ++ JaasTestUtils.zkSections.asScala
}
}
private def writeJaasConfigurationToFile(jaasSections: Seq[JaasSection]): Unit = {

View File

@ -32,8 +32,7 @@ class MultipleListenersWithAdditionalJaasContextTest extends MultipleListenersWi
override def staticJaasSections: Seq[JaasSection] = {
val (serverKeytabFile, _) = maybeCreateEmptyKeytabFiles()
JaasTestUtils.zkSections.asScala :+
JaasTestUtils.kafkaServerSection("secure_external.KafkaServer", kafkaServerSaslMechanisms(SecureExternal).asJava, Some(serverKeytabFile).toJava)
Seq(JaasTestUtils.kafkaServerSection("secure_external.KafkaServer", kafkaServerSaslMechanisms(SecureExternal).asJava, Some(serverKeytabFile).toJava))
}
override protected def dynamicJaasSections: Properties = {