Search in sources :

Example 1 with DelegationTokenCache

use of org.apache.kafka.common.security.token.delegation.DelegationTokenCache in project apache-kafka-on-k8s by banzaicloud.

the class SaslServerAuthenticatorTest method setupAuthenticator.

private SaslServerAuthenticator setupAuthenticator(Map<String, ?> configs, TransportLayer transportLayer, String mechanism) throws IOException {
    TestJaasConfig jaasConfig = new TestJaasConfig();
    jaasConfig.addEntry("jaasContext", PlainLoginModule.class.getName(), new HashMap<String, Object>());
    Map<String, JaasContext> jaasContexts = Collections.singletonMap(mechanism, new JaasContext("jaasContext", JaasContext.Type.SERVER, jaasConfig, null));
    Map<String, Subject> subjects = Collections.singletonMap(mechanism, new Subject());
    return new SaslServerAuthenticator(configs, "node", jaasContexts, subjects, null, new CredentialCache(), new ListenerName("ssl"), SecurityProtocol.SASL_SSL, transportLayer, new DelegationTokenCache(ScramMechanism.mechanismNames()));
}
Also used : PlainLoginModule(org.apache.kafka.common.security.plain.PlainLoginModule) ListenerName(org.apache.kafka.common.network.ListenerName) Subject(javax.security.auth.Subject) JaasContext(org.apache.kafka.common.security.JaasContext) DelegationTokenCache(org.apache.kafka.common.security.token.delegation.DelegationTokenCache)

Example 2 with DelegationTokenCache

use of org.apache.kafka.common.security.token.delegation.DelegationTokenCache in project apache-kafka-on-k8s by banzaicloud.

the class ScramSaslServerTest method setUp.

@Before
public void setUp() throws Exception {
    mechanism = ScramMechanism.SCRAM_SHA_256;
    formatter = new ScramFormatter(mechanism);
    CredentialCache.Cache<ScramCredential> credentialCache = new CredentialCache().createCache(mechanism.mechanismName(), ScramCredential.class);
    credentialCache.put(USER_A, formatter.generateCredential("passwordA", 4096));
    credentialCache.put(USER_B, formatter.generateCredential("passwordB", 4096));
    ScramServerCallbackHandler callbackHandler = new ScramServerCallbackHandler(credentialCache, new DelegationTokenCache(ScramMechanism.mechanismNames()));
    saslServer = new ScramSaslServer(mechanism, new HashMap<String, Object>(), callbackHandler);
}
Also used : HashMap(java.util.HashMap) CredentialCache(org.apache.kafka.common.security.authenticator.CredentialCache) DelegationTokenCache(org.apache.kafka.common.security.token.delegation.DelegationTokenCache) Before(org.junit.Before)

Aggregations

DelegationTokenCache (org.apache.kafka.common.security.token.delegation.DelegationTokenCache)2 HashMap (java.util.HashMap)1 Subject (javax.security.auth.Subject)1 ListenerName (org.apache.kafka.common.network.ListenerName)1 JaasContext (org.apache.kafka.common.security.JaasContext)1 CredentialCache (org.apache.kafka.common.security.authenticator.CredentialCache)1 PlainLoginModule (org.apache.kafka.common.security.plain.PlainLoginModule)1 Before (org.junit.Before)1