Interface CurrentUser
- All Known Subinterfaces:
UserLogin
- All Known Implementing Classes:
OAuthUser
public interface CurrentUser
-
Field Summary
Modifier and TypeFieldDescriptionstatic final org.joda.time.format.DateTimeFormatter
static final String
static final String
static final String
static final String
Standard name for role conveying administrative privilegesstatic final String
Special role string indicating that the user is logged instatic 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 userstatic final String
Special role string indicating that this is a service call, not a direct user request. -
Method Summary
Modifier and TypeMethodDescriptiondefault String
Return a string version of the provided timestamp in the user's preferred timezone and time formatdefault String
Return a string version of the provided timestamp in the user's preferred timezone and time formatdefault String
format
(org.joda.time.DateTime date) Return a string version of the provided timestamp in the user's preferred timezone and time formatReturn the type of authentication usedGet 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)getName()
Get the name of the current usergetRoles()
Get all the verified role claims for this user.default String
getSimpleClaim
(String name) Get a simple text/numeric claim as a String.getSimpleListClaim
(String name) Get aList
of simple text/numeric claims.getSimpleSetClaim
(String name) Get aSet
of simple text/numeric claims.default String
Return the user's timezoneGet the username of the current userboolean
Return whether the user has the named roleboolean
Return true if the user is not authenticatedboolean
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
- See Also:
-
ISO_DATE_FORMAT_STRING
- See Also:
-
DEFAULT_TIMEZONE
- See Also:
-
DEFAULT_DATE_FORMAT
static final org.joda.time.format.DateTimeFormatter DEFAULT_DATE_FORMAT -
ROLE_AUTHENTICATED
Special role string indicating that the user is logged in- See Also:
-
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
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
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
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
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
Get a simple text/numeric claim as a String. Returns null if no such claim was made.- Parameters:
name
-- Returns:
-
getSimpleListClaim
Get aList
of simple text/numeric claims. Returns null if no such claim was made.- Parameters:
name
-- Returns:
-
getSimpleSetClaim
Get aSet
of simple text/numeric claims. Returns null if no such claim was made.- Parameters:
name
-- Returns:
-
format
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
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
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
Return the user's timezone- Returns:
- e.g. Europe/London
-
getAccessRefuser
AccessRefuser getAccessRefuser()
-