Class KeycloakClientHelper

java.lang.Object
org.gcube.common.keycloak.KeycloakClientHelper

public class KeycloakClientHelper extends Object
  • Field Details

    • logger

      protected static org.slf4j.Logger logger
  • Constructor Details

    • KeycloakClientHelper

      public KeycloakClientHelper()
  • Method Details

    • setDefaultGWClientID

      public static void setDefaultGWClientID(String gatewayClientId)
      Sets the new default GW clientId used for all the queries to the Keycloak server. Note: The operation will logged as WARN to be visible.
      Parameters:
      gatewayClientId - the new GW clientId
    • getTokenForUser

      public static TokenResponse getTokenForUser(String context, String username, String password) throws KeycloakClientException
      Gets a new TokenResponse, containing the AccessToken and the RefreshToken from the Keycloak server in the environment of the context represented by the context parameter. The context parameter is also used as audience for the token.
      Parameters:
      context - the context ot be used for discovery and for audience
      username - the user's username
      password - the user's password
      Returns:
      the token response from the Keycloak server
      Throws:
      KeycloakClientException - if an error occurs during the process