Search in sources :

Example 1 with ScramMechanism

use of org.apache.kafka.common.security.scram.internals.ScramMechanism in project kafka by apache.

the class SaslAuthenticatorTest method updateTokenCredentialCache.

@SuppressWarnings("unchecked")
private void updateTokenCredentialCache(String username, String password) throws NoSuchAlgorithmException {
    for (String mechanism : (List<String>) saslServerConfigs.get(BrokerSecurityConfigs.SASL_ENABLED_MECHANISMS_CONFIG)) {
        ScramMechanism scramMechanism = ScramMechanism.forMechanismName(mechanism);
        if (scramMechanism != null) {
            ScramFormatter formatter = new ScramFormatter(scramMechanism);
            ScramCredential credential = formatter.generateCredential(password, 4096);
            server.tokenCache().credentialCache(scramMechanism.mechanismName()).put(username, credential);
        }
    }
}
Also used : ScramCredential(org.apache.kafka.common.security.scram.ScramCredential) ScramFormatter(org.apache.kafka.common.security.scram.internals.ScramFormatter) ScramMechanism(org.apache.kafka.common.security.scram.internals.ScramMechanism) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with ScramMechanism

use of org.apache.kafka.common.security.scram.internals.ScramMechanism in project kafka by apache.

the class SaslAuthenticatorTest method updateScramCredentialCache.

@SuppressWarnings("unchecked")
private void updateScramCredentialCache(String username, String password) throws NoSuchAlgorithmException {
    for (String mechanism : (List<String>) saslServerConfigs.get(BrokerSecurityConfigs.SASL_ENABLED_MECHANISMS_CONFIG)) {
        ScramMechanism scramMechanism = ScramMechanism.forMechanismName(mechanism);
        if (scramMechanism != null) {
            ScramFormatter formatter = new ScramFormatter(scramMechanism);
            ScramCredential credential = formatter.generateCredential(password, 4096);
            credentialCache.cache(scramMechanism.mechanismName(), ScramCredential.class).put(username, credential);
        }
    }
}
Also used : ScramCredential(org.apache.kafka.common.security.scram.ScramCredential) ScramFormatter(org.apache.kafka.common.security.scram.internals.ScramFormatter) ScramMechanism(org.apache.kafka.common.security.scram.internals.ScramMechanism) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 ScramCredential (org.apache.kafka.common.security.scram.ScramCredential)2 ScramFormatter (org.apache.kafka.common.security.scram.internals.ScramFormatter)2 ScramMechanism (org.apache.kafka.common.security.scram.internals.ScramMechanism)2