Package com.atlassian.confluence.user
Class AuthenticatedUserThreadLocal
java.lang.Object
com.atlassian.confluence.user.AuthenticatedUserThreadLocal
A simple ThreadLocal to store the currently authenticated user. This can be used when the user comes
from something other than the web interface (i.e. SOAP).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AutoCloseable
asUser
(ConfluenceUser user) Deprecated.static void
asUser
(ConfluenceUser user, Runnable task) Executes the givenRunnable
with the given thread-local User.static <T> T
asUser
(ConfluenceUser user, Callable<T> task) Executes the givenCallable
with the given thread-local User.static ConfluenceUser
get()
static com.atlassian.user.User
getUser()
Deprecated.since 5.2.static String
static boolean
static void
reset()
Remove any user from the current contextstatic void
set
(ConfluenceUser user) static void
setUser
(com.atlassian.user.User user) Deprecated.since 5.2.
-
Constructor Details
-
AuthenticatedUserThreadLocal
public AuthenticatedUserThreadLocal()
-
-
Method Details
-
set
- Since:
- 5.2
-
setUser
Deprecated.since 5.2. Useset(ConfluenceUser)
instead. -
get
- Returns:
- the currently authenticated user, null if anonymous user
- Since:
- 5.2
-
getUser
Deprecated.since 5.2. Useget()
instead.- Returns:
- the currently authenticated user, null if anonymous user
-
reset
public static void reset()Remove any user from the current context -
getUsername
-
isAnonymousUser
public static boolean isAnonymousUser()- Returns:
- true if anonymous user
- Since:
- 5.3.1
-
asUser
Deprecated.since 7.14 PreferasUser(ConfluenceUser, Runnable)
orasUser(ConfluenceUser, Callable)
-
asUser
Executes the givenRunnable
with the given thread-local User.- Since:
- 7.14
-
asUser
Executes the givenCallable
with the given thread-local User.- Throws:
Exception
- Since:
- 7.14
-
asUser(ConfluenceUser, Runnable)
orasUser(ConfluenceUser, Callable)