Search in sources :

Example 1 with TestJaasConfig

use of org.apache.kafka.common.security.authenticator.TestJaasConfig in project apache-kafka-on-k8s by banzaicloud.

the class PlainSaslServerTest method setUp.

@Before
public void setUp() throws Exception {
    TestJaasConfig jaasConfig = new TestJaasConfig();
    Map<String, Object> options = new HashMap<>();
    options.put("user_" + USER_A, PASSWORD_A);
    options.put("user_" + USER_B, PASSWORD_B);
    jaasConfig.addEntry("jaasContext", PlainLoginModule.class.getName(), options);
    JaasContext jaasContext = new JaasContext("jaasContext", JaasContext.Type.SERVER, jaasConfig, null);
    saslServer = new PlainSaslServer(jaasContext);
}
Also used : JaasContext(org.apache.kafka.common.security.JaasContext) HashMap(java.util.HashMap) TestJaasConfig(org.apache.kafka.common.security.authenticator.TestJaasConfig) Before(org.junit.Before)

Example 2 with TestJaasConfig

use of org.apache.kafka.common.security.authenticator.TestJaasConfig in project apache-kafka-on-k8s by banzaicloud.

the class SaslChannelBuilderTest method createChannelBuilder.

private SaslChannelBuilder createChannelBuilder(SecurityProtocol securityProtocol) {
    TestJaasConfig jaasConfig = new TestJaasConfig();
    jaasConfig.addEntry("jaasContext", PlainLoginModule.class.getName(), new HashMap<String, Object>());
    JaasContext jaasContext = new JaasContext("jaasContext", JaasContext.Type.SERVER, jaasConfig, null);
    Map<String, JaasContext> jaasContexts = Collections.singletonMap("PLAIN", jaasContext);
    return new SaslChannelBuilder(Mode.CLIENT, jaasContexts, securityProtocol, new ListenerName("PLAIN"), false, "PLAIN", true, null, null);
}
Also used : JaasContext(org.apache.kafka.common.security.JaasContext) PlainLoginModule(org.apache.kafka.common.security.plain.PlainLoginModule) TestJaasConfig(org.apache.kafka.common.security.authenticator.TestJaasConfig)

Example 3 with TestJaasConfig

use of org.apache.kafka.common.security.authenticator.TestJaasConfig in project kafka by apache.

the class OAuthBearerTest method configureHandler.

protected void configureHandler(AuthenticateCallbackHandler handler, Map<String, ?> configs, Map<String, Object> jaasConfig) {
    TestJaasConfig config = new TestJaasConfig();
    config.createOrUpdateEntry("KafkaClient", OAuthBearerLoginModule.class.getName(), jaasConfig);
    AppConfigurationEntry kafkaClient = config.getAppConfigurationEntry("KafkaClient")[0];
    handler.configure(configs, OAuthBearerLoginModule.OAUTHBEARER_MECHANISM, Collections.singletonList(kafkaClient));
}
Also used : AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry) OAuthBearerLoginModule(org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule) TestJaasConfig(org.apache.kafka.common.security.authenticator.TestJaasConfig)

Example 4 with TestJaasConfig

use of org.apache.kafka.common.security.authenticator.TestJaasConfig in project kafka by apache.

the class PlainSaslServerTest method setUp.

@BeforeEach
public void setUp() {
    TestJaasConfig jaasConfig = new TestJaasConfig();
    Map<String, Object> options = new HashMap<>();
    options.put("user_" + USER_A, PASSWORD_A);
    options.put("user_" + USER_B, PASSWORD_B);
    jaasConfig.addEntry("jaasContext", PlainLoginModule.class.getName(), options);
    JaasContext jaasContext = new JaasContext("jaasContext", JaasContext.Type.SERVER, jaasConfig, null);
    PlainServerCallbackHandler callbackHandler = new PlainServerCallbackHandler();
    callbackHandler.configure(null, "PLAIN", jaasContext.configurationEntries());
    saslServer = new PlainSaslServer(callbackHandler);
}
Also used : JaasContext(org.apache.kafka.common.security.JaasContext) HashMap(java.util.HashMap) PlainLoginModule(org.apache.kafka.common.security.plain.PlainLoginModule) TestJaasConfig(org.apache.kafka.common.security.authenticator.TestJaasConfig) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with TestJaasConfig

use of org.apache.kafka.common.security.authenticator.TestJaasConfig in project kafka by apache.

the class JaasBasicAuthFilterTest method setupJaasFilter.

private JaasBasicAuthFilter setupJaasFilter(String name, String credentialFilePath) {
    TestJaasConfig configuration = new TestJaasConfig();
    Map<String, Object> moduleOptions = credentialFilePath != null ? Collections.singletonMap("file", credentialFilePath) : Collections.emptyMap();
    configuration.addEntry(name, LOGIN_MODULE, moduleOptions);
    return new JaasBasicAuthFilter(configuration);
}
Also used : TestJaasConfig(org.apache.kafka.common.security.authenticator.TestJaasConfig)

Aggregations

TestJaasConfig (org.apache.kafka.common.security.authenticator.TestJaasConfig)9 JaasContext (org.apache.kafka.common.security.JaasContext)5 HashMap (java.util.HashMap)2 PlainLoginModule (org.apache.kafka.common.security.plain.PlainLoginModule)2 AppConfigurationEntry (javax.security.auth.login.AppConfigurationEntry)1 OAuthBearerLoginModule (org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule)1 LogContext (org.apache.kafka.common.utils.LogContext)1 GSSCredential (org.ietf.jgss.GSSCredential)1 GSSManager (org.ietf.jgss.GSSManager)1 GSSName (org.ietf.jgss.GSSName)1 Oid (org.ietf.jgss.Oid)1 Before (org.junit.Before)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1