@ThreadSafe public final class AuthenticatedClientUser extends Object
PlainSaslServer
.
It is maintained in a ThreadLocal
variable based on the Thrift RPC mechanism.
TThreadPoolServer
allocates a thread to serve a connection
from client side and take back it when connection is closed. During the thread alive cycle,
all the RPC happens in this thread. These RPC methods implemented in server side could
get the client user by this class.Modifier and Type | Method and Description |
---|---|
static User |
get()
Gets the
User from the ThreadLocal variable. |
static String |
getClientUser()
Gets the user name from the
ThreadLocal variable. |
static User |
getOrNull() |
static void |
remove()
Removes the
User from the ThreadLocal variable. |
static void |
set(String userName)
Creates a
User and sets it to the ThreadLocal variable. |
static void |
set(User user)
Sets
User to the ThreadLocal variable. |
public static void set(String userName)
User
and sets it to the ThreadLocal
variable.userName
- the name of the client userpublic static void set(User user)
User
to the ThreadLocal
variable.user
- the client user objectpublic static User get() throws IOException
User
from the ThreadLocal
variable.IOException
public static User getOrNull()
public static String getClientUser() throws AccessControlException
ThreadLocal
variable.AccessControlException
- there is no authenticated user for this thread or
the authentication is not enabledpublic static void remove()
User
from the ThreadLocal
variable.Copyright © 2023. All Rights Reserved.