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:
    • USER_PASSWORD

      static final String USER_PASSWORD
      The password used for all users in Keycloak.
      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. The role should not have the PRINCIPAL_ROLE: prefix.
    • createUser

      void createUser(String name)
      Creates a new user in Keycloak. The password is always "s3cr3t"
    • assignRoleToUser

      void assignRoleToUser(String role, String user)
      Assigns a role to a user in Keycloak. The role should not have the PRINCIPAL_ROLE: prefix. 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. The role should not have the PRINCIPAL_ROLE: prefix.
    • 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.