Interface KeycloakAccess

All Known Implementing Classes:
KeycloakContainer

public interface KeycloakAccess
A facade interface for accessing Keycloak server functionalities.
  • Field Details

    • PRINCIPAL_NAME_CLAIM

      static final String PRINCIPAL_NAME_CLAIM
      The claim name used to identify the principal in Keycloak tokens.
      See Also:
  • Method Details

    • getIssuerUrl

      URI getIssuerUrl()
      Returns the URL of the Keycloak issuer. This is typically https://<keycloak-server>/realms/<realm-name>.
    • getTokenEndpoint

      URI getTokenEndpoint()
      Returns the URL of the Keycloak token endpoint. This is typically https://<keycloak-server>/realms/<realm-name>/protocol/openid-connect/token.
    • getTokenPath

      default String getTokenPath()
      Returns the path of the Keycloak token endpoint. This is typically /realms/<realm-name>/protocol/openid-connect/token.
    • createRole

      void createRole(String name)
      Creates a new role in Keycloak with the specified name.
    • createUser

      void createUser(String name, String password)
      Creates a new user in Keycloak.
    • assignRoleToUser

      void assignRoleToUser(String role, String user)
      Assigns a role to a user in Keycloak. Both the role and the user must exist.
    • createServiceAccount

      void createServiceAccount(String clientId, String clientSecret)
      Creates a new service account in Keycloak with the specified client ID and client secret.
    • deleteRole

      void deleteRole(String name)
      Deletes a role in Keycloak with the specified name.
    • deleteUser

      void deleteUser(String name)
      Deletes a user in Keycloak with the specified name.
    • deleteServiceAccount

      void deleteServiceAccount(String clientId)
      Deletes a service account in Keycloak with the specified client ID.
    • getToken

      String getToken(Map<String,String> params)
      Obtains an access token from the Keycloak server. The passed map becomes the POST request body and should contain the grant type and all required parameters.