Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
*/
package org.apache.kafka.security;

import org.apache.kafka.clients.admin.ScramMechanism;
import org.apache.kafka.common.security.authenticator.CredentialCache;
import org.apache.kafka.common.security.scram.ScramCredential;
import org.apache.kafka.common.security.scram.internals.ScramCredentialUtils;
import org.apache.kafka.common.security.scram.internals.ScramMechanism;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the import also fix the import conflict caused by org.apache.kafka.clients.admin.ScramMechanism. Hence, could you please import org.apache.kafka.clients.admin.ScramMechanism and then streamline line#36 and line#45?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!
I have just fixed it.

import org.apache.kafka.common.security.token.delegation.internals.DelegationTokenCache;

import java.util.Collection;
import java.util.Properties;

public class CredentialProvider {
public final DelegationTokenCache tokenCache;
Expand All @@ -34,22 +33,8 @@ public CredentialProvider(Collection<String> scramMechanisms, DelegationTokenCac
ScramCredentialUtils.createCache(credentialCache, scramMechanisms);
}

public void updateCredentials(String username, Properties config) {
for (ScramMechanism mechanism : ScramMechanism.values()) {
CredentialCache.Cache<ScramCredential> cache = credentialCache.cache(mechanism.mechanismName(), ScramCredential.class);
if (cache != null) {
String c = config.getProperty(mechanism.mechanismName());
if (c == null) {
cache.remove(username);
} else {
cache.put(username, ScramCredentialUtils.credentialFromString(c));
}
}
}
}

public void updateCredential(
org.apache.kafka.clients.admin.ScramMechanism mechanism,
ScramMechanism mechanism,
String name,
ScramCredential credential
) {
Expand All @@ -58,7 +43,7 @@ public void updateCredential(
}

public void removeCredentials(
org.apache.kafka.clients.admin.ScramMechanism mechanism,
ScramMechanism mechanism,
String name
) {
CredentialCache.Cache<ScramCredential> cache = credentialCache.cache(mechanism.mechanismName(), ScramCredential.class);
Expand Down