Java Code Examples for org.keycloak.models.RealmModel#isEventsEnabled()
The following examples show how to use
org.keycloak.models.RealmModel#isEventsEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventBuilder.java From keycloak with Apache License 2.0 | 5 votes |
public EventBuilder(RealmModel realm, KeycloakSession session, ClientConnection clientConnection) { this.realm = realm; event = new Event(); if (realm.isEventsEnabled()) { EventStoreProvider store = session.getProvider(EventStoreProvider.class); if (store != null) { this.store = store; } else { log.error("Events enabled, but no event store provider configured"); } } if (realm.getEventsListeners() != null && !realm.getEventsListeners().isEmpty()) { this.listeners = new LinkedList<>(); for (String id : realm.getEventsListeners()) { EventListenerProvider listener = session.getProvider(EventListenerProvider.class, id); if (listener != null) { listeners.add(listener); } else { log.error("Event listener '" + id + "' registered, but provider not found"); } } } realm(realm); ipAddress(clientConnection.getRemoteAddr()); }
Example 2
Source File: ClearExpiredEvents.java From keycloak with Apache License 2.0 | 5 votes |
@Override public void run(KeycloakSession session) { EventStoreProvider eventStore = session.getProvider(EventStoreProvider.class); if (eventStore != null) { for (RealmModel realm : session.realms().getRealms()) { if (realm.isEventsEnabled() && realm.getEventsExpiration() > 0) { long olderThan = System.currentTimeMillis() - realm.getEventsExpiration() * 1000; eventStore.clear(realm.getId(), olderThan); } } } }