Search in sources :

Example 1 with ChannelState

use of org.apache.kafka.common.network.ChannelState in project apache-kafka-on-k8s by banzaicloud.

the class SaslAuthenticatorTest method createAndCheckClientConnectionFailure.

private ChannelState createAndCheckClientConnectionFailure(SecurityProtocol securityProtocol, String node) throws Exception {
    createClientConnection(securityProtocol, node);
    ChannelState finalState = NetworkTestUtils.waitForChannelClose(selector, node, ChannelState.State.AUTHENTICATION_FAILED);
    selector.close();
    selector = null;
    return finalState;
}
Also used : ChannelState(org.apache.kafka.common.network.ChannelState)

Example 2 with ChannelState

use of org.apache.kafka.common.network.ChannelState in project kafka by apache.

the class SaslAuthenticatorFailureDelayTest method createAndCheckClientAuthenticationFailure.

private void createAndCheckClientAuthenticationFailure(SecurityProtocol securityProtocol, String node, String mechanism, String expectedErrorMessage) throws Exception {
    ChannelState finalState = createAndCheckClientConnectionFailure(securityProtocol, node);
    Exception exception = finalState.exception();
    assertTrue(exception instanceof SaslAuthenticationException, "Invalid exception class " + exception.getClass());
    if (expectedErrorMessage == null)
        expectedErrorMessage = "Authentication failed during authentication due to invalid credentials with SASL mechanism " + mechanism;
    assertEquals(expectedErrorMessage, exception.getMessage());
}
Also used : ChannelState(org.apache.kafka.common.network.ChannelState) SaslAuthenticationException(org.apache.kafka.common.errors.SaslAuthenticationException) SaslAuthenticationException(org.apache.kafka.common.errors.SaslAuthenticationException) IOException(java.io.IOException)

Example 3 with ChannelState

use of org.apache.kafka.common.network.ChannelState in project kafka by apache.

the class SaslAuthenticatorTest method createAndCheckClientAuthenticationFailure.

private void createAndCheckClientAuthenticationFailure(SecurityProtocol securityProtocol, String node, String mechanism, String expectedErrorMessage) throws Exception {
    ChannelState finalState = createAndCheckClientConnectionFailure(securityProtocol, node);
    Exception exception = finalState.exception();
    assertTrue(exception instanceof SaslAuthenticationException, "Invalid exception class " + exception.getClass());
    String expectedExceptionMessage = expectedErrorMessage != null ? expectedErrorMessage : "Authentication failed during authentication due to invalid credentials with SASL mechanism " + mechanism;
    assertEquals(expectedExceptionMessage, exception.getMessage());
}
Also used : ChannelState(org.apache.kafka.common.network.ChannelState) SaslAuthenticationException(org.apache.kafka.common.errors.SaslAuthenticationException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) KafkaException(org.apache.kafka.common.KafkaException) SaslException(javax.security.sasl.SaslException) OAuthBearerIllegalTokenException(org.apache.kafka.common.security.oauthbearer.internals.unsecured.OAuthBearerIllegalTokenException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) OAuthBearerConfigException(org.apache.kafka.common.security.oauthbearer.internals.unsecured.OAuthBearerConfigException) SaslAuthenticationException(org.apache.kafka.common.errors.SaslAuthenticationException) IOException(java.io.IOException) LoginException(javax.security.auth.login.LoginException) SchemaException(org.apache.kafka.common.protocol.types.SchemaException) SslAuthenticationException(org.apache.kafka.common.errors.SslAuthenticationException) SSLPeerUnverifiedException(javax.net.ssl.SSLPeerUnverifiedException)

Example 4 with ChannelState

use of org.apache.kafka.common.network.ChannelState in project apache-kafka-on-k8s by banzaicloud.

the class SaslAuthenticatorTest method createAndCheckClientAuthenticationFailure.

private void createAndCheckClientAuthenticationFailure(SecurityProtocol securityProtocol, String node, String mechanism, String expectedErrorMessage) throws Exception {
    ChannelState finalState = createAndCheckClientConnectionFailure(securityProtocol, node);
    Exception exception = finalState.exception();
    assertTrue("Invalid exception class " + exception.getClass(), exception instanceof SaslAuthenticationException);
    if (expectedErrorMessage == null)
        expectedErrorMessage = "Authentication failed due to invalid credentials with SASL mechanism " + mechanism;
    assertEquals(expectedErrorMessage, exception.getMessage());
}
Also used : ChannelState(org.apache.kafka.common.network.ChannelState) SaslAuthenticationException(org.apache.kafka.common.errors.SaslAuthenticationException) KafkaException(org.apache.kafka.common.KafkaException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SaslAuthenticationException(org.apache.kafka.common.errors.SaslAuthenticationException) IOException(java.io.IOException)

Example 5 with ChannelState

use of org.apache.kafka.common.network.ChannelState in project kafka by apache.

the class SaslAuthenticatorTest method createAndCheckClientConnectionFailure.

private ChannelState createAndCheckClientConnectionFailure(SecurityProtocol securityProtocol, String node) throws Exception {
    try {
        createClientConnection(securityProtocol, node);
        ChannelState finalState = NetworkTestUtils.waitForChannelClose(selector, node, ChannelState.State.AUTHENTICATION_FAILED);
        return finalState;
    } finally {
        closeClientConnectionIfNecessary();
    }
}
Also used : ChannelState(org.apache.kafka.common.network.ChannelState)

Aggregations

ChannelState (org.apache.kafka.common.network.ChannelState)8 IOException (java.io.IOException)4 SaslAuthenticationException (org.apache.kafka.common.errors.SaslAuthenticationException)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 KafkaException (org.apache.kafka.common.KafkaException)3 SSLPeerUnverifiedException (javax.net.ssl.SSLPeerUnverifiedException)2 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)2 LoginException (javax.security.auth.login.LoginException)2 SaslException (javax.security.sasl.SaslException)2 SslAuthenticationException (org.apache.kafka.common.errors.SslAuthenticationException)2 SchemaException (org.apache.kafka.common.protocol.types.SchemaException)2 OAuthBearerConfigException (org.apache.kafka.common.security.oauthbearer.internals.unsecured.OAuthBearerConfigException)2 OAuthBearerIllegalTokenException (org.apache.kafka.common.security.oauthbearer.internals.unsecured.OAuthBearerIllegalTokenException)2 AuthenticationException (org.apache.kafka.common.errors.AuthenticationException)1