All Downloads are FREE. Search and download functionalities are using the official Maven repository.

be.vlaanderen.informatievlaanderen.ldes.ldio.auth.SaslSslPlainConfigProvider Maven / Gradle / Ivy

The newest version!
package be.vlaanderen.informatievlaanderen.ldes.ldio.auth;

import org.apache.kafka.clients.CommonClientConfigs;
import org.apache.kafka.common.config.SaslConfigs;

import java.util.HashMap;
import java.util.Map;

public class SaslSslPlainConfigProvider {

	private static final String PLAIN_LOGIN_BASE_STRING = "org.apache.kafka.common.security.plain.PlainLoginModule" +
			" required username='%s' password='%s';";
	private static final String SASL_SSL = "SASL_SSL";
	private static final String PLAIN = "PLAIN";

	public Map createSaslSslPlainConfig(String user, String password) {
		final Map properties = new HashMap<>();
		properties.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, SASL_SSL);
		properties.put(SaslConfigs.SASL_MECHANISM, PLAIN);
		final String plainLoginString = PLAIN_LOGIN_BASE_STRING.formatted(user, password);
		properties.put(SaslConfigs.SASL_JAAS_CONFIG, plainLoginString);
		return properties;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy