This commit is contained in:
Bill Burke 2014-07-23 10:42:18 -04:00
parent 148d494905
commit f1d72d0b6d
2 changed files with 13 additions and 5 deletions

View file

@ -13,6 +13,10 @@ import java.util.Set;
public class FederationManager implements UserProvider { public class FederationManager implements UserProvider {
protected KeycloakSession session; protected KeycloakSession session;
public FederationManager(KeycloakSession session) {
this.session = session;
}
@Override @Override
public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles) { public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles) {
UserModel user = session.userStorage().addUser(realm, id, username, addDefaultRoles); UserModel user = session.userStorage().addUser(realm, id, username, addDefaultRoles);

View file

@ -1,5 +1,6 @@
package org.keycloak.services; package org.keycloak.services;
import org.keycloak.models.FederationManager;
import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory; import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.models.KeycloakTransactionManager; import org.keycloak.models.KeycloakTransactionManager;
@ -27,10 +28,12 @@ public class DefaultKeycloakSession implements KeycloakSession {
private RealmProvider model; private RealmProvider model;
private UserProvider userModel; private UserProvider userModel;
private UserSessionProvider sessionProvider; private UserSessionProvider sessionProvider;
private FederationManager federationManager;
public DefaultKeycloakSession(DefaultKeycloakSessionFactory factory) { public DefaultKeycloakSession(DefaultKeycloakSessionFactory factory) {
this.factory = factory; this.factory = factory;
this.transactionManager = new DefaultKeycloakTransactionManager(); this.transactionManager = new DefaultKeycloakTransactionManager();
federationManager = new FederationManager(this);
} }
private RealmProvider getRealmProvider() { private RealmProvider getRealmProvider() {
@ -61,7 +64,11 @@ public class DefaultKeycloakSession implements KeycloakSession {
@Override @Override
public UserProvider userStorage() { public UserProvider userStorage() {
return null; if (userModel == null) {
userModel = getUserProvider();
}
return userModel;
} }
public <T extends Provider> T getProvider(Class<T> clazz) { public <T extends Provider> T getProvider(Class<T> clazz) {
@ -113,10 +120,7 @@ public class DefaultKeycloakSession implements KeycloakSession {
@Override @Override
public UserProvider users() { public UserProvider users() {
if (userModel == null) { return federationManager;
userModel = getUserProvider();
}
return userModel;
} }
@Override @Override