Package com.atlassian.confluence.user
Class AuthenticatedUserThreadLocal
- java.lang.Object
-
- com.atlassian.confluence.user.AuthenticatedUserThreadLocal
-
public class AuthenticatedUserThreadLocal extends Object
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 Constructor Description AuthenticatedUserThreadLocal()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static AutoCloseable
asUser(ConfluenceUser user)
Deprecated.since 7.14 PreferasUser(ConfluenceUser, Runnable)
orasUser(ConfluenceUser, Callable)
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
getUsername()
static boolean
isAnonymousUser()
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.
-
-
-
Method Detail
-
set
public static void set(ConfluenceUser user)
- Since:
- 5.2
-
setUser
@Deprecated public static void setUser(com.atlassian.user.User user)
Deprecated.since 5.2. Useset(ConfluenceUser)
instead.
-
get
public static ConfluenceUser get()
- Returns:
- the currently authenticated user, null if anonymous user
- Since:
- 5.2
-
getUser
@Deprecated public static com.atlassian.user.User 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
public static String getUsername()
-
isAnonymousUser
public static boolean isAnonymousUser()
- Returns:
- true if anonymous user
- Since:
- 5.3.1
-
asUser
@Deprecated public static AutoCloseable asUser(ConfluenceUser user)
Deprecated.since 7.14 PreferasUser(ConfluenceUser, Runnable)
orasUser(ConfluenceUser, Callable)
-
asUser
public static void asUser(ConfluenceUser user, Runnable task)
Executes the givenRunnable
with the given thread-local User.- Since:
- 7.14
-
asUser
public static <T> T asUser(ConfluenceUser user, Callable<T> task) throws Exception
Executes the givenCallable
with the given thread-local User.- Throws:
Exception
- Since:
- 7.14
-
-