Class Sessions

java.lang.Object
io.strimzi.kafka.oauth.services.Sessions

public class Sessions extends Object
Sessions entries should automatically get cleared as KafkaPrincipals for the sessions get garbage collected by JVM. The size of `activeSessions` at any moment in time should be about the number of currently active sessions. They may also get removed by broker-side plugins like custom authorizers when it is determined that the token has expired.
  • Constructor Details

    • Sessions

      public Sessions()
  • Method Details

    • put

      public void put(BearerTokenWithPayload token)
      Put a new token object into sessions cache
      Parameters:
      token - A token to add
    • remove

      public void remove(BearerTokenWithPayload token)
      Remove a token from sessions cache
      Parameters:
      token - A token to remove
    • removeAllWithMatchingAccessToken

      public void removeAllWithMatchingAccessToken(String accessToken)
      Remove all the active sessions for the passed access token
      Parameters:
      accessToken - access token for which to remove the sessions
    • executeTask

      Iterate over all active sessions (represented by stored token objects) applying a filter and submit a task to the passed executor for each passing token. Return a list of SessionFuture instances.
      Parameters:
      executor - An Executor to use for submitting tasks
      filter - A filter to decide if the task should be submitted for specific token
      task - Logic to run on the token
      Returns:
      A list of SessionFuture instances
    • cleanupExpired

      public void cleanupExpired()
      Cleanup the sessions whose lifetime has expired
    • map

      public <T> List<T> map(Function<BearerTokenWithPayload,T> mapper)
      Get a list of objects retrieved by applying the passed mapping function to the current active sessions set.

      For example, you can get a list of all the princiapl names.

      Type Parameters:
      T - A return type
      Parameters:
      mapper - A mapping function
      Returns:
      A list of mapped results