Interface EventListenerProvider

  • All Superinterfaces:
    Provider
    All Known Subinterfaces:
    EventStoreProvider
    All Known Implementing Classes:
    EmailEventListenerProvider, JBossLoggingEventListenerProvider, JpaEventStoreProvider, MapEventStoreProvider

    public interface EventListenerProvider
    extends Provider
    Author:
    Stian Thorgersen This interface provides a way to listen to events that happen during the keycloak run.

    There are two types of events:

    • Event - User events (fired when users do some action, like log in, register etc.)
    • Admin event - An administrator did some action like client created/updated etc.
    Implementors can leverage the fact that the onEvent and onAdminEvent are run within a running transaction. Hence, if the event processing uses JPA, it can insert event details into a table, and the whole transaction including the event is either committed or rolled back. However if transaction processing is not an option, e.g. in the case of log files, it is recommended to hook onto transaction after the commit is complete via the KeycloakTransactionManager.enlistAfterCompletion(KeycloakTransaction) method, so that the events are stacked in memory and only written to the file after the original transaction completes successfully.
    • Method Detail

      • onEvent

        void onEvent​(Event event)
        Called when a user event occurs e.g. log in, register.

        Note this method should not do any action that cannot be rolled back, see EventListenerProvider javadoc for more details.

        Parameters:
        event - to be triggered
      • onEvent

        void onEvent​(AdminEvent event,
                     boolean includeRepresentation)
        Called when an admin event occurs e.g. a client was updated/deleted.

        Note this method should not do any action that cannot be rolled back, see EventListenerProvider javadoc for more details.

        Parameters:
        event - to be triggered
        includeRepresentation - when false, event listener should NOT include representation field in the resulting action