Merge pull request #3221 from patriot1burke/master

KEYCLOAK-3423
This commit is contained in:
Stian Thorgersen 2016-09-09 07:45:53 +02:00 committed by GitHub
commit e8f99a2109
3 changed files with 72 additions and 18 deletions

View file

@ -137,7 +137,7 @@ public class UserStorageManager implements UserProvider, OnUserCache {
@Override
public boolean removeUser(RealmModel realm, UserModel user) {
getFederatedStorage().preRemove(realm, user);
if (getFederatedStorage() != null) getFederatedStorage().preRemove(realm, user);
StorageId storageId = new StorageId(user.getId());
if (storageId.getProviderId() == null) {
return localStorage().removeUser(realm, user);
@ -272,6 +272,7 @@ public class UserStorageManager implements UserProvider, OnUserCache {
if (user != null) {
return user;
}
if (getFederatedStorage() == null) return null;
String id = getFederatedStorage().getUserByFederatedIdentity(socialLink, realm);
if (id != null) return getUserById(id, realm);
return null;
@ -315,8 +316,6 @@ public class UserStorageManager implements UserProvider, OnUserCache {
protected List<UserModel> query(PaginatedQuery pagedQuery, RealmModel realm, int firstResult, int maxResults) {
if (maxResults == 0) return Collections.EMPTY_LIST;
List<UserQueryProvider> storageProviders = getStorageProviders(session, realm, UserQueryProvider.class);
// we can skip rest of method if there are no storage providers
if (storageProviders.isEmpty()) {
@ -326,7 +325,7 @@ public class UserStorageManager implements UserProvider, OnUserCache {
List<UserModel> results = new LinkedList<UserModel>();
providers.add(localStorage());
providers.addAll(storageProviders);
providers.add(getFederatedStorage());
if (getFederatedStorage() != null) providers.add(getFederatedStorage());
int leftToRead = maxResults;
int leftToFirstResult = firstResult;
@ -432,7 +431,7 @@ public class UserStorageManager implements UserProvider, OnUserCache {
if (StorageId.isLocalStorage(user)) {
set.addAll(localStorage().getFederatedIdentities(user, realm));
}
set.addAll(getFederatedStorage().getFederatedIdentities(user, realm));
if (getFederatedStorage() != null) set.addAll(getFederatedStorage().getFederatedIdentities(user, realm));
return set;
}
@ -443,7 +442,8 @@ public class UserStorageManager implements UserProvider, OnUserCache {
FederatedIdentityModel model = localStorage().getFederatedIdentity(user, socialProvider, realm);
if (model != null) return model;
}
return getFederatedStorage().getFederatedIdentity(user, socialProvider, realm);
if (getFederatedStorage() != null) return getFederatedStorage().getFederatedIdentity(user, socialProvider, realm);
else return null;
}
@Override
@ -483,47 +483,53 @@ public class UserStorageManager implements UserProvider, OnUserCache {
@Override
public void preRemove(RealmModel realm) {
localStorage().preRemove(realm);
if (getFederatedStorage() != null) {
getFederatedStorage().preRemove(realm);
for (UserStorageProvider provider : getStorageProviders(session, realm, UserStorageProvider.class)) {
provider.preRemove(realm);
}
}
}
@Override
public void preRemove(RealmModel realm, UserFederationProviderModel model) {
getFederatedStorage().preRemove(realm, model);
if (getFederatedStorage() != null) getFederatedStorage().preRemove(realm, model);
localStorage().preRemove(realm, model);
}
@Override
public void preRemove(RealmModel realm, GroupModel group) {
localStorage().preRemove(realm, group);
if (getFederatedStorage() != null) {
getFederatedStorage().preRemove(realm, group);
for (UserStorageProvider provider : getStorageProviders(session, realm, UserStorageProvider.class)) {
provider.preRemove(realm, group);
}
}
}
@Override
public void preRemove(RealmModel realm, RoleModel role) {
localStorage().preRemove(realm, role);
if (getFederatedStorage() != null) {
getFederatedStorage().preRemove(realm, role);
for (UserStorageProvider provider : getStorageProviders(session, realm, UserStorageProvider.class)) {
provider.preRemove(realm, role);
}
}
}
@Override
public void preRemove(RealmModel realm, ClientModel client) {
localStorage().preRemove(realm, client);
getFederatedStorage().preRemove(realm, client);
if (getFederatedStorage() != null) getFederatedStorage().preRemove(realm, client);
}
@Override
public void preRemove(ProtocolMapperModel protocolMapper) {
localStorage().preRemove(protocolMapper);
getFederatedStorage().preRemove(protocolMapper);
if (getFederatedStorage() != null) getFederatedStorage().preRemove(protocolMapper);
}
@Override

View file

@ -510,6 +510,51 @@
</profile>
<profile>
<id>mongodb-server</id>
<properties>
<keycloak.connectionsMongo.host>localhost</keycloak.connectionsMongo.host>
<keycloak.connectionsMongo.port>27018</keycloak.connectionsMongo.port>
<keycloak.connectionsMongo.db>keycloak</keycloak.connectionsMongo.db>
<keycloak.connectionsMongo.bindIp>127.0.0.1</keycloak.connectionsMongo.bindIp>
</properties>
<build>
<plugins>
<!-- Embedded mongo -->
<plugin>
<groupId>com.github.joelittlejohn.embedmongo</groupId>
<artifactId>embedmongo-maven-plugin</artifactId>
<executions>
<execution>
<id>start-mongodb</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<port>${keycloak.connectionsMongo.port}</port>
<logging>file</logging>
<logFile>${project.build.directory}/mongodb.log</logFile>
<bindIp>${keycloak.connectionsMongo.bindIp}</bindIp>
</configuration>
</execution>
<execution>
<id>stop-mongodb</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>clean-jpa</id>
<build>

View file

@ -30,6 +30,9 @@ keycloak.server.subsys.default.config=\
<spi name="user">\
<default-provider>jpa</default-provider>\
</spi>\
<spi name="userFederatedStorage">\
<default-provider>jpa</default-provider>\
</spi>\
<spi name="userCache">\
<provider name="default" enabled="true"/>\
</spi>\