Merge pull request #3086 from cargosoft/KEYCLOAK-3369

KEYCLOAK-3369 Fire RealmPostCreateEvent
This commit is contained in:
Marek Posolda 2016-08-01 08:56:09 +02:00 committed by GitHub
commit bbeac6d741
2 changed files with 27 additions and 4 deletions

View file

@ -38,6 +38,11 @@ public interface RealmModel extends RoleContainerModel {
RealmModel getCreatedRealm();
}
interface RealmPostCreateEvent extends ProviderEvent {
RealmModel getCreatedRealm();
KeycloakSession getKeycloakSession();
}
interface RealmRemovedEvent extends ProviderEvent {
RealmModel getRealm();
KeycloakSession getKeycloakSession();
@ -342,19 +347,19 @@ public interface RealmModel extends RoleContainerModel {
Set<String> getEventsListeners();
void setEventsListeners(Set<String> listeners);
Set<String> getEnabledEventTypes();
void setEnabledEventTypes(Set<String> enabledEventTypes);
boolean isAdminEventsEnabled();
void setAdminEventsEnabled(boolean enabled);
boolean isAdminEventsDetailsEnabled();
void setAdminEventsDetailsEnabled(boolean enabled);
ClientModel getMasterAdminClient();
void setMasterAdminClient(ClientModel client);

View file

@ -121,6 +121,8 @@ public class RealmManager implements RealmImporter {
setupOfflineTokens(realm);
setupAuthorizationServices(realm);
fireRealmPostCreate(realm);
return realm;
}
@ -491,6 +493,7 @@ public class RealmManager implements RealmImporter {
}
setupAuthorizationServices(realm);
fireRealmPostCreate(realm);
return realm;
}
@ -587,4 +590,19 @@ public class RealmManager implements RealmImporter {
private void setupAuthorizationServices(RealmModel realm) {
KeycloakModelUtils.setupAuthorizationServices(realm);
}
private void fireRealmPostCreate(RealmModel realm) {
session.getKeycloakSessionFactory().publish(new RealmModel.RealmPostCreateEvent() {
@Override
public RealmModel getCreatedRealm() {
return realm;
}
@Override
public KeycloakSession getKeycloakSession() {
return session;
}
});
}
}