Package org.gcube.common.keycloak
Class DefaultKeycloakClientLegacyIS
- java.lang.Object
-
- org.gcube.common.keycloak.DefaultKeycloakClient
-
- org.gcube.common.keycloak.DefaultKeycloakClientLegacyIS
-
- All Implemented Interfaces:
org.gcube.common.keycloak.KeycloakClient,KeycloakClientLegacyIS
public class DefaultKeycloakClientLegacyIS extends org.gcube.common.keycloak.DefaultKeycloakClient implements KeycloakClientLegacyIS
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Loggerlogger-
Fields inherited from class org.gcube.common.keycloak.DefaultKeycloakClient
AUTHORIZATION_HEADER, BASE_URL, D4S_CONTEXT_HEADER_NAME
-
Fields inherited from interface org.gcube.common.keycloak.KeycloakClient
DEFAULT_REALM, OPEN_ID_URI_PATH, PROD_ROOT_SCOPE, TOKEN_INTROSPECT_URI_PATH, TOKEN_URI_PATH
-
Fields inherited from interface org.gcube.common.keycloak.KeycloakClientLegacyIS
CATEGORY, DESCRIPTION, NAME
-
-
Constructor Summary
Constructors Constructor Description DefaultKeycloakClientLegacyIS()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description URLcomputeIntrospectionEndpointURL()Compute the keycloakintrospectionendpointURLstarting from the discovered token endpoint it in the current scope provided byScopeProvider.URLfindTokenEndpointURL()org.gcube.common.keycloak.model.TokenIntrospectionResponseintrospectAccessToken(String clientId, String clientSecret, String accessTokenJWTString)Introspects an access token against the Keycloak server discovered in the current scope.booleanisAccessTokenVerified(String clientId, String clientSecret, String accessTokenJWTString)Verifies an access token against the Keycloak server discovered in the current scope.org.gcube.common.keycloak.model.TokenResponsequeryOIDCToken(String clientId, String clientSecret)Queries an OIDC token from the Keycloak server discovered in the current scope, by using provided clientId and client secret.org.gcube.common.keycloak.model.TokenResponsequeryUMAToken(String clientId, String clientSecret, String audience, List<String> permissions)Queries an UMA token from the Keycloak server discovered in the current scope, by using provided clientId and client secret for the given audience (context), in URLEncoded form or not, and optionally a list of permissions.org.gcube.common.keycloak.model.TokenResponsequeryUMAToken(String clientId, String clientSecret, List<String> permissions)Queries an UMA token from the Keycloak server discovered in the current scope, by using provided clientId and client secret for the current scope as audience (context), in URLEncoded form or not, and optionally a list of permissions.org.gcube.common.keycloak.model.TokenResponsequeryUMAToken(org.gcube.common.keycloak.model.TokenResponse oidcTokenResponse, String audience, List<String> permissions)Queries an UMA token from the Keycloak server discovered in the current scope, by using access-token provided by theTokenResponseobject for the given audience (context), in URLEncoded form or not, and optionally a list of permissions.org.gcube.common.keycloak.model.TokenResponserefreshToken(String refreshTokenJWTString)Refreshes a previously issued token from the Keycloak server discovered in the current scope using the the refresh token JWT encoded string obtained with the access token in the previous token response.org.gcube.common.keycloak.model.TokenResponserefreshToken(String clientId, String refreshTokenJWTString)Refreshes a previously issued token from the Keycloak server discovered in the current scope using the provided client id and the refresh token JWT encoded string obtained with the access token in the previous token response.org.gcube.common.keycloak.model.TokenResponserefreshToken(String clientId, String clientSecret, String refreshTokenJWTString)Refreshes a previously issued token from the Keycloak server discovered in the current scope using the provided client id and secret and the refresh token JWT encoded string obtained with the access token in the previous token response.org.gcube.common.keycloak.model.TokenResponserefreshToken(String clientId, String clientSecret, org.gcube.common.keycloak.model.TokenResponse tokenResponse)Refreshes a previously issued token from the Keycloak server discovered in the current scope using the refresh token JWT encoded string in the token response object and the provided client id and secret.org.gcube.common.keycloak.model.TokenResponserefreshToken(String clientId, org.gcube.common.keycloak.model.TokenResponse tokenResponse)Refreshes a previously issued token from the Keycloak server discovered in the current scope using the refresh token JWT encoded string in the token response object and the provided client id.org.gcube.common.keycloak.model.TokenResponserefreshToken(org.gcube.common.keycloak.model.TokenResponse tokenResponse)Refreshes a previously issued token from the Keycloak server discovered in the current scope using the refresh token JWT encoded string in the token response object.-
Methods inherited from class org.gcube.common.keycloak.DefaultKeycloakClient
computeIntrospectionEndpointURL, constructBasicAuthenticationHeader, constructBeareAuthenticationHeader, getIntrospectionEndpointURL, getRealmBaseURL, getRealmBaseURL, getTokenEndpointURL, introspectAccessToken, introspectAccessToken, isAccessTokenVerified, isAccessTokenVerified, performRequest, queryOIDCToken, queryOIDCToken, queryOIDCToken, queryOIDCTokenOfUser, queryOIDCTokenOfUserWithContext, queryOIDCTokenOfUserWithContext, queryOIDCTokenOfUserWithContext, queryOIDCTokenOfUserWithContext, queryOIDCTokenWithContext, queryOIDCTokenWithContext, queryOIDCTokenWithContext, queryOIDCTokenWithContext, queryUMAToken, queryUMAToken, queryUMAToken, queryUMAToken, queryUMAToken, refreshToken, refreshToken, refreshToken, refreshToken, refreshToken, safeSetAsExternalCallForOldAPI
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.gcube.common.keycloak.KeycloakClient
computeIntrospectionEndpointURL, getIntrospectionEndpointURL, getRealmBaseURL, getRealmBaseURL, getTokenEndpointURL, introspectAccessToken, introspectAccessToken, isAccessTokenVerified, isAccessTokenVerified, queryOIDCToken, queryOIDCToken, queryOIDCToken, queryOIDCTokenOfUser, queryOIDCTokenOfUserWithContext, queryOIDCTokenOfUserWithContext, queryOIDCTokenOfUserWithContext, queryOIDCTokenOfUserWithContext, queryOIDCTokenWithContext, queryOIDCTokenWithContext, queryOIDCTokenWithContext, queryOIDCTokenWithContext, queryUMAToken, queryUMAToken, queryUMAToken, queryUMAToken, queryUMAToken, refreshToken, refreshToken, refreshToken, refreshToken, refreshToken
-
-
-
-
Method Detail
-
findTokenEndpointURL
public URL findTokenEndpointURL() throws org.gcube.common.keycloak.KeycloakClientException
Description copied from interface:KeycloakClientLegacyIS- Specified by:
findTokenEndpointURLin interfaceKeycloakClientLegacyIS- Returns:
- the keycloak
tokenendpoint URL in the current scope - Throws:
org.gcube.common.keycloak.KeycloakClientException- if something goes wrong discovering the endpoint URL
-
computeIntrospectionEndpointURL
public URL computeIntrospectionEndpointURL() throws org.gcube.common.keycloak.KeycloakClientException
Description copied from interface:KeycloakClientLegacyISCompute the keycloakintrospectionendpointURLstarting from the discovered token endpoint it in the current scope provided byScopeProvider.- Specified by:
computeIntrospectionEndpointURLin interfaceKeycloakClientLegacyIS- Returns:
- the keycloak
introspectionendpoint URL in the current scope - Throws:
org.gcube.common.keycloak.KeycloakClientException- if something goes wrong discovering the endpoint URL
-
queryOIDCToken
public org.gcube.common.keycloak.model.TokenResponse queryOIDCToken(String clientId, String clientSecret) throws org.gcube.common.keycloak.KeycloakClientException
Description copied from interface:KeycloakClientLegacyISQueries an OIDC token from the Keycloak server discovered in the current scope, by using provided clientId and client secret.- Specified by:
queryOIDCTokenin interfaceorg.gcube.common.keycloak.KeycloakClient- Specified by:
queryOIDCTokenin interfaceKeycloakClientLegacyIS- Overrides:
queryOIDCTokenin classorg.gcube.common.keycloak.DefaultKeycloakClient- Parameters:
clientId- the client idclientSecret- the client secret- Returns:
- the issued token as
TokenResponseobject - Throws:
org.gcube.common.keycloak.KeycloakClientException- if something goes wrong performing the query
-
queryUMAToken
public org.gcube.common.keycloak.model.TokenResponse queryUMAToken(String clientId, String clientSecret, List<String> permissions) throws org.gcube.common.keycloak.KeycloakClientException
Description copied from interface:KeycloakClientLegacyISQueries an UMA token from the Keycloak server discovered in the current scope, by using provided clientId and client secret for the current scope as audience (context), in URLEncoded form or not, and optionally a list of permissions.- Specified by:
queryUMATokenin interfaceKeycloakClientLegacyIS- Parameters:
clientId- the client idclientSecret- the client secretpermissions- a list of permissions, can benull- Returns:
- the issued token as
TokenResponseobject - Throws:
org.gcube.common.keycloak.KeycloakClientException- if something goes wrong performing the query
-
queryUMAToken
public org.gcube.common.keycloak.model.TokenResponse queryUMAToken(org.gcube.common.keycloak.model.TokenResponse oidcTokenResponse, String audience, List<String> permissions) throws org.gcube.common.keycloak.KeycloakClientExceptionDescription copied from interface:KeycloakClientLegacyISQueries an UMA token from the Keycloak server discovered in the current scope, by using access-token provided by theTokenResponseobject for the given audience (context), in URLEncoded form or not, and optionally a list of permissions.- Specified by:
queryUMATokenin interfaceKeycloakClientLegacyISaudience- the audience (context) where to request the issuing of the ticketpermissions- a list of permissions, can benull- Returns:
- the issued token as
TokenResponseobject - Throws:
org.gcube.common.keycloak.KeycloakClientException- if something goes wrong performing the query
-
queryUMAToken
public org.gcube.common.keycloak.model.TokenResponse queryUMAToken(String clientId, String clientSecret, String audience, List<String> permissions) throws org.gcube.common.keycloak.KeycloakClientException
Description copied from interface:KeycloakClientLegacyISQueries an UMA token from the Keycloak server discovered in the current scope, by using provided clientId and client secret for the given audience (context), in URLEncoded form or not, and optionally a list of permissions.- Specified by:
queryUMATokenin interfaceorg.gcube.common.keycloak.KeycloakClient- Specified by:
queryUMATokenin interfaceKeycloakClientLegacyIS- Overrides:
queryUMATokenin classorg.gcube.common.keycloak.DefaultKeycloakClient- Parameters:
clientId- the client idclientSecret- the client secretaudience- the audience (context) where to request the issuing of the ticketpermissions- a list of permissions, can benull- Returns:
- the issued token as
TokenResponseobject - Throws:
org.gcube.common.keycloak.KeycloakClientException- if something goes wrong performing the query
-
refreshToken
public org.gcube.common.keycloak.model.TokenResponse refreshToken(org.gcube.common.keycloak.model.TokenResponse tokenResponse) throws org.gcube.common.keycloak.KeycloakClientExceptionDescription copied from interface:KeycloakClientLegacyISRefreshes a previously issued token from the Keycloak server discovered in the current scope using the refresh token JWT encoded string in the token response object. Client id will be read from "issued for" access token's claim and client secret will be not sent.
NOTE: Forpublicclients types only.- Specified by:
refreshTokenin interfaceKeycloakClientLegacyIS- Parameters:
tokenResponse- the previously issued token asTokenResponseobject- Returns:
- the refreshed token as
TokenResponseobject - Throws:
org.gcube.common.keycloak.KeycloakClientException- if something goes wrong performing the refresh query
-
refreshToken
public org.gcube.common.keycloak.model.TokenResponse refreshToken(String clientId, org.gcube.common.keycloak.model.TokenResponse tokenResponse) throws org.gcube.common.keycloak.KeycloakClientException
Description copied from interface:KeycloakClientLegacyISRefreshes a previously issued token from the Keycloak server discovered in the current scope using the refresh token JWT encoded string in the token response object and the provided client id. Client secret will be not sent.
NOTE: Forpublicclients types only.- Specified by:
refreshTokenin interfaceorg.gcube.common.keycloak.KeycloakClient- Specified by:
refreshTokenin interfaceKeycloakClientLegacyIS- Overrides:
refreshTokenin classorg.gcube.common.keycloak.DefaultKeycloakClient- Parameters:
clientId- the requestor client id, may benulland in this case will be take from the access token "issued for" claimtokenResponse- the previously issued token asTokenResponseobject- Returns:
- the refreshed token as
TokenResponseobject - Throws:
org.gcube.common.keycloak.KeycloakClientException- if something goes wrong performing the refresh query
-
refreshToken
public org.gcube.common.keycloak.model.TokenResponse refreshToken(String clientId, String clientSecret, org.gcube.common.keycloak.model.TokenResponse tokenResponse) throws org.gcube.common.keycloak.KeycloakClientException
Description copied from interface:KeycloakClientLegacyISRefreshes a previously issued token from the Keycloak server discovered in the current scope using the refresh token JWT encoded string in the token response object and the provided client id and secret.- Specified by:
refreshTokenin interfaceKeycloakClientLegacyIS- Parameters:
clientId- the requestor client id, may benulland in this case will be take from the access token "issued for" claimclientSecret- the requestor client secret, may benullfor non-confidential clientstokenResponse- the previously issued token asTokenResponseobject- Returns:
- the refreshed token as
TokenResponseobject - Throws:
org.gcube.common.keycloak.KeycloakClientException- if something goes wrong performing the refresh query
-
refreshToken
public org.gcube.common.keycloak.model.TokenResponse refreshToken(String refreshTokenJWTString) throws org.gcube.common.keycloak.KeycloakClientException
Description copied from interface:KeycloakClientLegacyISRefreshes a previously issued token from the Keycloak server discovered in the current scope using the the refresh token JWT encoded string obtained with the access token in the previous token response. Client id will be read from "issued for" refresh token's claim and client secret will be not sent.
NOTE: Forpublicclients types only.- Specified by:
refreshTokenin interfaceKeycloakClientLegacyIS- Parameters:
refreshTokenJWTString- the previously issued refresh token JWT string taken from the same token response of the access token parameter- Returns:
- the refreshed token as
TokenResponseobject - Throws:
org.gcube.common.keycloak.KeycloakClientException- if something goes wrong performing the refresh query
-
refreshToken
public org.gcube.common.keycloak.model.TokenResponse refreshToken(String clientId, String refreshTokenJWTString) throws org.gcube.common.keycloak.KeycloakClientException
Description copied from interface:KeycloakClientLegacyISRefreshes a previously issued token from the Keycloak server discovered in the current scope using the provided client id and the refresh token JWT encoded string obtained with the access token in the previous token response. Client secret will be not used.
NOTE: Forpublicclients types only.- Specified by:
refreshTokenin interfaceKeycloakClientLegacyIS- Parameters:
clientId- the requestor client idrefreshTokenJWTString- the previously issued refresh token JWT string taken from the same token response of the access token parameter- Returns:
- the refreshed token as
TokenResponseobject - Throws:
org.gcube.common.keycloak.KeycloakClientException- if something goes wrong performing the refresh query
-
refreshToken
public org.gcube.common.keycloak.model.TokenResponse refreshToken(String clientId, String clientSecret, String refreshTokenJWTString) throws org.gcube.common.keycloak.KeycloakClientException
Description copied from interface:KeycloakClientLegacyISRefreshes a previously issued token from the Keycloak server discovered in the current scope using the provided client id and secret and the refresh token JWT encoded string obtained with the access token in the previous token response.- Specified by:
refreshTokenin interfaceKeycloakClientLegacyIS- Parameters:
clientId- the requestor client idclientSecret- the requestor client secret, may benullfor non-confidential clientsrefreshTokenJWTString- the previously issued refresh token JWT string taken from the same token response of the access token parameter- Returns:
- the refreshed token as
TokenResponseobject - Throws:
org.gcube.common.keycloak.KeycloakClientException- if something goes wrong performing the refresh query
-
introspectAccessToken
public org.gcube.common.keycloak.model.TokenIntrospectionResponse introspectAccessToken(String clientId, String clientSecret, String accessTokenJWTString) throws org.gcube.common.keycloak.KeycloakClientException
Description copied from interface:KeycloakClientLegacyISIntrospects an access token against the Keycloak server discovered in the current scope.- Specified by:
introspectAccessTokenin interfaceKeycloakClientLegacyIS- Parameters:
clientId- the requestor client idclientSecret- the requestor client secretaccessTokenJWTString- the access token to verify- Returns:
trueif the token is valid,falseotherwise- Throws:
org.gcube.common.keycloak.KeycloakClientException- if something goes wrong performing the verification
-
isAccessTokenVerified
public boolean isAccessTokenVerified(String clientId, String clientSecret, String accessTokenJWTString) throws org.gcube.common.keycloak.KeycloakClientException
Description copied from interface:KeycloakClientLegacyISVerifies an access token against the Keycloak server discovered in the current scope.- Specified by:
isAccessTokenVerifiedin interfaceKeycloakClientLegacyIS- Parameters:
clientId- the requestor client idclientSecret- the requestor client secretaccessTokenJWTString- the access token to verify- Returns:
- a
TokenIntrospectionResponseobject with the introspection results; in particular, theactivefield represents the token validity - Throws:
org.gcube.common.keycloak.KeycloakClientException- if something goes wrong performing the verification
-
-