Package org.gcube.oidc.rest
Class JWTToken
- java.lang.Object
-
- org.gcube.oidc.rest.JWTToken
-
- All Implemented Interfaces:
Serializable
public class JWTToken extends Object implements Serializable
JWT token wrapper.- Author:
- Mauro Mugnaini
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringACCOUNT_RESOURCEAccount resource.protected static org.slf4j.LoggerloggerLogger.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static JWTTokenfromString(String tokenString)Creates aJWTTokenfrom a string.StringgetAccessTokenAsBearer()Returns the access token as bearer.StringgetAccessTokenString()Returns the access token string.StringgetAsBearer()Deprecated.UsegetAccessTokenAsBearer()method instead.List<String>getAud()Returns the aud.List<String>getAuthorizationPermissionRSNameResourceScopes(String rsname)Returns the authorization permission RS name resource scopes.List<String>getAuthorizationPermissionRSNames()Returns the authorization permission RS names.Map<String,List<String>>getAuthorizationPermissionRSNameToResourceScopesMap()Returns the authorization permission RS name to resource scopes map.protected org.json.simple.JSONArraygetAuthorizationPermissions()Returns the authorization permissions.StringgetAzp()Returns the azp.StringgetD4SContext()Returns thed4s_context.StringgetDisplayName()Returns the name.StringgetEmail()Returns the email.LonggetExp()Returns the exp.CalendargetExpAsCalendar()Returns the exp as calendar.DategetExpAsDate()Returns the exp as date.StringgetFamily()Returns the family name.StringgetGiven()Returns the given name.StringgetJti()Returns the jti.org.json.simple.JSONObjectgetPayload()Returns the payload.StringgetRaw()Returns the raw token string.org.json.simple.JSONObjectgetRefreshToken()Returns the refresh token.LonggetRefreshTokenExp()Returns the refresh token exp.DategetRefreshTokenExpAsDate()Returns the refresh token exp as date.StringgetRefreshTokenString()Returns the refresh token string.protected org.json.simple.JSONObjectgetResourceAccess()Returns the resource access.protected Iterator<String>getResourceAccessKeys()Returns the resource access keys.List<String>getResourceAccessRoles(String resource)Returns the resource access roles.Map<String,List<String>>getResourceNameToAccessRolesMap(List<String> resourcesToSkip)Returns the resource name to access roles map.StringgetSub()Returns the sub.StringgetTokenEssentials()Returns the token essentials.StringgetUserName()Returns the preferred username.booleanhasRefreshToken()Checks if a refresh token exists.booleanisExpired()Checks if the token is expired.booleanisRefreshTokenExpired()Checks if the refresh token is expired.StringtoString()
-
-
-
Field Detail
-
logger
protected static org.slf4j.Logger logger
Logger.
-
ACCOUNT_RESOURCE
public static final String ACCOUNT_RESOURCE
Account resource.- See Also:
- Constant Field Values
-
-
Method Detail
-
fromString
public static JWTToken fromString(String tokenString)
Creates aJWTTokenfrom a string.- Parameters:
tokenString- the token string.- Returns:
- the
JWTToken.
-
getRaw
public String getRaw()
Returns the raw token string.- Returns:
- the raw token string.
-
getAccessTokenString
public String getAccessTokenString()
Returns the access token string.- Returns:
- the access token string.
-
getRefreshTokenString
public String getRefreshTokenString()
Returns the refresh token string.- Returns:
- the refresh token string.
-
getAsBearer
@Deprecated public String getAsBearer()
Deprecated.UsegetAccessTokenAsBearer()method instead.Returns the access token as bearer.- Returns:
- the access token as bearer.
-
getAccessTokenAsBearer
public String getAccessTokenAsBearer()
Returns the access token as bearer.- Returns:
- the access token as bearer.
-
getPayload
public org.json.simple.JSONObject getPayload()
Returns the payload.- Returns:
- the payload.
-
hasRefreshToken
public boolean hasRefreshToken()
Checks if a refresh token exists.- Returns:
- true if a refresh token exists, false otherwise.
-
getRefreshToken
public org.json.simple.JSONObject getRefreshToken()
Returns the refresh token.- Returns:
- the refresh token.
-
getAzp
public String getAzp()
Returns the azp.- Returns:
- the azp.
-
getExp
public Long getExp()
Returns the exp.- Returns:
- the exp.
-
getRefreshTokenExp
public Long getRefreshTokenExp()
Returns the refresh token exp.- Returns:
- the refresh token exp.
-
getExpAsDate
public Date getExpAsDate()
Returns the exp as date.- Returns:
- the exp as date.
-
getRefreshTokenExpAsDate
public Date getRefreshTokenExpAsDate()
Returns the refresh token exp as date.- Returns:
- the refresh token exp as date.
-
getExpAsCalendar
public Calendar getExpAsCalendar()
Returns the exp as calendar.- Returns:
- the exp as calendar.
-
isExpired
public boolean isExpired()
Checks if the token is expired.- Returns:
- true if the token is expired, false otherwise.
-
isRefreshTokenExpired
public boolean isRefreshTokenExpired()
Checks if the refresh token is expired.- Returns:
- true if the refresh token is expired, false otherwise.
-
getJti
public String getJti()
Returns the jti.- Returns:
- the jti.
-
getSub
public String getSub()
Returns the sub.- Returns:
- the sub.
-
getEmail
public String getEmail()
Returns the email.- Returns:
- the email.
-
getFamily
public String getFamily()
Returns the family name.- Returns:
- the family name.
-
getGiven
public String getGiven()
Returns the given name.- Returns:
- the given name.
-
getUserName
public String getUserName()
Returns the preferred username.- Returns:
- the preferred username.
-
getDisplayName
public String getDisplayName()
Returns the name.- Returns:
- the name.
-
getResourceAccess
protected org.json.simple.JSONObject getResourceAccess()
Returns the resource access.- Returns:
- the resource access.
-
getResourceAccessKeys
protected Iterator<String> getResourceAccessKeys()
Returns the resource access keys.- Returns:
- the resource access keys.
-
getResourceAccessRoles
public List<String> getResourceAccessRoles(String resource)
Returns the resource access roles.- Parameters:
resource- the resource.- Returns:
- the roles.
-
getResourceNameToAccessRolesMap
public Map<String,List<String>> getResourceNameToAccessRolesMap(List<String> resourcesToSkip)
Returns the resource name to access roles map.- Parameters:
resourcesToSkip- the resources to skip.- Returns:
- the map.
-
getAuthorizationPermissions
protected org.json.simple.JSONArray getAuthorizationPermissions()
Returns the authorization permissions.- Returns:
- the permissions.
-
getAuthorizationPermissionRSNames
public List<String> getAuthorizationPermissionRSNames()
Returns the authorization permission RS names.- Returns:
- the names.
-
getAuthorizationPermissionRSNameResourceScopes
public List<String> getAuthorizationPermissionRSNameResourceScopes(String rsname)
Returns the authorization permission RS name resource scopes.- Parameters:
rsname- the RS name.- Returns:
- the scopes.
-
getAuthorizationPermissionRSNameToResourceScopesMap
public Map<String,List<String>> getAuthorizationPermissionRSNameToResourceScopesMap()
Returns the authorization permission RS name to resource scopes map.- Returns:
- the map.
-
getD4SContext
public String getD4SContext()
Returns thed4s_context.- Returns:
- the d4s_context or
nullif the dynamic scope is not used.
-
getTokenEssentials
public String getTokenEssentials()
Returns the token essentials.- Returns:
- the token essentials.
-
-