Class OAuthUser
java.lang.Object
com.peterphi.std.guice.web.rest.auth.oauth2.OAuthUser
- All Implemented Interfaces:
CurrentUser
,GuiceLifecycleListener
-
Field Summary
Fields inherited from interface com.peterphi.std.guice.common.auth.iface.CurrentUser
DEFAULT_DATE_FORMAT, DEFAULT_DATE_FORMAT_STRING, DEFAULT_TIMEZONE, ISO_DATE_FORMAT_STRING, ROLE_ADMIN, ROLE_AUTHENTICATED, ROLE_DELEGATED, ROLE_SERVICE_CALL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturn a string version of the provided timestamp in the user's preferred timezone and time formatReturn a string version of the provided timestamp in the user's preferred timezone and time formatformat
(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.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.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.Get 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.void
Called after this object has been fully and successfully constructedtoString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.peterphi.std.guice.common.auth.iface.CurrentUser
getTimeZone
-
Constructor Details
-
OAuthUser
public OAuthUser()
-
-
Method Details
-
getAuthType
Description copied from interface:CurrentUser
Return the type of authentication used- Specified by:
getAuthType
in interfaceCurrentUser
- Returns:
-
isAnonymous
public boolean isAnonymous()Description copied from interface:CurrentUser
Return true if the user is not authenticated- Specified by:
isAnonymous
in interfaceCurrentUser
- 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 interfaceCurrentUser
- 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 interfaceCurrentUser
- Returns:
-
getName
Description copied from interface:CurrentUser
Get the name of the current user- Specified by:
getName
in interfaceCurrentUser
- Returns:
- the name if known, otherwise null
-
getUsername
Description copied from interface:CurrentUser
Get the username of the current user- Specified by:
getUsername
in interfaceCurrentUser
- Returns:
- the username if known, otherwise null if not logged in (i.e. anonymous)
-
hasRole
Description copied from interface:CurrentUser
Return whether the user has the named role- Specified by:
hasRole
in interfaceCurrentUser
- 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 interfaceCurrentUser
- Returns:
-
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 interfaceCurrentUser
- Returns:
-
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 interfaceCurrentUser
- Returns:
-
getSimpleClaim
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 interfaceCurrentUser
- Returns:
-
getSimpleListClaim
Description copied from interface:CurrentUser
Get aList
of simple text/numeric claims. Returns null if no such claim was made.- Specified by:
getSimpleListClaim
in interfaceCurrentUser
- Returns:
-
getSimpleSetClaim
Description copied from interface:CurrentUser
Get aSet
of simple text/numeric claims. Returns null if no such claim was made.- Specified by:
getSimpleSetClaim
in interfaceCurrentUser
- Returns:
-
format
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 interfaceCurrentUser
- Returns:
- null if the input is null
-
getDateFormatter
public org.joda.time.format.DateTimeFormatter getDateFormatter()- Specified by:
getDateFormatter
in interfaceCurrentUser
-
format
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 interfaceCurrentUser
- Returns:
- null if the input is null
-
format
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 interfaceCurrentUser
- Returns:
- null if the input is null
-
getAccessRefuser
- Specified by:
getAccessRefuser
in interfaceCurrentUser
-
getOrCreateDelegatedToken
-
postConstruct
public void postConstruct()Description copied from interface:GuiceLifecycleListener
Called after this object has been fully and successfully constructed- Specified by:
postConstruct
in interfaceGuiceLifecycleListener
-
toString
-