Skip to content

Commit

Permalink
GH-3217: kafkaJaasInitializer clean up
Browse files Browse the repository at this point in the history
Fixes: #3217

* Cleaning up a temp file creation that was added as part of Kafka 0.9 Java client.
  This seems to be a no-op in the latest versions of the Kafka Java client.

(cherry picked from commit 6cb805b)
  • Loading branch information
sobychacko authored and spring-builds committed Apr 26, 2024
1 parent d7c22a0 commit 8eacc72
Showing 1 changed file with 2 additions and 14 deletions.
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

0 comments on commit 8eacc72

Please sign in to comment.