Class SystemdProviderFactory

java.lang.Object
com.github.jpmsilva.jsystemd.keycloak.SystemdProviderFactory
All Implemented Interfaces:
org.keycloak.provider.ProviderFactory<SystemdProvider>

public class SystemdProviderFactory extends Object implements org.keycloak.provider.ProviderFactory<SystemdProvider>
Integrates Keycloak with systemd, following the life cycle of Keycloak:
  1. when Keycloak initializes its providers, at the start of its bootstrap, the integration starts, and the status shows Startup: bootstrapping;
  2. once Keycloak has completed its bootstrap, which includes migrating the database and importing realms, and its HTTP server listens, systemd is told that Keycloak is ready. Either may happen last: Keycloak bootstraps once its HTTP server listens when the health endpoints are enabled, answering 503 until then, and before it starts its HTTP server otherwise. When the health endpoints are enabled, Keycloak is also only ready once its readiness health checks, those of its /health/ready endpoint, are all up;
  3. as soon as Keycloak is told to stop, systemd is told that it is stopping, and the status shows Shutdown: stopping;
  4. once Keycloak closes its providers, the integration stops.

The watchdog heartbeats are sent when the service unit sets WatchdogSec, and the status shows the status of the JVM.

Author:
Joao Silva
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The id of the factory, which is part of its options.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance, as Keycloak does.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Stops the integration with systemd, once Keycloak closes its providers, telling systemd that Keycloak is stopping if not done before.
    create(org.keycloak.models.KeycloakSession session)
     
    List<org.keycloak.provider.ProviderConfigProperty>
     
     
    void
    init(org.keycloak.Config.Scope config)
    Starts the integration with systemd, when Keycloak initializes its providers, at the start of its bootstrap.
    void
    postInit(org.keycloak.models.KeycloakSessionFactory factory)
    Tells systemd that Keycloak is ready once it has completed its bootstrap, and its HTTP server listens.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.keycloak.provider.ProviderFactory

    dependsOn, order
  • Field Details

  • Constructor Details

    • SystemdProviderFactory

      public SystemdProviderFactory()
      Creates a new instance, as Keycloak does.
  • Method Details

    • getId

      public String getId()
      Specified by:
      getId in interface org.keycloak.provider.ProviderFactory<SystemdProvider>
    • create

      public SystemdProvider create(org.keycloak.models.KeycloakSession session)
      Specified by:
      create in interface org.keycloak.provider.ProviderFactory<SystemdProvider>
    • init

      public void init(org.keycloak.Config.Scope config)
      Starts the integration with systemd, when Keycloak initializes its providers, at the start of its bootstrap.
      Specified by:
      init in interface org.keycloak.provider.ProviderFactory<SystemdProvider>
      Parameters:
      config - the options of the factory
    • postInit

      public void postInit(org.keycloak.models.KeycloakSessionFactory factory)
      Tells systemd that Keycloak is ready once it has completed its bootstrap, and its HTTP server listens.
      Specified by:
      postInit in interface org.keycloak.provider.ProviderFactory<SystemdProvider>
      Parameters:
      factory - the session factory of Keycloak
    • close

      public void close()
      Stops the integration with systemd, once Keycloak closes its providers, telling systemd that Keycloak is stopping if not done before.
      Specified by:
      close in interface org.keycloak.provider.ProviderFactory<SystemdProvider>
    • getConfigMetadata

      public List<org.keycloak.provider.ProviderConfigProperty> getConfigMetadata()
      Specified by:
      getConfigMetadata in interface org.keycloak.provider.ProviderFactory<SystemdProvider>