use of org.apache.kafka.common.network.CertStores in project apache-kafka-on-k8s by banzaicloud.
the class SaslAuthenticatorTest method setup.
@Before
public void setup() throws Exception {
LoginManager.closeAll();
serverCertStores = new CertStores(true, "localhost");
clientCertStores = new CertStores(false, "localhost");
saslServerConfigs = serverCertStores.getTrustingConfig(clientCertStores);
saslClientConfigs = clientCertStores.getTrustingConfig(serverCertStores);
credentialCache = new CredentialCache();
}
use of org.apache.kafka.common.network.CertStores in project kafka by apache.
the class SaslAuthenticatorTest method verifySslClientAuthForSaslSslListener.
private void verifySslClientAuthForSaslSslListener(boolean useListenerPrefix, SslClientAuth configuredClientAuth) throws Exception {
SecurityProtocol securityProtocol = SecurityProtocol.SASL_SSL;
configureMechanisms("PLAIN", Collections.singletonList("PLAIN"));
String listenerPrefix = useListenerPrefix ? ListenerName.forSecurityProtocol(securityProtocol).configPrefix() : "";
saslServerConfigs.put(listenerPrefix + BrokerSecurityConfigs.SSL_CLIENT_AUTH_CONFIG, configuredClientAuth.name());
saslServerConfigs.put(BrokerSecurityConfigs.PRINCIPAL_BUILDER_CLASS_CONFIG, SaslSslPrincipalBuilder.class.getName());
server = createEchoServer(securityProtocol);
SslClientAuth expectedClientAuth = useListenerPrefix ? configuredClientAuth : SslClientAuth.NONE;
String certDn = "O=A client,CN=localhost";
KafkaPrincipal principalWithMutualTls = SaslSslPrincipalBuilder.saslSslPrincipal(TestJaasConfig.USERNAME, certDn);
KafkaPrincipal principalWithOneWayTls = SaslSslPrincipalBuilder.saslSslPrincipal(TestJaasConfig.USERNAME, "ANONYMOUS");
// Client configured with valid key store
createAndCheckClientConnectionAndPrincipal(securityProtocol, "0", expectedClientAuth == SslClientAuth.NONE ? principalWithOneWayTls : principalWithMutualTls);
// Client does not configure key store
removeClientSslKeystore();
if (expectedClientAuth != SslClientAuth.REQUIRED) {
createAndCheckClientConnectionAndPrincipal(securityProtocol, "1", principalWithOneWayTls);
} else {
createAndCheckSslAuthenticationFailure(securityProtocol, "1");
}
// Client configures untrusted key store
CertStores newStore = new CertStores(false, "localhost");
newStore.keyStoreProps().forEach((k, v) -> saslClientConfigs.put(k, v));
if (expectedClientAuth == SslClientAuth.NONE) {
createAndCheckClientConnectionAndPrincipal(securityProtocol, "2", principalWithOneWayTls);
} else {
createAndCheckSslAuthenticationFailure(securityProtocol, "2");
}
}
use of org.apache.kafka.common.network.CertStores in project kafka by apache.
the class SaslAuthenticatorTest method setup.
@BeforeEach
public void setup() throws Exception {
LoginManager.closeAll();
time = Time.SYSTEM;
serverCertStores = new CertStores(true, "localhost");
clientCertStores = new CertStores(false, "localhost");
saslServerConfigs = serverCertStores.getTrustingConfig(clientCertStores);
saslClientConfigs = clientCertStores.getTrustingConfig(serverCertStores);
credentialCache = new CredentialCache();
TestLogin.loginCount.set(0);
}
use of org.apache.kafka.common.network.CertStores in project kafka by apache.
the class SaslAuthenticatorFailureDelayTest method setup.
@BeforeEach
public void setup() throws Exception {
LoginManager.closeAll();
serverCertStores = new CertStores(true, "localhost");
clientCertStores = new CertStores(false, "localhost");
saslServerConfigs = serverCertStores.getTrustingConfig(clientCertStores);
saslClientConfigs = clientCertStores.getTrustingConfig(serverCertStores);
credentialCache = new CredentialCache();
SaslAuthenticatorTest.TestLogin.loginCount.set(0);
startTimeMs = time.milliseconds();
}
Aggregations