Package org.gcube.common.keycloak
Class KeycloakClientHelper
java.lang.Object
org.gcube.common.keycloak.KeycloakClientHelper
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TokenResponsegetTokenForUser(String context, String username, String password) Gets a newTokenResponse, containing theAccessTokenand theRefreshTokenfrom the Keycloak server in the environment of the context represented by thecontextparameter.static voidsetDefaultGWClientID(String gatewayClientId) Sets the new default GWclientIdused for all the queries to the Keycloak server.
-
Field Details
-
logger
protected static org.slf4j.Logger logger
-
-
Constructor Details
-
KeycloakClientHelper
public KeycloakClientHelper()
-
-
Method Details
-
setDefaultGWClientID
Sets the new default GWclientIdused for all the queries to the Keycloak server. Note: The operation will logged as WARN to be visible.- Parameters:
gatewayClientId- the new GWclientId
-
getTokenForUser
public static TokenResponse getTokenForUser(String context, String username, String password) throws KeycloakClientException Gets a newTokenResponse, containing theAccessTokenand theRefreshTokenfrom the Keycloak server in the environment of the context represented by thecontextparameter. Thecontextparameter is also used as audience for the token.- Parameters:
context- the context ot be used for discovery and for audienceusername- the user's usernamepassword- the user's password- Returns:
- the token response from the Keycloak server
- Throws:
KeycloakClientException- if an error occurs during the process
-