Class ThreadLocalSubjectStore
java.lang.Object
com.svenruppert.jsentinel.standalone.ThreadLocalSubjectStore
- All Implemented Interfaces:
com.svenruppert.jsentinel.authorization.api.SubjectStore
public final class ThreadLocalSubjectStore
extends Object
implements com.svenruppert.jsentinel.authorization.api.SubjectStore
SubjectStore that keeps the current subject in a thread-local
map keyed by subject class. The default for standalone (single-user
desktop / CLI) applications.
Background-thread propagation is the caller's responsibility: pass the
subject (or a Runnable wrapper that re-binds it) when handing
work off to executors, JavaFX Tasks, etc. The store does not
inherit across threads — by design, so a fork of a JVM process never
silently leaks a security context.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears every binding on the current thread.<T> Optional<T> currentSubject(Class<T> subjectType) <T> voiddeleteCurrentSubject(Class<T> subjectType) <T> voidsetCurrentSubject(T subject, Class<T> subjectType) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.svenruppert.jsentinel.authorization.api.SubjectStore
hasSubject
-
Constructor Details
-
ThreadLocalSubjectStore
public ThreadLocalSubjectStore()Creates an empty store. Registered viaMETA-INF/services.
-
-
Method Details
-
currentSubject
-
setCurrentSubject
- Specified by:
setCurrentSubjectin interfacecom.svenruppert.jsentinel.authorization.api.SubjectStore
-
deleteCurrentSubject
- Specified by:
deleteCurrentSubjectin interfacecom.svenruppert.jsentinel.authorization.api.SubjectStore
-
clear
public void clear()Clears every binding on the current thread. Intended for tests and for application shutdown paths.
-