public class DefaultKeycloakClient extends Object implements KeycloakClient
CATEGORY, DESCRIPTION, logger, NAME| Constructor and Description |
|---|
DefaultKeycloakClient() |
| Modifier and Type | Method and Description |
|---|---|
URL |
computeIntrospectionEndpointURL()
Compute the keycloak
introspection endpoint URL starting from the discovered token endpoint it in the current scope provided by ScopeProvider. |
URL |
computeIntrospectionEndpointURL(URL tokenEndpointURL)
Compute the keycloak
introspection endpoint URL starting from the provided token endpoint. |
protected String |
constructBasicAuthenticationHeader(String clientId,
String clientSecret) |
protected String |
constructBeareAuthenticationHeader(TokenResponse oidcTokenResponse) |
URL |
findTokenEndpointURL()
|
TokenIntrospectionResponse |
introspectAccessToken(String clientId,
String clientSecret,
String accessTokenJWTString)
Introspects an access token against the Keycloak server discovered in the current scope.
|
TokenIntrospectionResponse |
introspectAccessToken(URL introspectionURL,
String clientId,
String clientSecret,
String accessTokenJWTString)
Introspects an access token against the Keycloak server.
|
boolean |
isAccessTokenVerified(String clientId,
String clientSecret,
String accessTokenJWTString)
Verifies an access token against the Keycloak server discovered in the current scope.
|
boolean |
isAccessTokenVerified(URL introspectionURL,
String clientId,
String clientSecret,
String accessTokenJWTString)
Verifies an access token against the Keycloak server.
|
protected TokenResponse |
performRequest(URL tokenURL,
String authorization,
Map<String,List<String>> params) |
TokenResponse |
queryOIDCToken(String clientId,
String clientSecret)
Queries an OIDC token from the Keycloak server discovered in the current scope, by using provided clientId and client secret.
|
TokenResponse |
queryOIDCToken(URL tokenURL,
String authorization)
Queries an OIDC token from the Keycloak server, by using provided authorization.
|
TokenResponse |
queryOIDCToken(URL tokenURL,
String clientId,
String clientSecret)
Queries an OIDC token from the Keycloak server, by using provided clientId and client secret.
|
TokenResponse |
queryUMAToken(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.
|
TokenResponse |
queryUMAToken(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.
|
TokenResponse |
queryUMAToken(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 the
TokenResponse object
for the given audience (context), in URLEncoded form or not, and optionally a list of permissions. |
TokenResponse |
queryUMAToken(URL tokenURL,
String authorization,
String audience,
List<String> permissions)
Queries an UMA token from the Keycloak server, by using provided authorization, for the given audience (context),
in URLEncoded form or not, and optionally a list of permissions.
|
TokenResponse |
queryUMAToken(URL tokenURL,
String clientId,
String clientSecret,
String audience,
List<String> permissions)
Queries an UMA token from the Keycloak server, by using provided clientId and client secret for the given audience
(context), in URLEncoded form or not, and optionally a list of permissions.
|
TokenResponse |
queryUMAToken(URL tokenURL,
TokenResponse oidcTokenResponse,
String audience,
List<String> permissions)
Queries an UMA token from the Keycloak server, by using access-token provided by the
TokenResponse object
for the given audience (context), in URLEncoded form or not, and optionally a list of permissions. |
TokenResponse |
refreshToken(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.
|
TokenResponse |
refreshToken(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.
|
TokenResponse |
refreshToken(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.
|
TokenResponse |
refreshToken(String clientId,
String clientSecret,
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.
|
TokenResponse |
refreshToken(String clientId,
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.
|
TokenResponse |
refreshToken(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.
|
TokenResponse |
refreshToken(URL tokenURL,
String clientId,
String clientSecret,
String refreshTokenJWTString)
Refreshes a previously issued token from the Keycloak server by using the client id and secret
and the refresh token JWT encoded string obtained with the access token in the previous token response.
|
TokenResponse |
refreshToken(URL tokenURL,
String clientId,
String clientSecret,
TokenResponse tokenResponse)
Refreshes a previously issued token from the Keycloak server using the refresh token JWT encoded string in the
token response object and the provided client id and secret.
|
TokenResponse |
refreshToken(URL tokenURL,
TokenResponse tokenResponse)
Refreshes a previously issued token from the Keycloak server using the refresh token JWT encoded string in the
token response object.
|
public URL findTokenEndpointURL() throws KeycloakClientException
KeycloakClientfindTokenEndpointURL in interface KeycloakClienttoken endpoint URL in the current scopeKeycloakClientException - if something goes wrong discovering the endpoint URLpublic URL computeIntrospectionEndpointURL() throws KeycloakClientException
KeycloakClientintrospection endpoint URL starting from the discovered token endpoint it in the current scope provided by ScopeProvider.computeIntrospectionEndpointURL in interface KeycloakClientintrospection endpoint URL in the current scopeKeycloakClientException - if something goes wrong discovering the endpoint URLpublic URL computeIntrospectionEndpointURL(URL tokenEndpointURL) throws KeycloakClientException
KeycloakClientintrospection endpoint URL starting from the provided token endpoint.computeIntrospectionEndpointURL in interface KeycloakClientintrospection endpoint URL in the current scopeKeycloakClientException - if something goes wrong discovering the endpoint URLpublic TokenResponse queryOIDCToken(String clientId, String clientSecret) throws KeycloakClientException
KeycloakClientqueryOIDCToken in interface KeycloakClientclientId - the client idclientSecret - the client secretTokenResponse objectKeycloakClientException - if something goes wrong performing the querypublic TokenResponse queryOIDCToken(URL tokenURL, String clientId, String clientSecret) throws KeycloakClientException
KeycloakClientqueryOIDCToken in interface KeycloakClienttokenURL - the token endpoint URL of the Keycloak serverclientId - the client idclientSecret - the client secretTokenResponse objectKeycloakClientException - if something goes wrong performing the queryprotected String constructBasicAuthenticationHeader(String clientId, String clientSecret)
public TokenResponse queryOIDCToken(URL tokenURL, String authorization) throws KeycloakClientException
KeycloakClientqueryOIDCToken in interface KeycloakClientauthorization - the authorization to be set as header (e.g. a "Basic ...." auth or an encoded JWT access token preceded by the "Bearer " string)TokenResponse objectKeycloakClientException - if something goes wrong performing the querypublic TokenResponse queryUMAToken(String clientId, String clientSecret, List<String> permissions) throws KeycloakClientException
KeycloakClientqueryUMAToken in interface KeycloakClientclientId - the client idclientSecret - the client secretpermissions - a list of permissions, can be nullTokenResponse objectKeycloakClientException - if something goes wrong performing the querypublic TokenResponse queryUMAToken(TokenResponse oidcTokenResponse, String audience, List<String> permissions) throws KeycloakClientException
KeycloakClientTokenResponse object
for the given audience (context), in URLEncoded form or not, and optionally a list of permissions.queryUMAToken in interface KeycloakClientaudience - the audience (context) where to request the issuing of the ticketpermissions - a list of permissions, can be nullTokenResponse objectKeycloakClientException - if something goes wrong performing the querypublic TokenResponse queryUMAToken(String clientId, String clientSecret, String audience, List<String> permissions) throws KeycloakClientException
KeycloakClientqueryUMAToken in interface KeycloakClientclientId - the client idclientSecret - the client secretaudience - the audience (context) where to request the issuing of the ticketpermissions - a list of permissions, can be nullTokenResponse objectKeycloakClientException - if something goes wrong performing the querypublic TokenResponse queryUMAToken(URL tokenURL, TokenResponse oidcTokenResponse, String audience, List<String> permissions) throws KeycloakClientException
KeycloakClientTokenResponse object
for the given audience (context), in URLEncoded form or not, and optionally a list of permissions.queryUMAToken in interface KeycloakClientaudience - the audience (context) where to request the issuing of the ticketpermissions - a list of permissions, can be nullTokenResponse objectKeycloakClientException - if something goes wrong performing the queryprotected String constructBeareAuthenticationHeader(TokenResponse oidcTokenResponse)
public TokenResponse queryUMAToken(URL tokenURL, String clientId, String clientSecret, String audience, List<String> permissions) throws KeycloakClientException
KeycloakClientqueryUMAToken in interface KeycloakClienttokenURL - the token endpoint URL of the Keycloak serverclientId - the client idclientSecret - the client secretaudience - the audience (context) where to request the issuing of the ticketpermissions - a list of permissions, can be nullTokenResponse objectKeycloakClientException - if something goes wrong performing the querypublic TokenResponse queryUMAToken(URL tokenURL, String authorization, String audience, List<String> permissions) throws KeycloakClientException
KeycloakClientqueryUMAToken in interface KeycloakClientauthorization - the authorization to be set as header (e.g. a "Basic ...." auth or an encoded JWT access token preceded by the "Bearer " string)audience - the audience (context) where to request the issuing of the ticket (URLEncoded)permissions - a list of permissions, can be nullTokenResponse objectKeycloakClientException - if something goes wrong performing the queryprotected TokenResponse performRequest(URL tokenURL, String authorization, Map<String,List<String>> params) throws KeycloakClientException
KeycloakClientExceptionpublic TokenResponse refreshToken(TokenResponse tokenResponse) throws KeycloakClientException
KeycloakClientpublic clients types only.refreshToken in interface KeycloakClienttokenResponse - the previously issued token as TokenResponse objectTokenResponse objectKeycloakClientException - if something goes wrong performing the refresh querypublic TokenResponse refreshToken(URL tokenURL, TokenResponse tokenResponse) throws KeycloakClientException
KeycloakClientpublic clients types only.refreshToken in interface KeycloakClienttokenResponse - the previously issued token as TokenResponse objectTokenResponse objectKeycloakClientException - if something goes wrong performing the refresh querypublic TokenResponse refreshToken(String clientId, TokenResponse tokenResponse) throws KeycloakClientException
KeycloakClientpublic clients types only.refreshToken in interface KeycloakClientclientId - the requestor client id, may be null and in this case will be take from the access token "issued for" claimtokenResponse - the previously issued token as TokenResponse objectTokenResponse objectKeycloakClientException - if something goes wrong performing the refresh querypublic TokenResponse refreshToken(String clientId, String clientSecret, TokenResponse tokenResponse) throws KeycloakClientException
KeycloakClientrefreshToken in interface KeycloakClientclientId - the requestor client id, may be null and in this case will be take from the access token "issued for" claimclientSecret - the requestor client secret, may be null for non-confidential clientstokenResponse - the previously issued token as TokenResponse objectTokenResponse objectKeycloakClientException - if something goes wrong performing the refresh querypublic TokenResponse refreshToken(URL tokenURL, String clientId, String clientSecret, TokenResponse tokenResponse) throws KeycloakClientException
KeycloakClientrefreshToken in interface KeycloakClientclientId - the requestor client id, may be null and in this case will be take from the access token "issued for" claimclientSecret - the requestor client secret, may be null for non-confidential clientstokenResponse - the previously issued token as TokenResponse objectTokenResponse objectKeycloakClientException - if something goes wrong performing the refresh querypublic TokenResponse refreshToken(String refreshTokenJWTString) throws KeycloakClientException
KeycloakClientpublic clients types only.refreshToken in interface KeycloakClientrefreshTokenJWTString - the previously issued refresh token JWT string taken from the same token response of the access token parameterTokenResponse objectKeycloakClientException - if something goes wrong performing the refresh querypublic TokenResponse refreshToken(String clientId, String refreshTokenJWTString) throws KeycloakClientException
KeycloakClientpublic clients types only.refreshToken in interface KeycloakClientclientId - the requestor client idrefreshTokenJWTString - the previously issued refresh token JWT string taken from the same token response of the access token parameterTokenResponse objectKeycloakClientException - if something goes wrong performing the refresh querypublic TokenResponse refreshToken(String clientId, String clientSecret, String refreshTokenJWTString) throws KeycloakClientException
KeycloakClientrefreshToken in interface KeycloakClientclientId - the requestor client idclientSecret - the requestor client secret, may be null for non-confidential clientsrefreshTokenJWTString - the previously issued refresh token JWT string taken from the same token response of the access token parameterTokenResponse objectKeycloakClientException - if something goes wrong performing the refresh querypublic TokenResponse refreshToken(URL tokenURL, String clientId, String clientSecret, String refreshTokenJWTString) throws KeycloakClientException
KeycloakClientrefreshToken in interface KeycloakClientclientId - the requestor client idclientSecret - the requestor client secret, may be null for non-confidential clientsrefreshTokenJWTString - the previously issued refresh token JWT stringTokenResponse objectKeycloakClientException - if something goes wrong performing the refresh querypublic TokenIntrospectionResponse introspectAccessToken(String clientId, String clientSecret, String accessTokenJWTString) throws KeycloakClientException
KeycloakClientintrospectAccessToken in interface KeycloakClientclientId - the requestor client idclientSecret - the requestor client secretaccessTokenJWTString - the access token to verifytrue if the token is valid, false otherwiseKeycloakClientException - if something goes wrong performing the verificationpublic TokenIntrospectionResponse introspectAccessToken(URL introspectionURL, String clientId, String clientSecret, String accessTokenJWTString) throws KeycloakClientException
KeycloakClientintrospectAccessToken in interface KeycloakClientintrospectionURL - the introspection endpoint URL of the Keycloak serverclientId - the requestor client idclientSecret - the requestor client secretaccessTokenJWTString - the access token to verifyTokenIntrospectionResponse object with the introspection results; in particular, the active field represents the token validityKeycloakClientException - if something goes wrong performing the verificationpublic boolean isAccessTokenVerified(String clientId, String clientSecret, String accessTokenJWTString) throws KeycloakClientException
KeycloakClientisAccessTokenVerified in interface KeycloakClientclientId - the requestor client idclientSecret - the requestor client secretaccessTokenJWTString - the access token to verifyTokenIntrospectionResponse object with the introspection results; in particular, the active field represents the token validityKeycloakClientException - if something goes wrong performing the verificationpublic boolean isAccessTokenVerified(URL introspectionURL, String clientId, String clientSecret, String accessTokenJWTString) throws KeycloakClientException
KeycloakClientisAccessTokenVerified in interface KeycloakClientintrospectionURL - the introspection endpoint URL of the Keycloak serverclientId - the requestor client idclientSecret - the requestor client secretaccessTokenJWTString - the access token to verifytrue if the token is active, false otherwiseKeycloakClientException - if something goes wrong performing the verificationCopyright © 2022. All Rights Reserved.