diff --git a/model/api/src/main/java/org/keycloak/models/FederationManager.java b/model/api/src/main/java/org/keycloak/models/FederationManager.java index 7c5bbc0e3b..a9978aa0c8 100755 --- a/model/api/src/main/java/org/keycloak/models/FederationManager.java +++ b/model/api/src/main/java/org/keycloak/models/FederationManager.java @@ -13,6 +13,10 @@ import java.util.Set; public class FederationManager implements UserProvider { protected KeycloakSession session; + public FederationManager(KeycloakSession session) { + this.session = session; + } + @Override public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles) { UserModel user = session.userStorage().addUser(realm, id, username, addDefaultRoles); diff --git a/services/src/main/java/org/keycloak/services/DefaultKeycloakSession.java b/services/src/main/java/org/keycloak/services/DefaultKeycloakSession.java index 09ed19c607..73299bf91f 100755 --- a/services/src/main/java/org/keycloak/services/DefaultKeycloakSession.java +++ b/services/src/main/java/org/keycloak/services/DefaultKeycloakSession.java @@ -1,5 +1,6 @@ package org.keycloak.services; +import org.keycloak.models.FederationManager; import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSessionFactory; import org.keycloak.models.KeycloakTransactionManager; @@ -27,10 +28,12 @@ public class DefaultKeycloakSession implements KeycloakSession { private RealmProvider model; private UserProvider userModel; private UserSessionProvider sessionProvider; + private FederationManager federationManager; public DefaultKeycloakSession(DefaultKeycloakSessionFactory factory) { this.factory = factory; this.transactionManager = new DefaultKeycloakTransactionManager(); + federationManager = new FederationManager(this); } private RealmProvider getRealmProvider() { @@ -61,7 +64,11 @@ public class DefaultKeycloakSession implements KeycloakSession { @Override public UserProvider userStorage() { - return null; + if (userModel == null) { + userModel = getUserProvider(); + } + return userModel; + } public T getProvider(Class clazz) { @@ -113,10 +120,7 @@ public class DefaultKeycloakSession implements KeycloakSession { @Override public UserProvider users() { - if (userModel == null) { - userModel = getUserProvider(); - } - return userModel; + return federationManager; } @Override