commit
e8f99a2109
3 changed files with 72 additions and 18 deletions
|
@ -137,7 +137,7 @@ public class UserStorageManager implements UserProvider, OnUserCache {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeUser(RealmModel realm, UserModel user) {
|
public boolean removeUser(RealmModel realm, UserModel user) {
|
||||||
getFederatedStorage().preRemove(realm, user);
|
if (getFederatedStorage() != null) getFederatedStorage().preRemove(realm, user);
|
||||||
StorageId storageId = new StorageId(user.getId());
|
StorageId storageId = new StorageId(user.getId());
|
||||||
if (storageId.getProviderId() == null) {
|
if (storageId.getProviderId() == null) {
|
||||||
return localStorage().removeUser(realm, user);
|
return localStorage().removeUser(realm, user);
|
||||||
|
@ -272,6 +272,7 @@ public class UserStorageManager implements UserProvider, OnUserCache {
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
if (getFederatedStorage() == null) return null;
|
||||||
String id = getFederatedStorage().getUserByFederatedIdentity(socialLink, realm);
|
String id = getFederatedStorage().getUserByFederatedIdentity(socialLink, realm);
|
||||||
if (id != null) return getUserById(id, realm);
|
if (id != null) return getUserById(id, realm);
|
||||||
return null;
|
return null;
|
||||||
|
@ -315,8 +316,6 @@ public class UserStorageManager implements UserProvider, OnUserCache {
|
||||||
protected List<UserModel> query(PaginatedQuery pagedQuery, RealmModel realm, int firstResult, int maxResults) {
|
protected List<UserModel> query(PaginatedQuery pagedQuery, RealmModel realm, int firstResult, int maxResults) {
|
||||||
if (maxResults == 0) return Collections.EMPTY_LIST;
|
if (maxResults == 0) return Collections.EMPTY_LIST;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<UserQueryProvider> storageProviders = getStorageProviders(session, realm, UserQueryProvider.class);
|
List<UserQueryProvider> storageProviders = getStorageProviders(session, realm, UserQueryProvider.class);
|
||||||
// we can skip rest of method if there are no storage providers
|
// we can skip rest of method if there are no storage providers
|
||||||
if (storageProviders.isEmpty()) {
|
if (storageProviders.isEmpty()) {
|
||||||
|
@ -326,7 +325,7 @@ public class UserStorageManager implements UserProvider, OnUserCache {
|
||||||
List<UserModel> results = new LinkedList<UserModel>();
|
List<UserModel> results = new LinkedList<UserModel>();
|
||||||
providers.add(localStorage());
|
providers.add(localStorage());
|
||||||
providers.addAll(storageProviders);
|
providers.addAll(storageProviders);
|
||||||
providers.add(getFederatedStorage());
|
if (getFederatedStorage() != null) providers.add(getFederatedStorage());
|
||||||
|
|
||||||
int leftToRead = maxResults;
|
int leftToRead = maxResults;
|
||||||
int leftToFirstResult = firstResult;
|
int leftToFirstResult = firstResult;
|
||||||
|
@ -432,7 +431,7 @@ public class UserStorageManager implements UserProvider, OnUserCache {
|
||||||
if (StorageId.isLocalStorage(user)) {
|
if (StorageId.isLocalStorage(user)) {
|
||||||
set.addAll(localStorage().getFederatedIdentities(user, realm));
|
set.addAll(localStorage().getFederatedIdentities(user, realm));
|
||||||
}
|
}
|
||||||
set.addAll(getFederatedStorage().getFederatedIdentities(user, realm));
|
if (getFederatedStorage() != null) set.addAll(getFederatedStorage().getFederatedIdentities(user, realm));
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +442,8 @@ public class UserStorageManager implements UserProvider, OnUserCache {
|
||||||
FederatedIdentityModel model = localStorage().getFederatedIdentity(user, socialProvider, realm);
|
FederatedIdentityModel model = localStorage().getFederatedIdentity(user, socialProvider, realm);
|
||||||
if (model != null) return model;
|
if (model != null) return model;
|
||||||
}
|
}
|
||||||
return getFederatedStorage().getFederatedIdentity(user, socialProvider, realm);
|
if (getFederatedStorage() != null) return getFederatedStorage().getFederatedIdentity(user, socialProvider, realm);
|
||||||
|
else return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -483,47 +483,53 @@ public class UserStorageManager implements UserProvider, OnUserCache {
|
||||||
@Override
|
@Override
|
||||||
public void preRemove(RealmModel realm) {
|
public void preRemove(RealmModel realm) {
|
||||||
localStorage().preRemove(realm);
|
localStorage().preRemove(realm);
|
||||||
getFederatedStorage().preRemove(realm);
|
if (getFederatedStorage() != null) {
|
||||||
for (UserStorageProvider provider : getStorageProviders(session, realm, UserStorageProvider.class)) {
|
getFederatedStorage().preRemove(realm);
|
||||||
provider.preRemove(realm);
|
for (UserStorageProvider provider : getStorageProviders(session, realm, UserStorageProvider.class)) {
|
||||||
|
provider.preRemove(realm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preRemove(RealmModel realm, UserFederationProviderModel model) {
|
public void preRemove(RealmModel realm, UserFederationProviderModel model) {
|
||||||
getFederatedStorage().preRemove(realm, model);
|
if (getFederatedStorage() != null) getFederatedStorage().preRemove(realm, model);
|
||||||
localStorage().preRemove(realm, model);
|
localStorage().preRemove(realm, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preRemove(RealmModel realm, GroupModel group) {
|
public void preRemove(RealmModel realm, GroupModel group) {
|
||||||
localStorage().preRemove(realm, group);
|
localStorage().preRemove(realm, group);
|
||||||
getFederatedStorage().preRemove(realm, group);
|
if (getFederatedStorage() != null) {
|
||||||
for (UserStorageProvider provider : getStorageProviders(session, realm, UserStorageProvider.class)) {
|
getFederatedStorage().preRemove(realm, group);
|
||||||
provider.preRemove(realm, group);
|
for (UserStorageProvider provider : getStorageProviders(session, realm, UserStorageProvider.class)) {
|
||||||
|
provider.preRemove(realm, group);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preRemove(RealmModel realm, RoleModel role) {
|
public void preRemove(RealmModel realm, RoleModel role) {
|
||||||
localStorage().preRemove(realm, role);
|
localStorage().preRemove(realm, role);
|
||||||
getFederatedStorage().preRemove(realm, role);
|
if (getFederatedStorage() != null) {
|
||||||
for (UserStorageProvider provider : getStorageProviders(session, realm, UserStorageProvider.class)) {
|
getFederatedStorage().preRemove(realm, role);
|
||||||
provider.preRemove(realm, role);
|
for (UserStorageProvider provider : getStorageProviders(session, realm, UserStorageProvider.class)) {
|
||||||
|
provider.preRemove(realm, role);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preRemove(RealmModel realm, ClientModel client) {
|
public void preRemove(RealmModel realm, ClientModel client) {
|
||||||
localStorage().preRemove(realm, client);
|
localStorage().preRemove(realm, client);
|
||||||
getFederatedStorage().preRemove(realm, client);
|
if (getFederatedStorage() != null) getFederatedStorage().preRemove(realm, client);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preRemove(ProtocolMapperModel protocolMapper) {
|
public void preRemove(ProtocolMapperModel protocolMapper) {
|
||||||
localStorage().preRemove(protocolMapper);
|
localStorage().preRemove(protocolMapper);
|
||||||
getFederatedStorage().preRemove(protocolMapper);
|
if (getFederatedStorage() != null) getFederatedStorage().preRemove(protocolMapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -510,6 +510,51 @@
|
||||||
|
|
||||||
</profile>
|
</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>
|
<profile>
|
||||||
<id>clean-jpa</id>
|
<id>clean-jpa</id>
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -30,6 +30,9 @@ keycloak.server.subsys.default.config=\
|
||||||
<spi name="user">\
|
<spi name="user">\
|
||||||
<default-provider>jpa</default-provider>\
|
<default-provider>jpa</default-provider>\
|
||||||
</spi>\
|
</spi>\
|
||||||
|
<spi name="userFederatedStorage">\
|
||||||
|
<default-provider>jpa</default-provider>\
|
||||||
|
</spi>\
|
||||||
<spi name="userCache">\
|
<spi name="userCache">\
|
||||||
<provider name="default" enabled="true"/>\
|
<provider name="default" enabled="true"/>\
|
||||||
</spi>\
|
</spi>\
|
||||||
|
|
Loading…
Reference in a new issue