Search in sources :

Example 1 with SaslAuthenticationContext

use of org.apache.kafka.common.security.auth.SaslAuthenticationContext in project apache-kafka-on-k8s by banzaicloud.

the class SaslServerAuthenticator method principal.

@Override
public KafkaPrincipal principal() {
    SaslAuthenticationContext context = new SaslAuthenticationContext(saslServer, securityProtocol, clientAddress());
    KafkaPrincipal principal = principalBuilder.build(context);
    if (ScramMechanism.isScram(saslMechanism) && Boolean.parseBoolean((String) saslServer.getNegotiatedProperty(ScramLoginModule.TOKEN_AUTH_CONFIG))) {
        principal.tokenAuthenticated(true);
    }
    return principal;
}
Also used : SaslAuthenticationContext(org.apache.kafka.common.security.auth.SaslAuthenticationContext) KafkaPrincipal(org.apache.kafka.common.security.auth.KafkaPrincipal)

Example 2 with SaslAuthenticationContext

use of org.apache.kafka.common.security.auth.SaslAuthenticationContext in project kafka by apache.

the class SaslServerAuthenticator method principal.

@Override
public KafkaPrincipal principal() {
    Optional<SSLSession> sslSession = transportLayer instanceof SslTransportLayer ? Optional.of(((SslTransportLayer) transportLayer).sslSession()) : Optional.empty();
    SaslAuthenticationContext context = new SaslAuthenticationContext(saslServer, securityProtocol, clientAddress(), listenerName.value(), sslSession);
    KafkaPrincipal principal = principalBuilder.build(context);
    if (ScramMechanism.isScram(saslMechanism) && Boolean.parseBoolean((String) saslServer.getNegotiatedProperty(ScramLoginModule.TOKEN_AUTH_CONFIG))) {
        principal.tokenAuthenticated(true);
    }
    return principal;
}
Also used : SslTransportLayer(org.apache.kafka.common.network.SslTransportLayer) SaslAuthenticationContext(org.apache.kafka.common.security.auth.SaslAuthenticationContext) SSLSession(javax.net.ssl.SSLSession) KafkaPrincipal(org.apache.kafka.common.security.auth.KafkaPrincipal)

Aggregations

KafkaPrincipal (org.apache.kafka.common.security.auth.KafkaPrincipal)2 SaslAuthenticationContext (org.apache.kafka.common.security.auth.SaslAuthenticationContext)2 SSLSession (javax.net.ssl.SSLSession)1 SslTransportLayer (org.apache.kafka.common.network.SslTransportLayer)1