@Override
protected void setupDefaultRealm(String contextPath) {
super.setupDefaultRealm(contextPath);
ProviderSession providerSession = providerSessionFactory.createSession();
KeycloakSession session = providerSession.getProvider(KeycloakSession.class);
session.getTransaction().begin();
// disable master realm by deleting the admin user.
try {
RealmManager manager = new RealmManager(session);
RealmModel master = manager.getKeycloakAdminstrationRealm();
UserModel admin = master.getUser("admin");
if (admin != null) master.removeUser(admin.getLoginName());
session.getTransaction().commit();
} finally {
providerSession.close();
}
}