Class AuthenticatedClientUser


  • @ThreadSafe
    public final class AuthenticatedClientUser
    extends java.lang.Object
    An instance of this class represents a client user connecting to PlainSaslServer. It is maintained in a ThreadLocal variable based on the gRPC mechanism. For plain authentication, every authenticated channel injects its channel-Id to outgoing RPC calls via ChannelIdInjector. Server-side interceptor, AuthenticatedUserInjector, will intercept that Id before calling the service call implementation and store it in this class in a thread local storage.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static User get​(AlluxioConfiguration conf)
      Gets the User from the ThreadLocal variable.
      static java.lang.String getAuthMethod​(AlluxioConfiguration conf)
      Gets the connection authentication method from the ThreadLocal variable.
      static java.lang.String getClientUser​(AlluxioConfiguration conf)
      Gets the user name from the ThreadLocal variable.
      static java.lang.String getConnectionUser​(AlluxioConfiguration conf)
      Gets the connection user name from the ThreadLocal variable.
      static User getOrNull()  
      static void remove()
      Removes the User from the ThreadLocal variable.
      static void set​(User user)
      Sets User to the ThreadLocal variable.
      static void set​(java.lang.String userName)
      Creates a User and sets it to the ThreadLocal variable.
      static void setAuthMethod​(java.lang.String authMethod)
      Sets the connection authentication method to the ThreadLocal variable.
      static void setConnectionUser​(java.lang.String userName)
      Creates a connection User and sets it to the ThreadLocal variable.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • set

        public static void set​(java.lang.String userName)
        Creates a User and sets it to the ThreadLocal variable.
        Parameters:
        userName - the name of the client user
      • set

        public static void set​(User user)
        Sets User to the ThreadLocal variable.
        Parameters:
        user - the client user object
      • setConnectionUser

        public static void setConnectionUser​(java.lang.String userName)
        Creates a connection User and sets it to the ThreadLocal variable.
        Parameters:
        userName - the name of the connection user
      • setAuthMethod

        public static void setAuthMethod​(java.lang.String authMethod)
        Sets the connection authentication method to the ThreadLocal variable.
        Parameters:
        authMethod - the name of the authentication method
      • get

        public static User get​(AlluxioConfiguration conf)
                        throws java.io.IOException
        Gets the User from the ThreadLocal variable.
        Parameters:
        conf - Alluxio configuration
        Returns:
        the client user, null if the user is not present
        Throws:
        java.io.IOException
      • getOrNull

        public static User getOrNull()
        Returns:
        the user or null if the user is not set
      • getClientUser

        public static java.lang.String getClientUser​(AlluxioConfiguration conf)
                                              throws AccessControlException
        Gets the user name from the ThreadLocal variable.
        Parameters:
        conf - Alluxio configuration
        Returns:
        the client user in string
        Throws:
        AccessControlException - there is no authenticated user for this thread or the authentication is not enabled
      • getConnectionUser

        public static java.lang.String getConnectionUser​(AlluxioConfiguration conf)
                                                  throws AccessControlException
        Gets the connection user name from the ThreadLocal variable.
        Parameters:
        conf - Alluxio configuration
        Returns:
        the client user in string, null if the user is not present
        Throws:
        AccessControlException - if the authentication is not enabled
      • getAuthMethod

        public static java.lang.String getAuthMethod​(AlluxioConfiguration conf)
                                              throws AccessControlException
        Gets the connection authentication method from the ThreadLocal variable.
        Parameters:
        conf - Alluxio configuration
        Returns:
        the client user in string, null if the user is not present
        Throws:
        AccessControlException - if the authentication is not enabled
      • remove

        public static void remove()
        Removes the User from the ThreadLocal variable.