Interface SecurityService


public interface SecurityService
Provides access to the current user's username and roles, if any.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the organization associated with the current thread context.
    Gets the current user, or the local organization's anonymous user if the user has not been authenticated.
    Gets the current user's IP or null if unable to determine the User's IP.
    void
    Sets the organization for the calling thread.
    void
    setUser(User user)
    Sets the current thread's user context to another user.
    void
    setUserIP(String userIP)
    Sets the current thread's user's IP address.
  • Method Details

    • getUser

      User getUser() throws IllegalStateException
      Gets the current user, or the local organization's anonymous user if the user has not been authenticated.
      Returns:
      the user
      Throws:
      IllegalStateException - if no organization is set in the security context
    • getOrganization

      Organization getOrganization()
      Gets the organization associated with the current thread context.
      Returns:
      the organization
    • getUserIP

      String getUserIP()
      Gets the current user's IP or null if unable to determine the User's IP.
      Returns:
      The current user's IP.
    • setOrganization

      void setOrganization(Organization organization)
      Sets the organization for the calling thread.
      Parameters:
      organization - the organization
    • setUser

      void setUser(User user)
      Sets the current thread's user context to another user. This is useful when spawning new threads that must contain the parent thread's user context.
      Parameters:
      user - the user to set for the current user context
    • setUserIP

      void setUserIP(String userIP)
      Sets the current thread's user's IP address.
      Parameters:
      userIP - The IP address of the user.