java.lang.Object
com.peterphi.std.guice.web.rest.auth.oauth2.OAuthUser
All Implemented Interfaces:
CurrentUser, GuiceLifecycleListener

public class OAuthUser extends Object implements CurrentUser, GuiceLifecycleListener
  • Constructor Details

    • OAuthUser

      public OAuthUser()
  • Method Details

    • getAuthType

      public String getAuthType()
      Description copied from interface: CurrentUser
      Return the type of authentication used
      Specified by:
      getAuthType in interface CurrentUser
      Returns:
    • isAnonymous

      public boolean isAnonymous()
      Description copied from interface: CurrentUser
      Return true if the user is not authenticated
      Specified by:
      isAnonymous in interface CurrentUser
      Returns:
      true if the user is not authenticated, false if the user is authenticated
    • isDelegated

      public boolean isDelegated()
      Description copied from interface: CurrentUser
      Return true if the user was authenticated by a delegated access token; this is important to know when a service will not talk to a user directly but will talk to services acting on behalf of the user.
      Specified by:
      isDelegated in interface CurrentUser
      Returns:
    • isService

      public boolean isService()
      Description copied from interface: CurrentUser
      Returns true if the calling user is a service user. This indicates that a call is being made by a service directly, not on behalf of a particular user.
      Specified by:
      isService in interface CurrentUser
      Returns:
    • getName

      public String getName()
      Description copied from interface: CurrentUser
      Get the name of the current user
      Specified by:
      getName in interface CurrentUser
      Returns:
      the name if known, otherwise null
    • getUsername

      public String getUsername()
      Description copied from interface: CurrentUser
      Get the username of the current user
      Specified by:
      getUsername in interface CurrentUser
      Returns:
      the username if known, otherwise null if not logged in (i.e. anonymous)
    • hasRole

      public boolean hasRole(String role)
      Description copied from interface: CurrentUser
      Return whether the user has the named role
      Specified by:
      hasRole in interface CurrentUser
      Parameters:
      role - the role name to test
      Returns:
      true if the user has that role, otherwise false
    • getExpires

      public org.joda.time.DateTime getExpires()
      Description copied from interface: CurrentUser
      Get the instant when the login must expire (or null if it will never expire or has not come through an authentication system that uses expiration)
      Specified by:
      getExpires in interface CurrentUser
      Returns:
    • getRoles

      public Set<String> getRoles()
      Description copied from interface: CurrentUser
      Get all the verified role claims for this user. The returned collection MUST NOT be modified. Returns an empty collection if no role list data is available.
      Specified by:
      getRoles in interface CurrentUser
      Returns:
    • getClaims

      public Map<String,Object> getClaims()
      Description copied from interface: CurrentUser
      Get all the (verified) claims for this user. The returned collection MUST NOT be modified. Returns an empty collection if no claims were made
      Specified by:
      getClaims in interface CurrentUser
      Returns:
    • getSimpleClaim

      public String getSimpleClaim(String name)
      Description copied from interface: CurrentUser
      Get a simple text/numeric claim as a String. Returns null if no such claim was made.
      Specified by:
      getSimpleClaim in interface CurrentUser
      Returns:
    • getSimpleListClaim

      public List<String> getSimpleListClaim(String name)
      Description copied from interface: CurrentUser
      Get a List of simple text/numeric claims. Returns null if no such claim was made.
      Specified by:
      getSimpleListClaim in interface CurrentUser
      Returns:
    • getSimpleSetClaim

      public Set<String> getSimpleSetClaim(String name)
      Description copied from interface: CurrentUser
      Get a Set of simple text/numeric claims. Returns null if no such claim was made.
      Specified by:
      getSimpleSetClaim in interface CurrentUser
      Returns:
    • format

      public String format(org.joda.time.DateTime date)
      Description copied from interface: CurrentUser
      Return a string version of the provided timestamp in the user's preferred timezone and time format
      Specified by:
      format in interface CurrentUser
      Returns:
      null if the input is null
    • getDateFormatter

      public org.joda.time.format.DateTimeFormatter getDateFormatter()
      Specified by:
      getDateFormatter in interface CurrentUser
    • format

      public String format(Instant date)
      Description copied from interface: CurrentUser
      Return a string version of the provided timestamp in the user's preferred timezone and time format
      Specified by:
      format in interface CurrentUser
      Returns:
      null if the input is null
    • format

      public String format(Date date)
      Description copied from interface: CurrentUser
      Return a string version of the provided timestamp in the user's preferred timezone and time format
      Specified by:
      format in interface CurrentUser
      Returns:
      null if the input is null
    • getAccessRefuser

      public AccessRefuser getAccessRefuser()
      Specified by:
      getAccessRefuser in interface CurrentUser
    • getOrCreateDelegatedToken

      public String getOrCreateDelegatedToken()
    • postConstruct

      public void postConstruct()
      Description copied from interface: GuiceLifecycleListener
      Called after this object has been fully and successfully constructed
      Specified by:
      postConstruct in interface GuiceLifecycleListener
    • toString

      public String toString()
      Overrides:
      toString in class Object