Package org.gcube.common.keycloak
Class KeycloakClientHelper
- java.lang.Object
-
- org.gcube.common.keycloak.KeycloakClientHelper
-
public class KeycloakClientHelper extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Loggerlogger
-
Constructor Summary
Constructors Constructor Description KeycloakClientHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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.
-
-
-
Method Detail
-
setDefaultGWClientID
public static void setDefaultGWClientID(String gatewayClientId)
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
-
-