Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-3217: kafkaJaasInitializer clean up #3218

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2023 the original author or authors.
* Copyright 2017-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,6 @@

package org.springframework.kafka.security.jaas;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -37,6 +36,7 @@
* @author Marius Bogoevici
* @author Gary Russell
* @author Edan Idzerda
* @author Soby Chacko
*
* @since 1.3
*/
Expand Down Expand Up @@ -87,8 +87,6 @@ public enum ControlFlag {

private final boolean ignoreJavaLoginConfigParamSystemProperty;

private final File placeholderJaasConfiguration;

private final Map<String, String> options = new HashMap<>();

private String loginModule = "com.sun.security.auth.module.Krb5LoginModule";
Expand All @@ -99,8 +97,6 @@ public enum ControlFlag {
public KafkaJaasLoginModuleInitializer() throws IOException {
// we ignore the system property if it wasn't originally set at launch
this.ignoreJavaLoginConfigParamSystemProperty = (System.getProperty(JaasUtils.JAVA_LOGIN_CONFIG_PARAM) == null);
this.placeholderJaasConfiguration = File.createTempFile("kafka-client-jaas-config-placeholder", "conf");
this.placeholderJaasConfiguration.deleteOnExit();
}

public void setLoginModule(String loginModule) {
Expand Down Expand Up @@ -137,14 +133,6 @@ public void afterSingletonsInstantiated() {
new AppConfigurationEntry[] { kafkaClientConfigurationEntry });
Configuration.setConfiguration(new InternalConfiguration(configurationEntries,
Configuration.getConfiguration()));
// Workaround for a 0.9 client issue where even if the Configuration is
// set
// a system property check is performed.
// Since the Configuration already exists, this will be ignored.
if (this.placeholderJaasConfiguration != null) {
System.setProperty(JaasUtils.JAVA_LOGIN_CONFIG_PARAM,
this.placeholderJaasConfiguration.getAbsolutePath());
}
}
}

Expand Down