Package org.gcube.common.iam
Interface IAMResponse
-
- All Known Implementing Classes:
AbstractIAMResponse,D4ScienceIAMClientAuthn,D4ScienceIAMClientAuthn4Client,D4ScienceIAMClientAuthn4User,D4ScienceIAMClientAuthz,OIDCBearerAuth
public interface IAMResponse
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancanBeRefreshed()Check if the current response can be refreshedorg.gcube.common.keycloak.model.AccessTokengetAccessToken()Returns the access token in the response.StringgetAccessTokenString()Returns the access token in the response as string.StringgetContactOrganization()Returns the client's contact organization from the tokenStringgetContactPerson()Returns the client's contact person from the tokenSet<String>getContextRoles()Returns the resource roles for the resource specified in the token contextSet<String>getGlobalRoles()Returns the realm roles in the tokenStringgetName()Returns the client's name from the tokenSet<String>getResourceRoles(String resource)Returns the resource roles for the resource specified in the resource parameterSet<String>getRoles()Returns all the roles, realm and from all the resources in the token in the same setbooleanisAccessTokenValid()Quick way to check if the access token is valid by checking the digital signature and the token expirationbooleanisAccessTokenValid(boolean checkExpiration)Quick way to check if the access token is valid by checking the digital signature and the token expiration if thecheckExpirationparameter istruebooleanisExpired()Check if the current response is expiredbooleanisRefreshTokenValid()Quick way to check if the refresh token present in the current response and it is valid by checking the digital signature and the token expirationbooleanisRefreshTokenValid(boolean checkExpiration)Quick way to check if the refresh token present in the current response and it is valid by checking the digital signature and the token expiration if thecheckExpirationparameter istruevoidrefresh()Refreshes the current response, new data can be obtained again with accessors.voidverifyAccessToken()Verifies the access token integrity and validity; token digital signature and expiration are reported via specific exceptions.voidverifyRefreshToken()Verifies the refresh token integrity and validity; token digital signature and expiration are reported via specific exceptions.
-
-
-
Method Detail
-
getAccessToken
org.gcube.common.keycloak.model.AccessToken getAccessToken() throws D4ScienceIAMClientExceptionReturns the access token in the response.- Returns:
- The access token
- Throws:
D4ScienceIAMClientException- if something goes wrong during the token decoding or JSON parsing
-
getAccessTokenString
String getAccessTokenString()
Returns the access token in the response as string.- Returns:
- The access token as string
-
isExpired
boolean isExpired() throws D4ScienceIAMClientExceptionCheck if the current response is expired- Returns:
trueif the response is expired,falseotherwise- Throws:
D4ScienceIAMClientException- if something goes wrong during the token decoding or JSON parsing
-
canBeRefreshed
boolean canBeRefreshed() throws D4ScienceIAMClientExceptionCheck if the current response can be refreshed- Returns:
trueif the response can be refreshed,falseotherwise- Throws:
D4ScienceIAMClientException- if something goes wrong during the token decoding or JSON parsing
-
refresh
void refresh() throws D4ScienceIAMClientExceptionRefreshes the current response, new data can be obtained again with accessors.- Throws:
D4ScienceIAMClientException- if something goes wrong during the token refresh
-
getContextRoles
Set<String> getContextRoles() throws D4ScienceIAMClientException
Returns the resource roles for the resource specified in the token context- Returns:
- the token context's roles
- Throws:
D4ScienceIAMClientException- if something goes wrong during the token decoding or JSON parsing
-
getResourceRoles
Set<String> getResourceRoles(String resource) throws D4ScienceIAMClientException
Returns the resource roles for the resource specified in the resource parameter- Parameters:
resource- the resource of which obtain the roles- Returns:
- the roles for the resource
- Throws:
D4ScienceIAMClientException- if something goes wrong during the token decoding or JSON parsing
-
getRoles
Set<String> getRoles() throws D4ScienceIAMClientException
Returns all the roles, realm and from all the resources in the token in the same set- Returns:
- the union of all the roles in the token
- Throws:
D4ScienceIAMClientException- if something goes wrong during the token decoding or JSON parsing
-
getGlobalRoles
Set<String> getGlobalRoles() throws D4ScienceIAMClientException
Returns the realm roles in the token- Returns:
- the realm roles
- Throws:
D4ScienceIAMClientException- if something goes wrong during the token decoding or JSON parsing
-
getContactOrganization
String getContactOrganization() throws D4ScienceIAMClientException
Returns the client's contact organization from the token- Returns:
- the contact organization string
- Throws:
D4ScienceIAMClientException- if something goes wrong during the token decoding or JSON parsing
-
getContactPerson
String getContactPerson() throws D4ScienceIAMClientException
Returns the client's contact person from the token- Returns:
- the contact person string
- Throws:
D4ScienceIAMClientException- if something goes wrong during the token decoding or JSON parsing
-
getName
String getName() throws D4ScienceIAMClientException
Returns the client's name from the token- Returns:
- the name string
- Throws:
D4ScienceIAMClientException- if something goes wrong during the token decoding or JSON parsing
-
isAccessTokenValid
boolean isAccessTokenValid() throws D4ScienceIAMClientExceptionQuick way to check if the access token is valid by checking the digital signature and the token expiration- Returns:
trueif the access token is valid,falseotherwise- Throws:
D4ScienceIAMClientException- if something goes wrong during the token validity checks
-
isAccessTokenValid
boolean isAccessTokenValid(boolean checkExpiration) throws D4ScienceIAMClientExceptionQuick way to check if the access token is valid by checking the digital signature and the token expiration if thecheckExpirationparameter istrue- Parameters:
checkExpiration- checks also if the token is expired- Returns:
trueif the access token is valid,falseotherwise- Throws:
D4ScienceIAMClientException- if something goes wrong during the token validity checks
-
verifyAccessToken
void verifyAccessToken() throws org.gcube.io.jsonwebtoken.security.SignatureException, org.gcube.io.jsonwebtoken.ExpiredJwtException, D4ScienceIAMClientExceptionVerifies the access token integrity and validity; token digital signature and expiration are reported via specific exceptions.- Throws:
org.gcube.io.jsonwebtoken.security.SignatureException- if the token has been tampered and/or signature is invalidorg.gcube.io.jsonwebtoken.ExpiredJwtException- if the token validity is expiredD4ScienceIAMClientException- if something else goes wrong during the token verification
-
isRefreshTokenValid
boolean isRefreshTokenValid() throws D4ScienceIAMClientExceptionQuick way to check if the refresh token present in the current response and it is valid by checking the digital signature and the token expiration- Returns:
trueif the refresh token is valid,falseotherwise- Throws:
D4ScienceIAMClientException- if something goes wrong during the token validity checks
-
isRefreshTokenValid
boolean isRefreshTokenValid(boolean checkExpiration) throws D4ScienceIAMClientExceptionQuick way to check if the refresh token present in the current response and it is valid by checking the digital signature and the token expiration if thecheckExpirationparameter istrue- Parameters:
checkExpiration- checks also if the token is expired- Returns:
trueif the refresh token is valid,falseotherwise- Throws:
D4ScienceIAMClientException- if something goes wrong during the token validity checks
-
verifyRefreshToken
void verifyRefreshToken() throws org.gcube.io.jsonwebtoken.security.SignatureException, org.gcube.io.jsonwebtoken.ExpiredJwtException, D4ScienceIAMClientExceptionVerifies the refresh token integrity and validity; token digital signature and expiration are reported via specific exceptions.- Throws:
org.gcube.io.jsonwebtoken.security.SignatureException- if the token has been tampered and/or signature is invalidorg.gcube.io.jsonwebtoken.ExpiredJwtException- if the token validity is expiredD4ScienceIAMClientException- if something else goes wrong during the token verification
-
-