StoreFactory storeFactory = provider.getStoreFactory(); PolicyStore policyStore = storeFactory.getPolicyStore(); ClientModel removedClient = ((ClientRemovedEvent) event).getClient(); ResourceServerStore resourceServerStore = storeFactory.getResourceServerStore(); ResourceServer resourceServer = resourceServerStore.findById(removedClient.getId());
private SessionAndKeyHolder getCacheKeyToInvalidate(ProviderEvent event) { if (event instanceof RealmModel.ClientUpdatedEvent) { RealmModel.ClientUpdatedEvent eventt = (RealmModel.ClientUpdatedEvent) event; String cacheKey = PublicKeyStorageUtils.getClientModelCacheKey(eventt.getUpdatedClient().getRealm().getId(), eventt.getUpdatedClient().getId()); return new SessionAndKeyHolder(eventt.getKeycloakSession(), cacheKey); } else if (event instanceof RealmModel.ClientRemovedEvent) { RealmModel.ClientRemovedEvent eventt = (RealmModel.ClientRemovedEvent) event; String cacheKey = PublicKeyStorageUtils.getClientModelCacheKey(eventt.getClient().getRealm().getId(), eventt.getClient().getId()); return new SessionAndKeyHolder(eventt.getKeycloakSession(), cacheKey); } else if (event instanceof RealmModel.IdentityProviderUpdatedEvent) { RealmModel.IdentityProviderUpdatedEvent eventt = (RealmModel.IdentityProviderUpdatedEvent) event; String cacheKey = PublicKeyStorageUtils.getIdpModelCacheKey(eventt.getRealm().getId(), eventt.getUpdatedIdentityProvider().getInternalId()); return new SessionAndKeyHolder(eventt.getKeycloakSession(), cacheKey); } else if (event instanceof RealmModel.IdentityProviderRemovedEvent) { RealmModel.IdentityProviderRemovedEvent eventt = (RealmModel.IdentityProviderRemovedEvent) event; String cacheKey = PublicKeyStorageUtils.getIdpModelCacheKey(eventt.getRealm().getId(), eventt.getRemovedIdentityProvider().getInternalId()); return new SessionAndKeyHolder(eventt.getKeycloakSession(), cacheKey); } else { return null; } }