Package io.strimzi.kafka.oauth.services
Class Sessions
java.lang.Object
io.strimzi.kafka.oauth.services.Sessions
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCleanup the sessions whose lifetime has expiredList<SessionFuture<?>>executeTask(ExecutorService executor, Predicate<BearerTokenWithPayload> filter, Consumer<BearerTokenWithPayload> task) 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.<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.voidput(BearerTokenWithPayload token) Put a new token object into sessions cachevoidremove(BearerTokenWithPayload token) Remove a token from sessions cachevoidremoveAllWithMatchingAccessToken(String accessToken) Remove all the active sessions for the passed access token
-
Constructor Details
-
Sessions
public Sessions()
-
-
Method Details
-
put
Put a new token object into sessions cache- Parameters:
token- A token to add
-
remove
Remove a token from sessions cache- Parameters:
token- A token to remove
-
removeAllWithMatchingAccessToken
Remove all the active sessions for the passed access token- Parameters:
accessToken- access token for which to remove the sessions
-
executeTask
public List<SessionFuture<?>> executeTask(ExecutorService executor, Predicate<BearerTokenWithPayload> filter, Consumer<BearerTokenWithPayload> task) 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 ofSessionFutureinstances.- Parameters:
executor- An Executor to use for submitting tasksfilter- A filter to decide if the task should be submitted for specific tokentask- Logic to run on the token- Returns:
- A list of SessionFuture instances
-
cleanupExpired
public void cleanupExpired()Cleanup the sessions whose lifetime has expired -
map
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
-