Interface CurrentUser

All Known Subinterfaces:
UserLogin
All Known Implementing Classes:
OAuthUser

public interface CurrentUser
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.joda.time.format.DateTimeFormatter
     
    static final String
     
    static final String
     
    static final String
     
    static final String
    Standard name for role conveying administrative privileges
    static final String
    Special role string indicating that the user is logged in
    static final String
    Special role string indicating that the user was authenticated via a Delegate Token, and is not calling in directly
    This is important when a service will not talk to a user directly but will talk to services acting on behalf of the user
    static final String
    Special role string indicating that this is a service call, not a direct user request.
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    Return a string version of the provided timestamp in the user's preferred timezone and time format
    default String
    format(Date date)
    Return a string version of the provided timestamp in the user's preferred timezone and time format
    default String
    format(org.joda.time.DateTime date)
    Return a string version of the provided timestamp in the user's preferred timezone and time format
     
    Return the type of authentication used
    Get all the (verified) claims for this user.
    default org.joda.time.format.DateTimeFormatter
     
    org.joda.time.DateTime
    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)
    Get the name of the current user
    Get all the verified role claims for this user.
    default String
    Get a simple text/numeric claim as a String.
    default List<String>
    Get a List of simple text/numeric claims.
    default Set<String>
    Get a Set of simple text/numeric claims.
    default String
    Return the user's timezone
    Get the username of the current user
    boolean
    Return whether the user has the named role
    boolean
    Return true if the user is not authenticated
    boolean
    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.
    boolean
    Returns true if the calling user is a service user.
  • Field Details

    • DEFAULT_DATE_FORMAT_STRING

      static final String DEFAULT_DATE_FORMAT_STRING
      See Also:
    • ISO_DATE_FORMAT_STRING

      static final String ISO_DATE_FORMAT_STRING
      See Also:
    • DEFAULT_TIMEZONE

      static final String DEFAULT_TIMEZONE
      See Also:
    • DEFAULT_DATE_FORMAT

      static final org.joda.time.format.DateTimeFormatter DEFAULT_DATE_FORMAT
    • ROLE_AUTHENTICATED

      static final String ROLE_AUTHENTICATED
      Special role string indicating that the user is logged in
      See Also:
    • ROLE_DELEGATED

      static final String ROLE_DELEGATED
      Special role string indicating that the user was authenticated via a Delegate Token, and is not calling in directly
      This is important when a service will not talk to a user directly but will talk to services acting on behalf of the user
      See Also:
    • ROLE_SERVICE_CALL

      static final String ROLE_SERVICE_CALL
      Special role string indicating that this is a service call, not a direct user request. This is important when a service will not talk to a user directly but will talk to services acting on behalf of the user
      See Also:
    • ROLE_ADMIN

      static final String ROLE_ADMIN
      Standard name for role conveying administrative privileges
      See Also:
  • Method Details

    • getAuthType

      String getAuthType()
      Return the type of authentication used
      Returns:
    • isAnonymous

      boolean isAnonymous()
      Return true if the user is not authenticated
      Returns:
      true if the user is not authenticated, false if the user is authenticated
    • isDelegated

      boolean isDelegated()
      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.
      Returns:
    • isService

      boolean isService()
      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.
      Returns:
    • getName

      String getName()
      Get the name of the current user
      Returns:
      the name if known, otherwise null
    • getUsername

      String getUsername()
      Get the username of the current user
      Returns:
      the username if known, otherwise null if not logged in (i.e. anonymous)
    • hasRole

      boolean hasRole(String role)
      Return whether the user has the named role
      Parameters:
      role - the role name to test
      Returns:
      true if the user has that role, otherwise false
    • getExpires

      org.joda.time.DateTime getExpires()
      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)
      Returns:
    • getRoles

      Collection<String> getRoles()
      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.
      Returns:
    • getClaims

      Map<String,Object> getClaims()
      Get all the (verified) claims for this user. The returned collection MUST NOT be modified. Returns an empty collection if no claims were made
      Returns:
    • getSimpleClaim

      default String getSimpleClaim(String name)
      Get a simple text/numeric claim as a String. Returns null if no such claim was made.
      Parameters:
      name -
      Returns:
    • getSimpleListClaim

      default List<String> getSimpleListClaim(String name)
      Get a List of simple text/numeric claims. Returns null if no such claim was made.
      Parameters:
      name -
      Returns:
    • getSimpleSetClaim

      default Set<String> getSimpleSetClaim(String name)
      Get a Set of simple text/numeric claims. Returns null if no such claim was made.
      Parameters:
      name -
      Returns:
    • format

      default String format(org.joda.time.DateTime date)
      Return a string version of the provided timestamp in the user's preferred timezone and time format
      Parameters:
      date -
      Returns:
      null if the input is null
    • format

      default String format(Instant date)
      Return a string version of the provided timestamp in the user's preferred timezone and time format
      Parameters:
      date -
      Returns:
      null if the input is null
    • format

      default String format(Date date)
      Return a string version of the provided timestamp in the user's preferred timezone and time format
      Parameters:
      date -
      Returns:
      null if the input is null
    • getDateFormatter

      default org.joda.time.format.DateTimeFormatter getDateFormatter()
    • getTimeZone

      default String getTimeZone()
      Return the user's timezone
      Returns:
      e.g. Europe/London
    • getAccessRefuser

      AccessRefuser getAccessRefuser()