Class AuthAttemptCache

java.lang.Object
io.confluent.kafka.server.plugins.auth.AuthAttemptCache

public class AuthAttemptCache extends Object
Caches authentication attempts, whether successful or unsuccessful. The password hash is cached against the [username, password].
  • Constructor Summary

    Constructors
    Constructor
    Description
    AuthAttemptCache(long ttlMs, int maxSize, org.apache.kafka.common.utils.Time time, int maxEntriesPerCleanup, String sensorName, org.apache.kafka.common.metrics.Metrics metrics)
    Create an AuthAttemptCache.
    AuthAttemptCache(String sensorName, org.apache.kafka.common.metrics.Metrics metrics)
    Create an AuthAttemptCache using default values of ttl and maxSize
  • Method Summary

    Modifier and Type
    Method
    Description
    get(String username, String password)
    Return the hash for the [username, password] if any
    void
    invalidate(String username, String password)
    Remove a cache entry, if it exists.
    void
    put(String username, String password, String hash)
    Cache an authorisation.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AuthAttemptCache

      public AuthAttemptCache(long ttlMs, int maxSize, org.apache.kafka.common.utils.Time time, int maxEntriesPerCleanup, String sensorName, org.apache.kafka.common.metrics.Metrics metrics)
      Create an AuthAttemptCache.
      Parameters:
      maxSize - The maximum number of entries in the cache. When necessary, the cache will evict the oldest elements.
      time - The Kafka time object to provide time.
      sensorName - A string to differentiate the hit rate metric when multiple caches are in use
      metrics - A metrics registry to create the hit rate sensor in
      ttl - How long to cache entries, in milliseconds. The timer is reset on each access.
    • AuthAttemptCache

      public AuthAttemptCache(String sensorName, org.apache.kafka.common.metrics.Metrics metrics)
      Create an AuthAttemptCache using default values of ttl and maxSize
  • Method Details

    • get

      public String get(String username, String password)
      Return the hash for the [username, password] if any
      Parameters:
      username - The username.
      password - The password.
      Returns:
      the hash, or null if there is no entry.
    • put

      public void put(String username, String password, String hash)
      Cache an authorisation.
      Parameters:
      username - The username.
      password - The password.
      hash - The hash.
    • invalidate

      public void invalidate(String username, String password)
      Remove a cache entry, if it exists.
      Parameters:
      username - The username
      password - The password