Class User

    • Constructor Detail

      • User

        public User​(int contextId,
                    java.lang.String name)
        Instantiates a new user.
        Parameters:
        contextId - the context id
        name - the name
      • User

        public User​(int contextId,
                    java.lang.String name,
                    int id)
        Instantiates a new user.
        Parameters:
        contextId - the context id
        name - the name
        id - the id
    • Method Detail

      • getName

        public java.lang.String getName()
        Gets the name of the user.
        Returns:
        the name
      • getContextId

        public int getContextId()
        Gets the context id.
        Returns:
        the context id
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getContext

        public Context getContext()
        Lazy loader for getting the context to which this user corresponds.
        Returns:
        the context
      • getId

        public int getId()
        Gets the id.
        Returns:
        the id
      • processMessageToMatchUser

        public void processMessageToMatchUser​(HttpMessage message)
        Modifies a message so its Request Header/Body matches the web session corresponding to this user.
        Parameters:
        message - the message
      • processMessageToMatchAuthenticatedSession

        public void processMessageToMatchAuthenticatedSession​(HttpMessage message)
        Modifies a message so its Request Header/Body matches the web session corresponding to this user.
        Parameters:
        message - the message
      • getAuthenticationCredentials

        public AuthenticationCredentials getAuthenticationCredentials()
        Gets the configured authentication credentials of this user.
        Returns:
        the authentication credentials
      • setAuthenticationCredentials

        public void setAuthenticationCredentials​(AuthenticationCredentials authenticationCredentials)
        Sets the authentication credentials for the user. These will be used to authenticate the user, if necessary.
        Parameters:
        authenticationCredentials - the new authentication credentials
      • requiresAuthentication

        public boolean requiresAuthentication()
        Checks if an authentication is needed and will be performed at the next call to processMessageToMatchUser(HttpMessage).
        Returns:
        true, if requires authentication
      • queueAuthentication

        public void queueAuthentication​(HttpMessage unauthenticatedMessage)
        Resets the existing authenticated session, causing subsequent calls to processMessageToMatchUser(HttpMessage) to reauthenticate.
        Parameters:
        unauthenticatedMessage - the unauthenticated message
      • getLastSuccessfulAuthTime

        @Deprecated
        protected long getLastSuccessfulAuthTime()
        Deprecated.
        use #getAuthenticationState().getLastSuccessfulAuthTime()
        Gets the last successful auth time.
        Returns:
        the time of last successful authentication
      • isAuthenticated

        public boolean isAuthenticated​(HttpMessage msg)
        Checks if the response received by the Http Message corresponds to this user.
        Parameters:
        msg - the msg
        Returns:
        true, if is authenticated
      • encode

        public static java.lang.String encode​(User user)
        Encodes the User in a String. Fields that contain strings are Base64 encoded.
        Parameters:
        user - the user
        Returns:
        the string
      • decode

        public static User decode​(int contextId,
                                  java.lang.String encodedString)
        Decodes an User from an encoded string. The string provided as input should have been obtained through calls to encode(User).
        Parameters:
        contextId - the ID of the context the user belongs to
        encodedString - the encoded string
        Returns:
        the user
      • decode

        protected static User decode​(int contextId,
                                     java.lang.String encodedString,
                                     ExtensionAuthentication authenticationExtension)
        Helper method for decoding an user from an encoded string. See decode(int, String).
        Parameters:
        contextId - the ID of the context the user belongs to
        encodedString - the encoded string
        authenticationExtension - the authentication extension
        Returns:
        the user
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class Enableable
      • setName

        public void setName​(java.lang.String name)
        Sets the name.
        Parameters:
        name - the new name
      • getCorrespondingHttpState

        public org.apache.commons.httpclient.HttpState getCorrespondingHttpState()
      • getAuthenticatedSession

        public WebSession getAuthenticatedSession()
      • setAuthenticatedSession

        public void setAuthenticatedSession​(WebSession session)
      • getAuthenticationState

        public AuthenticationState getAuthenticationState()
        Returns the authentication state for this user.
        Returns:
        the authentication state
        Since:
        2.10.0