Merge pull request #2228 from patriot1burke/master
make RealmModel unmodifiable collections
This commit is contained in:
commit
b20031faed
21 changed files with 286 additions and 239 deletions
|
@ -141,7 +141,7 @@ public class InfinispanCacheRealmProviderFactory implements CacheRealmProviderFa
|
||||||
realmCache.evictRoleById(r);
|
realmCache.evictRoleById(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String c : realm.getClients().values()) {
|
for (String c : realm.getClients()) {
|
||||||
realmCache.evictClientById(c);
|
realmCache.evictClientById(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -502,11 +502,8 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RequiredCredentialModel> getRequiredCredentials() {
|
public List<RequiredCredentialModel> getRequiredCredentials() {
|
||||||
|
if (updated != null) return updated.getRequiredCredentials();
|
||||||
List<RequiredCredentialModel> copy = new LinkedList<RequiredCredentialModel>();
|
return cached.getRequiredCredentials();
|
||||||
if (updated != null) copy.addAll(updated.getRequiredCredentials());
|
|
||||||
else copy.addAll(cached.getRequiredCredentials());
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -548,11 +545,13 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GroupModel> getDefaultGroups() {
|
public List<GroupModel> getDefaultGroups() {
|
||||||
|
if (updated != null) return updated.getDefaultGroups();
|
||||||
|
|
||||||
List<GroupModel> defaultGroups = new LinkedList<>();
|
List<GroupModel> defaultGroups = new LinkedList<>();
|
||||||
for (String id : cached.getDefaultGroups()) {
|
for (String id : cached.getDefaultGroups()) {
|
||||||
defaultGroups.add(cacheSession.getGroupById(id, this));
|
defaultGroups.add(cacheSession.getGroupById(id, this));
|
||||||
}
|
}
|
||||||
return defaultGroups;
|
return Collections.unmodifiableList(defaultGroups);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,32 +587,18 @@ public class RealmAdapter implements RealmModel {
|
||||||
updated.updateDefaultRoles(defaultRoles);
|
updated.updateDefaultRoles(defaultRoles);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, ClientModel> getClientNameMap() {
|
|
||||||
if (updated != null) return updated.getClientNameMap();
|
|
||||||
Map<String, ClientModel> map = new HashMap<String, ClientModel>();
|
|
||||||
for (String id : cached.getClients().values()) {
|
|
||||||
ClientModel model = cacheSession.getClientById(id, this);
|
|
||||||
if (model == null) {
|
|
||||||
throw new IllegalStateException("Cached application not found: " + id);
|
|
||||||
}
|
|
||||||
map.put(model.getClientId(), model);
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ClientModel> getClients() {
|
public List<ClientModel> getClients() {
|
||||||
if (updated != null) return updated.getClients();
|
if (updated != null) return updated.getClients();
|
||||||
List<ClientModel> apps = new LinkedList<ClientModel>();
|
List<ClientModel> apps = new LinkedList<>();
|
||||||
for (String id : cached.getClients().values()) {
|
for (String id : cached.getClients()) {
|
||||||
ClientModel model = cacheSession.getClientById(id, this);
|
ClientModel model = cacheSession.getClientById(id, this);
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
throw new IllegalStateException("Cached application not found: " + id);
|
throw new IllegalStateException("Cached application not found: " + id);
|
||||||
}
|
}
|
||||||
apps.add(model);
|
apps.add(model);
|
||||||
}
|
}
|
||||||
return apps;
|
return Collections.unmodifiableList(apps);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,6 +676,7 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IdentityProviderModel getIdentityProviderByAlias(String alias) {
|
public IdentityProviderModel getIdentityProviderByAlias(String alias) {
|
||||||
|
if (updated != null) return updated.getIdentityProviderByAlias(alias);
|
||||||
for (IdentityProviderModel identityProviderModel : getIdentityProviders()) {
|
for (IdentityProviderModel identityProviderModel : getIdentityProviders()) {
|
||||||
if (identityProviderModel.getAlias().equals(alias)) {
|
if (identityProviderModel.getAlias().equals(alias)) {
|
||||||
return identityProviderModel;
|
return identityProviderModel;
|
||||||
|
@ -941,7 +927,7 @@ public class RealmAdapter implements RealmModel {
|
||||||
if (roleById == null) continue;
|
if (roleById == null) continue;
|
||||||
roles.add(roleById);
|
roles.add(roleById);
|
||||||
}
|
}
|
||||||
return roles;
|
return Collections.unmodifiableSet(roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1003,13 +989,7 @@ public class RealmAdapter implements RealmModel {
|
||||||
@Override
|
@Override
|
||||||
public Set<IdentityProviderMapperModel> getIdentityProviderMappers() {
|
public Set<IdentityProviderMapperModel> getIdentityProviderMappers() {
|
||||||
if (updated != null) return updated.getIdentityProviderMappers();
|
if (updated != null) return updated.getIdentityProviderMappers();
|
||||||
Set<IdentityProviderMapperModel> mappings = new HashSet<>();
|
return cached.getIdentityProviderMapperSet();
|
||||||
for (List<IdentityProviderMapperModel> models : cached.getIdentityProviderMappers().values()) {
|
|
||||||
for (IdentityProviderMapperModel model : models) {
|
|
||||||
mappings.add(model);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mappings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1020,7 +1000,7 @@ public class RealmAdapter implements RealmModel {
|
||||||
for (IdentityProviderMapperModel entity : list) {
|
for (IdentityProviderMapperModel entity : list) {
|
||||||
mappings.add(entity);
|
mappings.add(entity);
|
||||||
}
|
}
|
||||||
return mappings;
|
return Collections.unmodifiableSet(mappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1066,13 +1046,7 @@ public class RealmAdapter implements RealmModel {
|
||||||
@Override
|
@Override
|
||||||
public Set<UserFederationMapperModel> getUserFederationMappers() {
|
public Set<UserFederationMapperModel> getUserFederationMappers() {
|
||||||
if (updated != null) return updated.getUserFederationMappers();
|
if (updated != null) return updated.getUserFederationMappers();
|
||||||
Set<UserFederationMapperModel> mappers = new HashSet<UserFederationMapperModel>();
|
return cached.getUserFederationMapperSet();
|
||||||
for (List<UserFederationMapperModel> models : cached.getUserFederationMappers().values()) {
|
|
||||||
for (UserFederationMapperModel model : models) {
|
|
||||||
mappers.add(model);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mappers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1083,7 +1057,7 @@ public class RealmAdapter implements RealmModel {
|
||||||
for (UserFederationMapperModel entity : list) {
|
for (UserFederationMapperModel entity : list) {
|
||||||
mappers.add(entity);
|
mappers.add(entity);
|
||||||
}
|
}
|
||||||
return mappers;
|
return Collections.unmodifiableSet(mappers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1192,9 +1166,7 @@ public class RealmAdapter implements RealmModel {
|
||||||
@Override
|
@Override
|
||||||
public List<AuthenticationFlowModel> getAuthenticationFlows() {
|
public List<AuthenticationFlowModel> getAuthenticationFlows() {
|
||||||
if (updated != null) return updated.getAuthenticationFlows();
|
if (updated != null) return updated.getAuthenticationFlows();
|
||||||
List<AuthenticationFlowModel> models = new ArrayList<>();
|
return cached.getAuthenticationFlowList();
|
||||||
models.addAll(cached.getAuthenticationFlows().values());
|
|
||||||
return models;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1281,7 +1253,7 @@ public class RealmAdapter implements RealmModel {
|
||||||
if (updated != null) return updated.getAuthenticatorConfigs();
|
if (updated != null) return updated.getAuthenticatorConfigs();
|
||||||
List<AuthenticatorConfigModel> models = new ArrayList<>();
|
List<AuthenticatorConfigModel> models = new ArrayList<>();
|
||||||
models.addAll(cached.getAuthenticatorConfigs().values());
|
models.addAll(cached.getAuthenticatorConfigs().values());
|
||||||
return models;
|
return Collections.unmodifiableList(models);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1313,9 +1285,7 @@ public class RealmAdapter implements RealmModel {
|
||||||
@Override
|
@Override
|
||||||
public List<RequiredActionProviderModel> getRequiredActionProviders() {
|
public List<RequiredActionProviderModel> getRequiredActionProviders() {
|
||||||
if (updated != null) return updated.getRequiredActionProviders();
|
if (updated != null) return updated.getRequiredActionProviders();
|
||||||
List<RequiredActionProviderModel> models = new ArrayList<>();
|
return cached.getRequiredActionProviderList();
|
||||||
models.addAll(cached.getRequiredActionProviders().values());
|
|
||||||
return models;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1366,20 +1336,20 @@ public class RealmAdapter implements RealmModel {
|
||||||
if (group == null) continue;
|
if (group == null) continue;
|
||||||
list.add(group);
|
list.add(group);
|
||||||
}
|
}
|
||||||
return list;
|
return Collections.unmodifiableList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GroupModel> getTopLevelGroups() {
|
public List<GroupModel> getTopLevelGroups() {
|
||||||
List<GroupModel> all = getGroups();
|
List<GroupModel> base = getGroups();
|
||||||
Iterator<GroupModel> it = all.iterator();
|
if (base.isEmpty()) return base;
|
||||||
while (it.hasNext()) {
|
List<GroupModel> copy = new LinkedList<>();
|
||||||
GroupModel group = it.next();
|
for (GroupModel group : base) {
|
||||||
if (group.getParent() != null) {
|
if (group.getParent() == null) {
|
||||||
it.remove();
|
copy.add(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return all;
|
return Collections.unmodifiableList(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1416,15 +1386,17 @@ public class RealmAdapter implements RealmModel {
|
||||||
@Override
|
@Override
|
||||||
public List<ClientTemplateModel> getClientTemplates() {
|
public List<ClientTemplateModel> getClientTemplates() {
|
||||||
if (updated != null) return updated.getClientTemplates();
|
if (updated != null) return updated.getClientTemplates();
|
||||||
|
List<String> clientTemplates = cached.getClientTemplates();
|
||||||
|
if (clientTemplates.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<ClientTemplateModel> apps = new LinkedList<ClientTemplateModel>();
|
List<ClientTemplateModel> apps = new LinkedList<ClientTemplateModel>();
|
||||||
for (String id : cached.getClientTemplates()) {
|
for (String id : clientTemplates) {
|
||||||
ClientTemplateModel model = cacheSession.getClientTemplateById(id, this);
|
ClientTemplateModel model = cacheSession.getClientTemplateById(id, this);
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
throw new IllegalStateException("Cached clientemplate not found: " + id);
|
throw new IllegalStateException("Cached clientemplate not found: " + id);
|
||||||
}
|
}
|
||||||
apps.add(model);
|
apps.add(model);
|
||||||
}
|
}
|
||||||
return apps;
|
return Collections.unmodifiableList(apps);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class LockingCacheRealmProviderFactory implements CacheRealmProviderFacto
|
||||||
realmCache.evictRoleById(r);
|
realmCache.evictRoleById(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String c : realm.getClients().values()) {
|
for (String c : realm.getClients()) {
|
||||||
realmCache.evictClientById(c);
|
realmCache.evictClientById(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class RevisionedCachedRealm extends CachedRealm implements Revisioned {
|
||||||
@Override
|
@Override
|
||||||
protected void cacheClients(RealmCache cache, RealmProvider delegate, RealmModel model) {
|
protected void cacheClients(RealmCache cache, RealmProvider delegate, RealmModel model) {
|
||||||
for (ClientModel client : model.getClients()) {
|
for (ClientModel client : model.getClients()) {
|
||||||
clients.put(client.getClientId(), client.getId());
|
clients.add(client.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -608,9 +608,9 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RequiredCredentialModel> getRequiredCredentials() {
|
public List<RequiredCredentialModel> getRequiredCredentials() {
|
||||||
List<RequiredCredentialModel> requiredCredentialModels = new ArrayList<RequiredCredentialModel>();
|
|
||||||
Collection<RequiredCredentialEntity> entities = realm.getRequiredCredentials();
|
Collection<RequiredCredentialEntity> entities = realm.getRequiredCredentials();
|
||||||
if (entities == null) return requiredCredentialModels;
|
if (entities == null) return Collections.EMPTY_LIST;
|
||||||
|
List<RequiredCredentialModel> requiredCredentialModels = new LinkedList<>();
|
||||||
for (RequiredCredentialEntity entity : entities) {
|
for (RequiredCredentialEntity entity : entities) {
|
||||||
RequiredCredentialModel model = new RequiredCredentialModel();
|
RequiredCredentialModel model = new RequiredCredentialModel();
|
||||||
model.setFormLabel(entity.getFormLabel());
|
model.setFormLabel(entity.getFormLabel());
|
||||||
|
@ -619,19 +619,19 @@ public class RealmAdapter implements RealmModel {
|
||||||
model.setInput(entity.isInput());
|
model.setInput(entity.isInput());
|
||||||
requiredCredentialModels.add(model);
|
requiredCredentialModels.add(model);
|
||||||
}
|
}
|
||||||
return requiredCredentialModels; //To change body of implemented methods use File | Settings | File Templates.
|
return Collections.unmodifiableList(requiredCredentialModels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDefaultRoles() {
|
public List<String> getDefaultRoles() {
|
||||||
Collection<RoleEntity> entities = realm.getDefaultRoles();
|
Collection<RoleEntity> entities = realm.getDefaultRoles();
|
||||||
List<String> roles = new ArrayList<String>();
|
if (entities == null || entities.isEmpty()) return Collections.emptyList();
|
||||||
if (entities == null) return roles;
|
List<String> roles = new LinkedList<>();
|
||||||
for (RoleEntity entity : entities) {
|
for (RoleEntity entity : entities) {
|
||||||
roles.add(entity.getName());
|
roles.add(entity.getName());
|
||||||
}
|
}
|
||||||
return roles;
|
return Collections.unmodifiableList(roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -685,11 +685,12 @@ public class RealmAdapter implements RealmModel {
|
||||||
@Override
|
@Override
|
||||||
public List<GroupModel> getDefaultGroups() {
|
public List<GroupModel> getDefaultGroups() {
|
||||||
Collection<GroupEntity> entities = realm.getDefaultGroups();
|
Collection<GroupEntity> entities = realm.getDefaultGroups();
|
||||||
|
if (entities == null || entities.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<GroupModel> defaultGroups = new LinkedList<>();
|
List<GroupModel> defaultGroups = new LinkedList<>();
|
||||||
for (GroupEntity entity : entities) {
|
for (GroupEntity entity : entities) {
|
||||||
defaultGroups.add(session.realms().getGroupById(entity.getId(), this));
|
defaultGroups.add(session.realms().getGroupById(entity.getId(), this));
|
||||||
}
|
}
|
||||||
return defaultGroups;
|
return Collections.unmodifiableList(defaultGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -720,25 +721,17 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, ClientModel> getClientNameMap() {
|
|
||||||
Map<String, ClientModel> map = new HashMap<String, ClientModel>();
|
|
||||||
for (ClientModel app : getClients()) {
|
|
||||||
map.put(app.getClientId(), app);
|
|
||||||
}
|
|
||||||
return map; //To change body of implemented methods use File | Settings | File Templates.
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ClientModel> getClients() {
|
public List<ClientModel> getClients() {
|
||||||
List<ClientModel> list = new LinkedList<>();
|
|
||||||
TypedQuery<ClientEntity> query = em.createNamedQuery("getClientsByRealm", ClientEntity.class);
|
TypedQuery<ClientEntity> query = em.createNamedQuery("getClientsByRealm", ClientEntity.class);
|
||||||
query.setParameter("realm", realm);
|
query.setParameter("realm", realm);
|
||||||
List<ClientEntity> clients = query.getResultList();
|
List<ClientEntity> clients = query.getResultList();
|
||||||
|
if (clients.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
|
List<ClientModel> list = new LinkedList<>();
|
||||||
for (ClientEntity entity : clients) {
|
for (ClientEntity entity : clients) {
|
||||||
list.add(new ClientAdapter(this, em, session, entity));
|
list.add(new ClientAdapter(this, em, session, entity));
|
||||||
}
|
}
|
||||||
return list;
|
return Collections.unmodifiableList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -794,13 +787,14 @@ public class RealmAdapter implements RealmModel {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getBrowserSecurityHeaders() {
|
public Map<String, String> getBrowserSecurityHeaders() {
|
||||||
Map<String, String> attributes = getAttributes();
|
Map<String, String> attributes = getAttributes();
|
||||||
|
if (attributes.isEmpty()) return Collections.EMPTY_MAP;
|
||||||
Map<String, String> headers = new HashMap<String, String>();
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
for (Map.Entry<String, String> entry : attributes.entrySet()) {
|
for (Map.Entry<String, String> entry : attributes.entrySet()) {
|
||||||
if (entry.getKey().startsWith(BROWSER_HEADER_PREFIX)) {
|
if (entry.getKey().startsWith(BROWSER_HEADER_PREFIX)) {
|
||||||
headers.put(entry.getKey().substring(BROWSER_HEADER_PREFIX.length()), entry.getValue());
|
headers.put(entry.getKey().substring(BROWSER_HEADER_PREFIX.length()), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return headers;
|
return Collections.unmodifiableMap(headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -812,7 +806,9 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getSmtpConfig() {
|
public Map<String, String> getSmtpConfig() {
|
||||||
return realm.getSmtpConfig();
|
Map<String, String> config = new HashMap<String, String>();
|
||||||
|
config.putAll(realm.getSmtpConfig());
|
||||||
|
return Collections.unmodifiableMap(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -824,6 +820,7 @@ public class RealmAdapter implements RealmModel {
|
||||||
@Override
|
@Override
|
||||||
public List<UserFederationProviderModel> getUserFederationProviders() {
|
public List<UserFederationProviderModel> getUserFederationProviders() {
|
||||||
List<UserFederationProviderEntity> entities = realm.getUserFederationProviders();
|
List<UserFederationProviderEntity> entities = realm.getUserFederationProviders();
|
||||||
|
if (entities.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<UserFederationProviderEntity> copy = new ArrayList<UserFederationProviderEntity>();
|
List<UserFederationProviderEntity> copy = new ArrayList<UserFederationProviderEntity>();
|
||||||
for (UserFederationProviderEntity entity : entities) {
|
for (UserFederationProviderEntity entity : entities) {
|
||||||
copy.add(entity);
|
copy.add(entity);
|
||||||
|
@ -843,7 +840,7 @@ public class RealmAdapter implements RealmModel {
|
||||||
entity.getFullSyncPeriod(), entity.getChangedSyncPeriod(), entity.getLastSync()));
|
entity.getFullSyncPeriod(), entity.getChangedSyncPeriod(), entity.getLastSync()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return Collections.unmodifiableList(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1062,13 +1059,13 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<RoleModel> getRoles() {
|
public Set<RoleModel> getRoles() {
|
||||||
Set<RoleModel> list = new HashSet<RoleModel>();
|
|
||||||
Collection<RoleEntity> roles = realm.getRoles();
|
Collection<RoleEntity> roles = realm.getRoles();
|
||||||
if (roles == null) return list;
|
if (roles == null) return Collections.EMPTY_SET;
|
||||||
|
Set<RoleModel> list = new HashSet<RoleModel>();
|
||||||
for (RoleEntity entity : roles) {
|
for (RoleEntity entity : roles) {
|
||||||
list.add(new RoleAdapter(this, em, entity));
|
list.add(new RoleAdapter(this, em, entity));
|
||||||
}
|
}
|
||||||
return list;
|
return Collections.unmodifiableSet(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1206,7 +1203,11 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getEventsListeners() {
|
public Set<String> getEventsListeners() {
|
||||||
return realm.getEventsListeners();
|
Set<String> eventsListeners = realm.getEventsListeners();
|
||||||
|
if (eventsListeners.isEmpty()) return Collections.EMPTY_SET;
|
||||||
|
Set<String> copy = new HashSet<>();
|
||||||
|
copy.addAll(eventsListeners);
|
||||||
|
return Collections.unmodifiableSet(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1217,7 +1218,11 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getEnabledEventTypes() {
|
public Set<String> getEnabledEventTypes() {
|
||||||
return realm.getEnabledEventTypes();
|
Set<String> enabledEventTypes = realm.getEnabledEventTypes();
|
||||||
|
if (enabledEventTypes.isEmpty()) return Collections.EMPTY_SET;
|
||||||
|
Set<String> copy = new HashSet<>();
|
||||||
|
copy.addAll(enabledEventTypes);
|
||||||
|
return Collections.unmodifiableSet(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1268,15 +1273,20 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IdentityProviderModel> getIdentityProviders() {
|
public List<IdentityProviderModel> getIdentityProviders() {
|
||||||
|
List<IdentityProviderEntity> entities = realm.getIdentityProviders();
|
||||||
|
if (entities.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<IdentityProviderModel> identityProviders = new ArrayList<IdentityProviderModel>();
|
List<IdentityProviderModel> identityProviders = new ArrayList<IdentityProviderModel>();
|
||||||
|
|
||||||
for (IdentityProviderEntity entity: realm.getIdentityProviders()) {
|
for (IdentityProviderEntity entity: entities) {
|
||||||
IdentityProviderModel identityProviderModel = new IdentityProviderModel();
|
IdentityProviderModel identityProviderModel = new IdentityProviderModel();
|
||||||
|
|
||||||
identityProviderModel.setProviderId(entity.getProviderId());
|
identityProviderModel.setProviderId(entity.getProviderId());
|
||||||
identityProviderModel.setAlias(entity.getAlias());
|
identityProviderModel.setAlias(entity.getAlias());
|
||||||
identityProviderModel.setInternalId(entity.getInternalId());
|
identityProviderModel.setInternalId(entity.getInternalId());
|
||||||
identityProviderModel.setConfig(entity.getConfig());
|
Map<String, String> config = entity.getConfig();
|
||||||
|
Map<String, String> copy = new HashMap<>();
|
||||||
|
copy.putAll(config);
|
||||||
|
identityProviderModel.setConfig(copy);
|
||||||
identityProviderModel.setEnabled(entity.isEnabled());
|
identityProviderModel.setEnabled(entity.isEnabled());
|
||||||
identityProviderModel.setTrustEmail(entity.isTrustEmail());
|
identityProviderModel.setTrustEmail(entity.isTrustEmail());
|
||||||
identityProviderModel.setAuthenticateByDefault(entity.isAuthenticateByDefault());
|
identityProviderModel.setAuthenticateByDefault(entity.isAuthenticateByDefault());
|
||||||
|
@ -1288,7 +1298,7 @@ public class RealmAdapter implements RealmModel {
|
||||||
identityProviders.add(identityProviderModel);
|
identityProviders.add(identityProviderModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
return identityProviders;
|
return Collections.unmodifiableList(identityProviders);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1373,7 +1383,11 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getSupportedLocales() {
|
public Set<String> getSupportedLocales() {
|
||||||
return realm.getSupportedLocales();
|
Set<String> supportedLocales = realm.getSupportedLocales();
|
||||||
|
if (supportedLocales == null || supportedLocales.isEmpty()) return Collections.EMPTY_SET;
|
||||||
|
Set<String> copy = new HashSet<>();
|
||||||
|
copy.addAll(supportedLocales);
|
||||||
|
return Collections.unmodifiableSet(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1395,12 +1409,14 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<IdentityProviderMapperModel> getIdentityProviderMappers() {
|
public Set<IdentityProviderMapperModel> getIdentityProviderMappers() {
|
||||||
|
Collection<IdentityProviderMapperEntity> entities = this.realm.getIdentityProviderMappers();
|
||||||
|
if (entities.isEmpty()) return Collections.EMPTY_SET;
|
||||||
Set<IdentityProviderMapperModel> mappings = new HashSet<IdentityProviderMapperModel>();
|
Set<IdentityProviderMapperModel> mappings = new HashSet<IdentityProviderMapperModel>();
|
||||||
for (IdentityProviderMapperEntity entity : this.realm.getIdentityProviderMappers()) {
|
for (IdentityProviderMapperEntity entity : entities) {
|
||||||
IdentityProviderMapperModel mapping = entityToModel(entity);
|
IdentityProviderMapperModel mapping = entityToModel(entity);
|
||||||
mappings.add(mapping);
|
mappings.add(mapping);
|
||||||
}
|
}
|
||||||
return mappings;
|
return Collections.unmodifiableSet(mappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1508,23 +1524,26 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UserFederationMapperModel> getUserFederationMappers() {
|
public Set<UserFederationMapperModel> getUserFederationMappers() {
|
||||||
Set<UserFederationMapperModel> mappers = new HashSet<UserFederationMapperModel>();
|
Collection<UserFederationMapperEntity> entities = this.realm.getUserFederationMappers();
|
||||||
for (UserFederationMapperEntity entity : this.realm.getUserFederationMappers()) {
|
if (entities.isEmpty()) return Collections.EMPTY_SET;
|
||||||
|
Set<UserFederationMapperModel> mappers = new HashSet<>();
|
||||||
|
for (UserFederationMapperEntity entity : entities) {
|
||||||
UserFederationMapperModel mapper = entityToModel(entity);
|
UserFederationMapperModel mapper = entityToModel(entity);
|
||||||
mappers.add(mapper);
|
mappers.add(mapper);
|
||||||
}
|
}
|
||||||
return mappers;
|
return Collections.unmodifiableSet(mappers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UserFederationMapperModel> getUserFederationMappersByFederationProvider(String federationProviderId) {
|
public Set<UserFederationMapperModel> getUserFederationMappersByFederationProvider(String federationProviderId) {
|
||||||
Set<UserFederationMapperModel> mappers = new HashSet<UserFederationMapperModel>();
|
|
||||||
Set<UserFederationMapperEntity> mapperEntities = getUserFederationMapperEntitiesByFederationProvider(federationProviderId);
|
Set<UserFederationMapperEntity> mapperEntities = getUserFederationMapperEntitiesByFederationProvider(federationProviderId);
|
||||||
|
if (mapperEntities.isEmpty()) return Collections.EMPTY_SET;
|
||||||
|
Set<UserFederationMapperModel> mappers = new HashSet<UserFederationMapperModel>();
|
||||||
for (UserFederationMapperEntity entity : mapperEntities) {
|
for (UserFederationMapperEntity entity : mapperEntities) {
|
||||||
UserFederationMapperModel mapper = entityToModel(entity);
|
UserFederationMapperModel mapper = entityToModel(entity);
|
||||||
mappers.add(mapper);
|
mappers.add(mapper);
|
||||||
}
|
}
|
||||||
return mappers;
|
return Collections.unmodifiableSet(mappers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1693,13 +1712,13 @@ public class RealmAdapter implements RealmModel {
|
||||||
TypedQuery<AuthenticationFlowEntity> query = em.createNamedQuery("getAuthenticationFlowsByRealm", AuthenticationFlowEntity.class);
|
TypedQuery<AuthenticationFlowEntity> query = em.createNamedQuery("getAuthenticationFlowsByRealm", AuthenticationFlowEntity.class);
|
||||||
query.setParameter("realm", realm);
|
query.setParameter("realm", realm);
|
||||||
List<AuthenticationFlowEntity> flows = query.getResultList();
|
List<AuthenticationFlowEntity> flows = query.getResultList();
|
||||||
if (flows.size() == 0) return Collections.EMPTY_LIST;
|
if (flows.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<AuthenticationFlowModel> models = new LinkedList<>();
|
List<AuthenticationFlowModel> models = new LinkedList<>();
|
||||||
for (AuthenticationFlowEntity entity : flows) {
|
for (AuthenticationFlowEntity entity : flows) {
|
||||||
AuthenticationFlowModel model = entityToModel(entity);
|
AuthenticationFlowModel model = entityToModel(entity);
|
||||||
models.add(model);
|
models.add(model);
|
||||||
}
|
}
|
||||||
return models;
|
return Collections.unmodifiableList(models);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1785,13 +1804,14 @@ public class RealmAdapter implements RealmModel {
|
||||||
query.setParameter("realm", realm);
|
query.setParameter("realm", realm);
|
||||||
query.setParameter("parentFlow", flow);
|
query.setParameter("parentFlow", flow);
|
||||||
List<AuthenticationExecutionEntity> queryResult = query.getResultList();
|
List<AuthenticationExecutionEntity> queryResult = query.getResultList();
|
||||||
|
if (queryResult.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<AuthenticationExecutionModel> executions = new LinkedList<>();
|
List<AuthenticationExecutionModel> executions = new LinkedList<>();
|
||||||
for (AuthenticationExecutionEntity entity : queryResult) {
|
for (AuthenticationExecutionEntity entity : queryResult) {
|
||||||
AuthenticationExecutionModel model = entityToModel(entity);
|
AuthenticationExecutionModel model = entityToModel(entity);
|
||||||
executions.add(model);
|
executions.add(model);
|
||||||
}
|
}
|
||||||
Collections.sort(executions, AuthenticationExecutionModel.ExecutionComparator.SINGLETON);
|
Collections.sort(executions, AuthenticationExecutionModel.ExecutionComparator.SINGLETON);
|
||||||
return executions;
|
return Collections.unmodifiableList(executions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthenticationExecutionModel entityToModel(AuthenticationExecutionEntity entity) {
|
public AuthenticationExecutionModel entityToModel(AuthenticationExecutionEntity entity) {
|
||||||
|
@ -1916,11 +1936,13 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AuthenticatorConfigModel> getAuthenticatorConfigs() {
|
public List<AuthenticatorConfigModel> getAuthenticatorConfigs() {
|
||||||
|
Collection<AuthenticatorConfigEntity> entities = realm.getAuthenticatorConfigs();
|
||||||
|
if (entities.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<AuthenticatorConfigModel> authenticators = new LinkedList<>();
|
List<AuthenticatorConfigModel> authenticators = new LinkedList<>();
|
||||||
for (AuthenticatorConfigEntity entity : realm.getAuthenticatorConfigs()) {
|
for (AuthenticatorConfigEntity entity : entities) {
|
||||||
authenticators.add(entityToModel(entity));
|
authenticators.add(entityToModel(entity));
|
||||||
}
|
}
|
||||||
return authenticators;
|
return Collections.unmodifiableList(authenticators);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1993,11 +2015,13 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RequiredActionProviderModel> getRequiredActionProviders() {
|
public List<RequiredActionProviderModel> getRequiredActionProviders() {
|
||||||
|
Collection<RequiredActionProviderEntity> entities = realm.getRequiredActionProviders();
|
||||||
|
if (entities.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<RequiredActionProviderModel> actions = new LinkedList<>();
|
List<RequiredActionProviderModel> actions = new LinkedList<>();
|
||||||
for (RequiredActionProviderEntity entity : realm.getRequiredActionProviders()) {
|
for (RequiredActionProviderEntity entity : entities) {
|
||||||
actions.add(entityToModel(entity));
|
actions.add(entityToModel(entity));
|
||||||
}
|
}
|
||||||
return actions;
|
return Collections.unmodifiableList(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2028,26 +2052,26 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GroupModel> getGroups() {
|
public List<GroupModel> getGroups() {
|
||||||
|
List<GroupEntity> groups = em.createNamedQuery("getAllGroupsByRealm").setParameter("realm", realm).getResultList();
|
||||||
|
if (groups == null) return Collections.EMPTY_LIST;
|
||||||
List<GroupModel> list = new LinkedList<>();
|
List<GroupModel> list = new LinkedList<>();
|
||||||
Collection<GroupEntity> groups = em.createNamedQuery("getAllGroupsByRealm").setParameter("realm", realm).getResultList();
|
|
||||||
if (groups == null) return list;
|
|
||||||
for (GroupEntity entity : groups) {
|
for (GroupEntity entity : groups) {
|
||||||
list.add(new GroupAdapter(this, em, entity));
|
list.add(new GroupAdapter(this, em, entity));
|
||||||
}
|
}
|
||||||
return list;
|
return Collections.unmodifiableList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GroupModel> getTopLevelGroups() {
|
public List<GroupModel> getTopLevelGroups() {
|
||||||
List<GroupModel> all = getGroups();
|
List<GroupModel> base = getGroups();
|
||||||
Iterator<GroupModel> it = all.iterator();
|
if (base.isEmpty()) return base;
|
||||||
while (it.hasNext()) {
|
List<GroupModel> copy = new LinkedList<>();
|
||||||
GroupModel group = it.next();
|
for (GroupModel group : base) {
|
||||||
if (group.getParent() != null) {
|
if (group.getParent() == null) {
|
||||||
it.remove();
|
copy.add(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return all;
|
return Collections.unmodifiableList(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2100,12 +2124,13 @@ public class RealmAdapter implements RealmModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ClientTemplateModel> getClientTemplates() {
|
public List<ClientTemplateModel> getClientTemplates() {
|
||||||
|
Collection<ClientTemplateEntity> entities = realm.getClientTemplates();
|
||||||
|
if (entities == null || entities.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<ClientTemplateModel> list = new LinkedList<>();
|
List<ClientTemplateModel> list = new LinkedList<>();
|
||||||
if (realm.getClientTemplates() == null) return list;
|
for (ClientTemplateEntity entity : entities) {
|
||||||
for (ClientTemplateEntity entity : realm.getClientTemplates()) {
|
|
||||||
list.add(new ClientTemplateAdapter(this, em, session, entity));
|
list.add(new ClientTemplateAdapter(this, em, session, entity));
|
||||||
}
|
}
|
||||||
return list;
|
return Collections.unmodifiableList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -645,14 +645,14 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
.get();
|
.get();
|
||||||
List<MongoRoleEntity> roles = getMongoStore().loadEntities(MongoRoleEntity.class, query, invocationContext);
|
List<MongoRoleEntity> roles = getMongoStore().loadEntities(MongoRoleEntity.class, query, invocationContext);
|
||||||
|
|
||||||
Set<RoleModel> result = new HashSet<RoleModel>();
|
|
||||||
|
|
||||||
if (roles == null) return result;
|
if (roles == null) return Collections.EMPTY_SET;
|
||||||
|
Set<RoleModel> result = new HashSet<RoleModel>();
|
||||||
for (MongoRoleEntity role : roles) {
|
for (MongoRoleEntity role : roles) {
|
||||||
result.add(new RoleAdapter(session, this, role, this, invocationContext));
|
result.add(new RoleAdapter(session, this, role, this, invocationContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return Collections.unmodifiableSet(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -709,6 +709,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
.and("realmId").is(getId())
|
.and("realmId").is(getId())
|
||||||
.get();
|
.get();
|
||||||
List<MongoGroupEntity> groups = getMongoStore().loadEntities(MongoGroupEntity.class, query, invocationContext);
|
List<MongoGroupEntity> groups = getMongoStore().loadEntities(MongoGroupEntity.class, query, invocationContext);
|
||||||
|
if (groups == null) return Collections.EMPTY_LIST;
|
||||||
|
|
||||||
List<GroupModel> result = new LinkedList<>();
|
List<GroupModel> result = new LinkedList<>();
|
||||||
|
|
||||||
|
@ -717,20 +718,20 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
result.add(model.getGroupById(group.getId(), this));
|
result.add(model.getGroupById(group.getId(), this));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return Collections.unmodifiableList(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GroupModel> getTopLevelGroups() {
|
public List<GroupModel> getTopLevelGroups() {
|
||||||
List<GroupModel> all = getGroups();
|
List<GroupModel> base = getGroups();
|
||||||
Iterator<GroupModel> it = all.iterator();
|
if (base.isEmpty()) return base;
|
||||||
while (it.hasNext()) {
|
List<GroupModel> copy = new LinkedList<>();
|
||||||
GroupModel group = it.next();
|
for (GroupModel group : base) {
|
||||||
if (group.getParentId() != null) {
|
if (group.getParent() == null) {
|
||||||
it.remove();
|
copy.add(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return all;
|
return Collections.unmodifiableList(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -750,7 +751,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getDefaultRoles() {
|
public List<String> getDefaultRoles() {
|
||||||
return realm.getDefaultRoles();
|
return Collections.unmodifiableList(realm.getDefaultRoles());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -781,11 +782,13 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GroupModel> getDefaultGroups() {
|
public List<GroupModel> getDefaultGroups() {
|
||||||
|
List<String> entities = realm.getDefaultGroups();
|
||||||
|
if (entities == null || entities.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<GroupModel> defaultGroups = new LinkedList<>();
|
List<GroupModel> defaultGroups = new LinkedList<>();
|
||||||
for (String id : realm.getDefaultGroups()) {
|
for (String id : entities) {
|
||||||
defaultGroups.add(session.realms().getGroupById(id, this));
|
defaultGroups.add(session.realms().getGroupById(id, this));
|
||||||
}
|
}
|
||||||
return defaultGroups;
|
return Collections.unmodifiableList(defaultGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -810,15 +813,6 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
return session.realms().getClientByClientId(clientId, this);
|
return session.realms().getClientByClientId(clientId, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, ClientModel> getClientNameMap() {
|
|
||||||
Map<String, ClientModel> resourceMap = new HashMap<String, ClientModel>();
|
|
||||||
for (ClientModel resource : getClients()) {
|
|
||||||
resourceMap.put(resource.getClientId(), resource);
|
|
||||||
}
|
|
||||||
return resourceMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ClientModel> getClients() {
|
public List<ClientModel> getClients() {
|
||||||
DBObject query = new QueryBuilder()
|
DBObject query = new QueryBuilder()
|
||||||
|
@ -826,11 +820,12 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
.get();
|
.get();
|
||||||
List<MongoClientEntity> clientEntities = getMongoStore().loadEntities(MongoClientEntity.class, query, invocationContext);
|
List<MongoClientEntity> clientEntities = getMongoStore().loadEntities(MongoClientEntity.class, query, invocationContext);
|
||||||
|
|
||||||
|
if (clientEntities.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<ClientModel> result = new ArrayList<ClientModel>();
|
List<ClientModel> result = new ArrayList<ClientModel>();
|
||||||
for (MongoClientEntity clientEntity : clientEntities) {
|
for (MongoClientEntity clientEntity : clientEntities) {
|
||||||
result.add(new ClientAdapter(session, this, clientEntity, invocationContext));
|
result.add(new ClientAdapter(session, this, clientEntity, invocationContext));
|
||||||
}
|
}
|
||||||
return result;
|
return Collections.unmodifiableList(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -922,8 +917,8 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<RequiredCredentialModel> convertRequiredCredentialEntities(Collection<RequiredCredentialEntity> credEntities) {
|
protected List<RequiredCredentialModel> convertRequiredCredentialEntities(Collection<RequiredCredentialEntity> credEntities) {
|
||||||
|
if (credEntities == null || credEntities.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<RequiredCredentialModel> result = new ArrayList<RequiredCredentialModel>();
|
List<RequiredCredentialModel> result = new LinkedList<>();
|
||||||
for (RequiredCredentialEntity entity : credEntities) {
|
for (RequiredCredentialEntity entity : credEntities) {
|
||||||
RequiredCredentialModel model = new RequiredCredentialModel();
|
RequiredCredentialModel model = new RequiredCredentialModel();
|
||||||
model.setFormLabel(entity.getFormLabel());
|
model.setFormLabel(entity.getFormLabel());
|
||||||
|
@ -933,7 +928,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
|
|
||||||
result.add(model);
|
result.add(model);
|
||||||
}
|
}
|
||||||
return result;
|
return Collections.unmodifiableList(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateRealm() {
|
protected void updateRealm() {
|
||||||
|
@ -950,7 +945,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getBrowserSecurityHeaders() {
|
public Map<String, String> getBrowserSecurityHeaders() {
|
||||||
return realm.getBrowserSecurityHeaders();
|
return Collections.unmodifiableMap(realm.getBrowserSecurityHeaders());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -961,7 +956,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getSmtpConfig() {
|
public Map<String, String> getSmtpConfig() {
|
||||||
return realm.getSmtpConfig();
|
return Collections.unmodifiableMap(realm.getSmtpConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -973,15 +968,20 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IdentityProviderModel> getIdentityProviders() {
|
public List<IdentityProviderModel> getIdentityProviders() {
|
||||||
|
List<IdentityProviderEntity> entities = realm.getIdentityProviders();
|
||||||
|
if (entities.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<IdentityProviderModel> identityProviders = new ArrayList<IdentityProviderModel>();
|
List<IdentityProviderModel> identityProviders = new ArrayList<IdentityProviderModel>();
|
||||||
|
|
||||||
for (IdentityProviderEntity entity: realm.getIdentityProviders()) {
|
for (IdentityProviderEntity entity: entities) {
|
||||||
IdentityProviderModel identityProviderModel = new IdentityProviderModel();
|
IdentityProviderModel identityProviderModel = new IdentityProviderModel();
|
||||||
|
|
||||||
identityProviderModel.setProviderId(entity.getProviderId());
|
identityProviderModel.setProviderId(entity.getProviderId());
|
||||||
identityProviderModel.setAlias(entity.getAlias());
|
identityProviderModel.setAlias(entity.getAlias());
|
||||||
identityProviderModel.setInternalId(entity.getInternalId());
|
identityProviderModel.setInternalId(entity.getInternalId());
|
||||||
identityProviderModel.setConfig(entity.getConfig());
|
Map<String, String> config = entity.getConfig();
|
||||||
|
Map<String, String> copy = new HashMap<>();
|
||||||
|
copy.putAll(config);
|
||||||
|
identityProviderModel.setConfig(copy);
|
||||||
identityProviderModel.setEnabled(entity.isEnabled());
|
identityProviderModel.setEnabled(entity.isEnabled());
|
||||||
identityProviderModel.setTrustEmail(entity.isTrustEmail());
|
identityProviderModel.setTrustEmail(entity.isTrustEmail());
|
||||||
identityProviderModel.setAuthenticateByDefault(entity.isAuthenticateByDefault());
|
identityProviderModel.setAuthenticateByDefault(entity.isAuthenticateByDefault());
|
||||||
|
@ -993,7 +993,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
identityProviders.add(identityProviderModel);
|
identityProviders.add(identityProviderModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
return identityProviders;
|
return Collections.unmodifiableList(identityProviders);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1132,6 +1132,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
@Override
|
@Override
|
||||||
public List<UserFederationProviderModel> getUserFederationProviders() {
|
public List<UserFederationProviderModel> getUserFederationProviders() {
|
||||||
List<UserFederationProviderEntity> entities = realm.getUserFederationProviders();
|
List<UserFederationProviderEntity> entities = realm.getUserFederationProviders();
|
||||||
|
if (entities.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<UserFederationProviderEntity> copy = new LinkedList<UserFederationProviderEntity>();
|
List<UserFederationProviderEntity> copy = new LinkedList<UserFederationProviderEntity>();
|
||||||
for (UserFederationProviderEntity entity : entities) {
|
for (UserFederationProviderEntity entity : entities) {
|
||||||
copy.add(entity);
|
copy.add(entity);
|
||||||
|
@ -1151,7 +1152,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
entity.getFullSyncPeriod(), entity.getChangedSyncPeriod(), entity.getLastSync()));
|
entity.getFullSyncPeriod(), entity.getChangedSyncPeriod(), entity.getLastSync()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return Collections.unmodifiableList(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1257,7 +1258,11 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getEventsListeners() {
|
public Set<String> getEventsListeners() {
|
||||||
return new HashSet<String>(realm.getEventsListeners());
|
List<String> eventsListeners = realm.getEventsListeners();
|
||||||
|
if (eventsListeners.isEmpty()) return Collections.EMPTY_SET;
|
||||||
|
Set<String> copy = new HashSet<>();
|
||||||
|
copy.addAll(eventsListeners);
|
||||||
|
return Collections.unmodifiableSet(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1272,7 +1277,11 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getEnabledEventTypes() {
|
public Set<String> getEnabledEventTypes() {
|
||||||
return new HashSet<String>(realm.getEnabledEventTypes());
|
List<String> enabledEventTypes = realm.getEnabledEventTypes();
|
||||||
|
if (enabledEventTypes.isEmpty()) return Collections.EMPTY_SET;
|
||||||
|
Set<String> copy = new HashSet<>();
|
||||||
|
copy.addAll(enabledEventTypes);
|
||||||
|
return Collections.unmodifiableSet(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1364,7 +1373,11 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getSupportedLocales() {
|
public Set<String> getSupportedLocales() {
|
||||||
return new HashSet<String>(realm.getSupportedLocales());
|
List<String> supportedLocales = realm.getSupportedLocales();
|
||||||
|
if (supportedLocales == null || supportedLocales.isEmpty()) return Collections.EMPTY_SET;
|
||||||
|
Set<String> copy = new HashSet<>();
|
||||||
|
copy.addAll(supportedLocales);
|
||||||
|
return Collections.unmodifiableSet(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1390,12 +1403,14 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<IdentityProviderMapperModel> getIdentityProviderMappers() {
|
public Set<IdentityProviderMapperModel> getIdentityProviderMappers() {
|
||||||
|
List<IdentityProviderMapperEntity> entities = getMongoEntity().getIdentityProviderMappers();
|
||||||
|
if (entities.isEmpty()) return Collections.EMPTY_SET;
|
||||||
Set<IdentityProviderMapperModel> mappings = new HashSet<IdentityProviderMapperModel>();
|
Set<IdentityProviderMapperModel> mappings = new HashSet<IdentityProviderMapperModel>();
|
||||||
for (IdentityProviderMapperEntity entity : getMongoEntity().getIdentityProviderMappers()) {
|
for (IdentityProviderMapperEntity entity : entities) {
|
||||||
IdentityProviderMapperModel mapping = entityToModel(entity);
|
IdentityProviderMapperModel mapping = entityToModel(entity);
|
||||||
mappings.add(mapping);
|
mappings.add(mapping);
|
||||||
}
|
}
|
||||||
return mappings;
|
return Collections.unmodifiableSet(mappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1568,12 +1583,13 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
@Override
|
@Override
|
||||||
public List<AuthenticationFlowModel> getAuthenticationFlows() {
|
public List<AuthenticationFlowModel> getAuthenticationFlows() {
|
||||||
List<AuthenticationFlowEntity> flows = getMongoEntity().getAuthenticationFlows();
|
List<AuthenticationFlowEntity> flows = getMongoEntity().getAuthenticationFlows();
|
||||||
|
if (flows.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<AuthenticationFlowModel> models = new LinkedList<>();
|
List<AuthenticationFlowModel> models = new LinkedList<>();
|
||||||
for (AuthenticationFlowEntity entity : flows) {
|
for (AuthenticationFlowEntity entity : flows) {
|
||||||
AuthenticationFlowModel model = entityToModel(entity);
|
AuthenticationFlowModel model = entityToModel(entity);
|
||||||
models.add(model);
|
models.add(model);
|
||||||
}
|
}
|
||||||
return models;
|
return Collections.unmodifiableList(models);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1662,7 +1678,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
executions.add(model);
|
executions.add(model);
|
||||||
}
|
}
|
||||||
Collections.sort(executions, AuthenticationExecutionModel.ExecutionComparator.SINGLETON);
|
Collections.sort(executions, AuthenticationExecutionModel.ExecutionComparator.SINGLETON);
|
||||||
return executions;
|
return Collections.unmodifiableList(executions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthenticationExecutionModel entityToModel(AuthenticationExecutionEntity entity) {
|
public AuthenticationExecutionModel entityToModel(AuthenticationExecutionEntity entity) {
|
||||||
|
@ -1752,11 +1768,13 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AuthenticatorConfigModel> getAuthenticatorConfigs() {
|
public List<AuthenticatorConfigModel> getAuthenticatorConfigs() {
|
||||||
|
List<AuthenticatorConfigEntity> entities = getMongoEntity().getAuthenticatorConfigs();
|
||||||
|
if (entities.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<AuthenticatorConfigModel> authenticators = new LinkedList<>();
|
List<AuthenticatorConfigModel> authenticators = new LinkedList<>();
|
||||||
for (AuthenticatorConfigEntity entity : getMongoEntity().getAuthenticatorConfigs()) {
|
for (AuthenticatorConfigEntity entity : entities) {
|
||||||
authenticators.add(entityToModel(entity));
|
authenticators.add(entityToModel(entity));
|
||||||
}
|
}
|
||||||
return authenticators;
|
return Collections.unmodifiableList(authenticators);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1898,11 +1916,13 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RequiredActionProviderModel> getRequiredActionProviders() {
|
public List<RequiredActionProviderModel> getRequiredActionProviders() {
|
||||||
|
List<RequiredActionProviderEntity> entities = realm.getRequiredActionProviders();
|
||||||
|
if (entities.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<RequiredActionProviderModel> actions = new LinkedList<>();
|
List<RequiredActionProviderModel> actions = new LinkedList<>();
|
||||||
for (RequiredActionProviderEntity entity : realm.getRequiredActionProviders()) {
|
for (RequiredActionProviderEntity entity : entities) {
|
||||||
actions.add(entityToModel(entity));
|
actions.add(entityToModel(entity));
|
||||||
}
|
}
|
||||||
return actions;
|
return Collections.unmodifiableList(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RequiredActionProviderEntity getRequiredActionProviderEntity(String id) {
|
public RequiredActionProviderEntity getRequiredActionProviderEntity(String id) {
|
||||||
|
@ -1930,12 +1950,14 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UserFederationMapperModel> getUserFederationMappers() {
|
public Set<UserFederationMapperModel> getUserFederationMappers() {
|
||||||
|
List<UserFederationMapperEntity> entities = getMongoEntity().getUserFederationMappers();
|
||||||
|
if (entities.isEmpty()) return Collections.EMPTY_SET;
|
||||||
Set<UserFederationMapperModel> mappers = new HashSet<UserFederationMapperModel>();
|
Set<UserFederationMapperModel> mappers = new HashSet<UserFederationMapperModel>();
|
||||||
for (UserFederationMapperEntity entity : getMongoEntity().getUserFederationMappers()) {
|
for (UserFederationMapperEntity entity : entities) {
|
||||||
UserFederationMapperModel mapper = entityToModel(entity);
|
UserFederationMapperModel mapper = entityToModel(entity);
|
||||||
mappers.add(mapper);
|
mappers.add(mapper);
|
||||||
}
|
}
|
||||||
return mappers;
|
return Collections.unmodifiableSet(mappers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2053,12 +2075,12 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
||||||
.and("realmId").is(getId())
|
.and("realmId").is(getId())
|
||||||
.get();
|
.get();
|
||||||
List<MongoClientTemplateEntity> clientEntities = getMongoStore().loadEntities(MongoClientTemplateEntity.class, query, invocationContext);
|
List<MongoClientTemplateEntity> clientEntities = getMongoStore().loadEntities(MongoClientTemplateEntity.class, query, invocationContext);
|
||||||
|
if (clientEntities.isEmpty()) return Collections.EMPTY_LIST;
|
||||||
List<ClientTemplateModel> result = new LinkedList<>();
|
List<ClientTemplateModel> result = new LinkedList<>();
|
||||||
for (MongoClientTemplateEntity clientEntity : clientEntities) {
|
for (MongoClientTemplateEntity clientEntity : clientEntities) {
|
||||||
result.add(new ClientTemplateAdapter(session, this, clientEntity, invocationContext));
|
result.add(new ClientTemplateAdapter(session, this, clientEntity, invocationContext));
|
||||||
}
|
}
|
||||||
return result;
|
return Collections.unmodifiableList(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class MigrationTo1_2_0_CR1 {
|
||||||
public static final ModelVersion VERSION = new ModelVersion("1.2.0.CR1");
|
public static final ModelVersion VERSION = new ModelVersion("1.2.0.CR1");
|
||||||
|
|
||||||
public void setupBrokerService(RealmModel realm) {
|
public void setupBrokerService(RealmModel realm) {
|
||||||
ClientModel client = realm.getClientNameMap().get(Constants.BROKER_SERVICE_CLIENT_ID);
|
ClientModel client = realm.getClientByClientId(Constants.BROKER_SERVICE_CLIENT_ID);
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
client = KeycloakModelUtils.createClient(realm, Constants.BROKER_SERVICE_CLIENT_ID);
|
client = KeycloakModelUtils.createClient(realm, Constants.BROKER_SERVICE_CLIENT_ID);
|
||||||
client.setEnabled(true);
|
client.setEnabled(true);
|
||||||
|
@ -52,16 +52,13 @@ public class MigrationTo1_2_0_CR1 {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupClientNames(RealmModel realm) {
|
private void setupClientNames(RealmModel realm) {
|
||||||
Map<String, ClientModel> clients = realm.getClientNameMap();
|
setupClientName(realm.getClientByClientId(Constants.ACCOUNT_MANAGEMENT_CLIENT_ID));
|
||||||
|
setupClientName(realm.getClientByClientId(Constants.ADMIN_CONSOLE_CLIENT_ID));
|
||||||
setupClientName(clients, Constants.ACCOUNT_MANAGEMENT_CLIENT_ID);
|
setupClientName(realm.getClientByClientId(Constants.REALM_MANAGEMENT_CLIENT_ID));
|
||||||
setupClientName(clients, Constants.ADMIN_CONSOLE_CLIENT_ID);
|
|
||||||
setupClientName(clients, Constants.REALM_MANAGEMENT_CLIENT_ID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupClientName(Map<String, ClientModel> clients, String clientId) {
|
private void setupClientName(ClientModel client) {
|
||||||
ClientModel client = clients.get(clientId);
|
if (client != null && client.getName() == null) client.setName("${client_" + client.getClientId() + "}");
|
||||||
if (client != null && client.getName() == null) client.setName("${client_" + clientId + "}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void migrate(KeycloakSession session) {
|
public void migrate(KeycloakSession session) {
|
||||||
|
|
|
@ -193,9 +193,6 @@ public interface RealmModel extends RoleContainerModel {
|
||||||
|
|
||||||
void removeDefaultGroup(GroupModel group);
|
void removeDefaultGroup(GroupModel group);
|
||||||
|
|
||||||
// Key is clientId
|
|
||||||
Map<String, ClientModel> getClientNameMap();
|
|
||||||
|
|
||||||
List<ClientModel> getClients();
|
List<ClientModel> getClients();
|
||||||
|
|
||||||
ClientModel addClient(String name);
|
ClientModel addClient(String name);
|
||||||
|
|
|
@ -44,6 +44,7 @@ import java.security.PublicKey;
|
||||||
import java.security.cert.Certificate;
|
import java.security.cert.Certificate;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -107,16 +108,19 @@ public class CachedRealm implements Serializable {
|
||||||
protected String emailTheme;
|
protected String emailTheme;
|
||||||
protected String masterAdminClient;
|
protected String masterAdminClient;
|
||||||
|
|
||||||
protected List<RequiredCredentialModel> requiredCredentials = new ArrayList<RequiredCredentialModel>();
|
protected List<RequiredCredentialModel> requiredCredentials;
|
||||||
protected List<UserFederationProviderModel> userFederationProviders = new ArrayList<UserFederationProviderModel>();
|
protected List<UserFederationProviderModel> userFederationProviders;
|
||||||
protected MultivaluedHashMap<String, UserFederationMapperModel> userFederationMappers = new MultivaluedHashMap<String, UserFederationMapperModel>();
|
protected MultivaluedHashMap<String, UserFederationMapperModel> userFederationMappers = new MultivaluedHashMap<String, UserFederationMapperModel>();
|
||||||
protected List<IdentityProviderModel> identityProviders = new ArrayList<IdentityProviderModel>();
|
protected Set<UserFederationMapperModel> userFederationMapperSet;
|
||||||
|
protected List<IdentityProviderModel> identityProviders;
|
||||||
|
|
||||||
protected Map<String, String> browserSecurityHeaders = new HashMap<String, String>();
|
protected Map<String, String> browserSecurityHeaders;
|
||||||
protected Map<String, String> smtpConfig = new HashMap<String, String>();
|
protected Map<String, String> smtpConfig;
|
||||||
protected Map<String, AuthenticationFlowModel> authenticationFlows = new HashMap<>();
|
protected Map<String, AuthenticationFlowModel> authenticationFlows = new HashMap<>();
|
||||||
|
protected List<AuthenticationFlowModel> authenticationFlowList;
|
||||||
protected Map<String, AuthenticatorConfigModel> authenticatorConfigs = new HashMap<>();
|
protected Map<String, AuthenticatorConfigModel> authenticatorConfigs = new HashMap<>();
|
||||||
protected Map<String, RequiredActionProviderModel> requiredActionProviders = new HashMap<>();
|
protected Map<String, RequiredActionProviderModel> requiredActionProviders = new HashMap<>();
|
||||||
|
protected List<RequiredActionProviderModel> requiredActionProviderList;
|
||||||
protected Map<String, RequiredActionProviderModel> requiredActionProvidersByAlias = new HashMap<>();
|
protected Map<String, RequiredActionProviderModel> requiredActionProvidersByAlias = new HashMap<>();
|
||||||
protected MultivaluedHashMap<String, AuthenticationExecutionModel> authenticationExecutions = new MultivaluedHashMap<>();
|
protected MultivaluedHashMap<String, AuthenticationExecutionModel> authenticationExecutions = new MultivaluedHashMap<>();
|
||||||
protected Map<String, AuthenticationExecutionModel> executionsById = new HashMap<>();
|
protected Map<String, AuthenticationExecutionModel> executionsById = new HashMap<>();
|
||||||
|
@ -129,21 +133,27 @@ public class CachedRealm implements Serializable {
|
||||||
|
|
||||||
protected boolean eventsEnabled;
|
protected boolean eventsEnabled;
|
||||||
protected long eventsExpiration;
|
protected long eventsExpiration;
|
||||||
protected Set<String> eventsListeners = new HashSet<String>();
|
protected Set<String> eventsListeners;
|
||||||
protected Set<String> enabledEventTypes = new HashSet<String>();
|
protected Set<String> enabledEventTypes;
|
||||||
protected boolean adminEventsEnabled;
|
protected boolean adminEventsEnabled;
|
||||||
protected Set<String> adminEnabledEventOperations = new HashSet<String>();
|
protected Set<String> adminEnabledEventOperations = new HashSet<String>();
|
||||||
protected boolean adminEventsDetailsEnabled;
|
protected boolean adminEventsDetailsEnabled;
|
||||||
protected List<String> defaultRoles = new LinkedList<String>();
|
protected List<String> defaultRoles;
|
||||||
|
|
||||||
|
public Set<IdentityProviderMapperModel> getIdentityProviderMapperSet() {
|
||||||
|
return identityProviderMapperSet;
|
||||||
|
}
|
||||||
|
|
||||||
protected List<String> defaultGroups = new LinkedList<String>();
|
protected List<String> defaultGroups = new LinkedList<String>();
|
||||||
protected Set<String> groups = new HashSet<String>();
|
protected Set<String> groups = new HashSet<String>();
|
||||||
protected Map<String, String> realmRoles = new HashMap<String, String>();
|
protected Map<String, String> realmRoles = new HashMap<String, String>();
|
||||||
protected Map<String, String> clients = new HashMap<String, String>();
|
protected List<String> clients = new LinkedList<>();
|
||||||
protected List<String> clientTemplates= new LinkedList<>();
|
protected List<String> clientTemplates= new LinkedList<>();
|
||||||
protected boolean internationalizationEnabled;
|
protected boolean internationalizationEnabled;
|
||||||
protected Set<String> supportedLocales = new HashSet<String>();
|
protected Set<String> supportedLocales;
|
||||||
protected String defaultLocale;
|
protected String defaultLocale;
|
||||||
protected MultivaluedHashMap<String, IdentityProviderMapperModel> identityProviderMappers = new MultivaluedHashMap<>();
|
protected MultivaluedHashMap<String, IdentityProviderMapperModel> identityProviderMappers = new MultivaluedHashMap<>();
|
||||||
|
protected Set<IdentityProviderMapperModel> identityProviderMapperSet;
|
||||||
|
|
||||||
public CachedRealm() {
|
public CachedRealm() {
|
||||||
}
|
}
|
||||||
|
@ -200,8 +210,9 @@ public class CachedRealm implements Serializable {
|
||||||
|
|
||||||
requiredCredentials = model.getRequiredCredentials();
|
requiredCredentials = model.getRequiredCredentials();
|
||||||
userFederationProviders = model.getUserFederationProviders();
|
userFederationProviders = model.getUserFederationProviders();
|
||||||
for (UserFederationMapperModel mapper : model.getUserFederationMappers()) {
|
userFederationMapperSet = model.getUserFederationMappers();
|
||||||
userFederationMappers.add(mapper.getFederationProviderId(), mapper);
|
for (UserFederationMapperModel mapper : userFederationMapperSet) {
|
||||||
|
this.userFederationMappers.add(mapper.getFederationProviderId(), mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.identityProviders = new ArrayList<>();
|
this.identityProviders = new ArrayList<>();
|
||||||
|
@ -209,25 +220,27 @@ public class CachedRealm implements Serializable {
|
||||||
for (IdentityProviderModel identityProviderModel : model.getIdentityProviders()) {
|
for (IdentityProviderModel identityProviderModel : model.getIdentityProviders()) {
|
||||||
this.identityProviders.add(new IdentityProviderModel(identityProviderModel));
|
this.identityProviders.add(new IdentityProviderModel(identityProviderModel));
|
||||||
}
|
}
|
||||||
|
this.identityProviders = Collections.unmodifiableList(this.identityProviders);
|
||||||
|
|
||||||
for (IdentityProviderMapperModel mapper : model.getIdentityProviderMappers()) {
|
this.identityProviderMapperSet = model.getIdentityProviderMappers();
|
||||||
|
for (IdentityProviderMapperModel mapper : identityProviderMapperSet) {
|
||||||
identityProviderMappers.add(mapper.getIdentityProviderAlias(), mapper);
|
identityProviderMappers.add(mapper.getIdentityProviderAlias(), mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
smtpConfig.putAll(model.getSmtpConfig());
|
smtpConfig = model.getSmtpConfig();
|
||||||
browserSecurityHeaders.putAll(model.getBrowserSecurityHeaders());
|
browserSecurityHeaders = model.getBrowserSecurityHeaders();
|
||||||
|
|
||||||
eventsEnabled = model.isEventsEnabled();
|
eventsEnabled = model.isEventsEnabled();
|
||||||
eventsExpiration = model.getEventsExpiration();
|
eventsExpiration = model.getEventsExpiration();
|
||||||
eventsListeners.addAll(model.getEventsListeners());
|
eventsListeners = model.getEventsListeners();
|
||||||
enabledEventTypes.addAll(model.getEnabledEventTypes());
|
enabledEventTypes = model.getEnabledEventTypes();
|
||||||
|
|
||||||
adminEventsEnabled = model.isAdminEventsEnabled();
|
adminEventsEnabled = model.isAdminEventsEnabled();
|
||||||
adminEventsDetailsEnabled = model.isAdminEventsDetailsEnabled();
|
adminEventsDetailsEnabled = model.isAdminEventsDetailsEnabled();
|
||||||
|
|
||||||
defaultRoles.addAll(model.getDefaultRoles());
|
defaultRoles = model.getDefaultRoles();
|
||||||
ClientModel masterAdminClient = model.getMasterAdminClient();
|
ClientModel masterAdminClient = model.getMasterAdminClient();
|
||||||
this.masterAdminClient = (masterAdminClient != null) ? masterAdminClient.getId() : null;
|
this.masterAdminClient = (masterAdminClient != null) ? masterAdminClient.getId() : null;
|
||||||
|
|
||||||
|
@ -238,10 +251,11 @@ public class CachedRealm implements Serializable {
|
||||||
cacheClientTemplates(cache, delegate, model);
|
cacheClientTemplates(cache, delegate, model);
|
||||||
|
|
||||||
internationalizationEnabled = model.isInternationalizationEnabled();
|
internationalizationEnabled = model.isInternationalizationEnabled();
|
||||||
supportedLocales.addAll(model.getSupportedLocales());
|
supportedLocales = model.getSupportedLocales();
|
||||||
defaultLocale = model.getDefaultLocale();
|
defaultLocale = model.getDefaultLocale();
|
||||||
for (AuthenticationFlowModel flow : model.getAuthenticationFlows()) {
|
authenticationFlowList = model.getAuthenticationFlows();
|
||||||
authenticationFlows.put(flow.getId(), flow);
|
for (AuthenticationFlowModel flow : authenticationFlowList) {
|
||||||
|
this.authenticationFlows.put(flow.getId(), flow);
|
||||||
authenticationExecutions.put(flow.getId(), new LinkedList<AuthenticationExecutionModel>());
|
authenticationExecutions.put(flow.getId(), new LinkedList<AuthenticationExecutionModel>());
|
||||||
for (AuthenticationExecutionModel execution : model.getAuthenticationExecutions(flow.getId())) {
|
for (AuthenticationExecutionModel execution : model.getAuthenticationExecutions(flow.getId())) {
|
||||||
authenticationExecutions.add(flow.getId(), execution);
|
authenticationExecutions.add(flow.getId(), execution);
|
||||||
|
@ -254,8 +268,9 @@ public class CachedRealm implements Serializable {
|
||||||
for (AuthenticatorConfigModel authenticator : model.getAuthenticatorConfigs()) {
|
for (AuthenticatorConfigModel authenticator : model.getAuthenticatorConfigs()) {
|
||||||
authenticatorConfigs.put(authenticator.getId(), authenticator);
|
authenticatorConfigs.put(authenticator.getId(), authenticator);
|
||||||
}
|
}
|
||||||
for (RequiredActionProviderModel action : model.getRequiredActionProviders()) {
|
requiredActionProviderList = model.getRequiredActionProviders();
|
||||||
requiredActionProviders.put(action.getId(), action);
|
for (RequiredActionProviderModel action : requiredActionProviderList) {
|
||||||
|
this.requiredActionProviders.put(action.getId(), action);
|
||||||
requiredActionProvidersByAlias.put(action.getAlias(), action);
|
requiredActionProvidersByAlias.put(action.getAlias(), action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +296,7 @@ public class CachedRealm implements Serializable {
|
||||||
|
|
||||||
protected void cacheClients(RealmCache cache, RealmProvider delegate, RealmModel model) {
|
protected void cacheClients(RealmCache cache, RealmProvider delegate, RealmModel model) {
|
||||||
for (ClientModel client : model.getClients()) {
|
for (ClientModel client : model.getClients()) {
|
||||||
clients.put(client.getClientId(), client.getId());
|
clients.add(client.getId());
|
||||||
CachedClient cachedClient = new CachedClient(cache, delegate, model, client);
|
CachedClient cachedClient = new CachedClient(cache, delegate, model, client);
|
||||||
cache.addClient(cachedClient);
|
cache.addClient(cachedClient);
|
||||||
}
|
}
|
||||||
|
@ -324,7 +339,7 @@ public class CachedRealm implements Serializable {
|
||||||
return realmRoles;
|
return realmRoles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getClients() {
|
public List<String> getClients() {
|
||||||
return clients;
|
return clients;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,4 +621,16 @@ public class CachedRealm implements Serializable {
|
||||||
public X509Certificate getCertificate() {
|
public X509Certificate getCertificate() {
|
||||||
return certificate;
|
return certificate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<UserFederationMapperModel> getUserFederationMapperSet() {
|
||||||
|
return userFederationMapperSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AuthenticationFlowModel> getAuthenticationFlowList() {
|
||||||
|
return authenticationFlowList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RequiredActionProviderModel> getRequiredActionProviderList() {
|
||||||
|
return requiredActionProviderList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,6 +400,9 @@ public class ModelToRepresentation {
|
||||||
rep.setRequiredActions(new LinkedList<RequiredActionProviderRepresentation>());
|
rep.setRequiredActions(new LinkedList<RequiredActionProviderRepresentation>());
|
||||||
|
|
||||||
List<RequiredActionProviderModel> requiredActionProviders = realm.getRequiredActionProviders();
|
List<RequiredActionProviderModel> requiredActionProviders = realm.getRequiredActionProviders();
|
||||||
|
List<RequiredActionProviderModel> copy = new LinkedList<>();
|
||||||
|
copy.addAll(requiredActionProviders);
|
||||||
|
requiredActionProviders = copy;
|
||||||
//ensure consistent ordering of requiredActionProviders.
|
//ensure consistent ordering of requiredActionProviders.
|
||||||
Collections.sort(requiredActionProviders, new Comparator<RequiredActionProviderModel>() {
|
Collections.sort(requiredActionProviders, new Comparator<RequiredActionProviderModel>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -234,12 +234,12 @@ public class RepresentationToModel {
|
||||||
|
|
||||||
// Now that all possible roles and clients are created, create scope mappings
|
// Now that all possible roles and clients are created, create scope mappings
|
||||||
|
|
||||||
Map<String, ClientModel> appMap = newRealm.getClientNameMap();
|
//Map<String, ClientModel> appMap = newRealm.getClientNameMap();
|
||||||
|
|
||||||
if (rep.getClientScopeMappings() != null) {
|
if (rep.getClientScopeMappings() != null) {
|
||||||
|
|
||||||
for (Map.Entry<String, List<ScopeMappingRepresentation>> entry : rep.getClientScopeMappings().entrySet()) {
|
for (Map.Entry<String, List<ScopeMappingRepresentation>> entry : rep.getClientScopeMappings().entrySet()) {
|
||||||
ClientModel app = appMap.get(entry.getKey());
|
ClientModel app = newRealm.getClientByClientId(entry.getKey());
|
||||||
if (app == null) {
|
if (app == null) {
|
||||||
throw new RuntimeException("Unable to find client role mappings for client: " + entry.getKey());
|
throw new RuntimeException("Unable to find client role mappings for client: " + entry.getKey());
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ public class RepresentationToModel {
|
||||||
|
|
||||||
if (rep.getUsers() != null) {
|
if (rep.getUsers() != null) {
|
||||||
for (UserRepresentation userRep : rep.getUsers()) {
|
for (UserRepresentation userRep : rep.getUsers()) {
|
||||||
UserModel user = createUser(session, newRealm, userRep, appMap);
|
UserModel user = createUser(session, newRealm, userRep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,14 +383,13 @@ public class RepresentationToModel {
|
||||||
List<GroupRepresentation> groups = rep.getGroups();
|
List<GroupRepresentation> groups = rep.getGroups();
|
||||||
if (groups == null) return;
|
if (groups == null) return;
|
||||||
|
|
||||||
Map<String, ClientModel> clientMap = realm.getClientNameMap();
|
|
||||||
GroupModel parent = null;
|
GroupModel parent = null;
|
||||||
for (GroupRepresentation group : groups) {
|
for (GroupRepresentation group : groups) {
|
||||||
importGroup(realm, clientMap, parent, group);
|
importGroup(realm, parent, group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void importGroup(RealmModel realm, Map<String, ClientModel> clientMap, GroupModel parent, GroupRepresentation group) {
|
public static void importGroup(RealmModel realm, GroupModel parent, GroupRepresentation group) {
|
||||||
GroupModel newGroup = realm.createGroup(group.getId(), group.getName());
|
GroupModel newGroup = realm.createGroup(group.getId(), group.getName());
|
||||||
if (group.getAttributes() != null) {
|
if (group.getAttributes() != null) {
|
||||||
for (Map.Entry<String, List<String>> attr : group.getAttributes().entrySet()) {
|
for (Map.Entry<String, List<String>> attr : group.getAttributes().entrySet()) {
|
||||||
|
@ -410,7 +409,7 @@ public class RepresentationToModel {
|
||||||
}
|
}
|
||||||
if (group.getClientRoles() != null) {
|
if (group.getClientRoles() != null) {
|
||||||
for (Map.Entry<String, List<String>> entry : group.getClientRoles().entrySet()) {
|
for (Map.Entry<String, List<String>> entry : group.getClientRoles().entrySet()) {
|
||||||
ClientModel client = clientMap.get(entry.getKey());
|
ClientModel client = realm.getClientByClientId(entry.getKey());
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
throw new RuntimeException("Unable to find client role mappings for client: " + entry.getKey());
|
throw new RuntimeException("Unable to find client role mappings for client: " + entry.getKey());
|
||||||
}
|
}
|
||||||
|
@ -427,7 +426,7 @@ public class RepresentationToModel {
|
||||||
}
|
}
|
||||||
if (group.getSubGroups() != null) {
|
if (group.getSubGroups() != null) {
|
||||||
for (GroupRepresentation subGroup : group.getSubGroups()) {
|
for (GroupRepresentation subGroup : group.getSubGroups()) {
|
||||||
importGroup(realm, clientMap, newGroup, subGroup);
|
importGroup(realm, newGroup, subGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1180,7 +1179,7 @@ public class RepresentationToModel {
|
||||||
|
|
||||||
// Users
|
// Users
|
||||||
|
|
||||||
public static UserModel createUser(KeycloakSession session, RealmModel newRealm, UserRepresentation userRep, Map<String, ClientModel> clientMap) {
|
public static UserModel createUser(KeycloakSession session, RealmModel newRealm, UserRepresentation userRep) {
|
||||||
convertDeprecatedSocialProviders(userRep);
|
convertDeprecatedSocialProviders(userRep);
|
||||||
|
|
||||||
// Import users just to user storage. Don't federate
|
// Import users just to user storage. Don't federate
|
||||||
|
@ -1228,7 +1227,7 @@ public class RepresentationToModel {
|
||||||
}
|
}
|
||||||
if (userRep.getServiceAccountClientId() != null) {
|
if (userRep.getServiceAccountClientId() != null) {
|
||||||
String clientId = userRep.getServiceAccountClientId();
|
String clientId = userRep.getServiceAccountClientId();
|
||||||
ClientModel client = clientMap.get(clientId);
|
ClientModel client = newRealm.getClientByClientId(clientId);
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
throw new RuntimeException("Unable to find client specified for service account link. Client: " + clientId);
|
throw new RuntimeException("Unable to find client specified for service account link. Client: " + clientId);
|
||||||
}
|
}
|
||||||
|
@ -1316,9 +1315,8 @@ public class RepresentationToModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (userRep.getClientRoles() != null) {
|
if (userRep.getClientRoles() != null) {
|
||||||
Map<String, ClientModel> clientMap = realm.getClientNameMap();
|
|
||||||
for (Map.Entry<String, List<String>> entry : userRep.getClientRoles().entrySet()) {
|
for (Map.Entry<String, List<String>> entry : userRep.getClientRoles().entrySet()) {
|
||||||
ClientModel client = clientMap.get(entry.getKey());
|
ClientModel client = realm.getClientByClientId(entry.getKey());
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
throw new RuntimeException("Unable to find client role mappings for client: " + entry.getKey());
|
throw new RuntimeException("Unable to find client role mappings for client: " + entry.getKey());
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,9 +199,8 @@ public class ImportUtils {
|
||||||
|
|
||||||
private static void importUsers(KeycloakSession session, RealmProvider model, String realmName, List<UserRepresentation> userReps) {
|
private static void importUsers(KeycloakSession session, RealmProvider model, String realmName, List<UserRepresentation> userReps) {
|
||||||
RealmModel realm = model.getRealmByName(realmName);
|
RealmModel realm = model.getRealmByName(realmName);
|
||||||
Map<String, ClientModel> apps = realm.getClientNameMap();
|
|
||||||
for (UserRepresentation user : userReps) {
|
for (UserRepresentation user : userReps) {
|
||||||
RepresentationToModel.createUser(session, realm, user, apps);
|
RepresentationToModel.createUser(session, realm, user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
services/src/main/java/org/keycloak/partialimport/UsersPartialImport.java
Normal file → Executable file
3
services/src/main/java/org/keycloak/partialimport/UsersPartialImport.java
Normal file → Executable file
|
@ -107,9 +107,8 @@ public class UsersPartialImport extends AbstractPartialImport<UserRepresentation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create(RealmModel realm, KeycloakSession session, UserRepresentation user) {
|
public void create(RealmModel realm, KeycloakSession session, UserRepresentation user) {
|
||||||
Map<String, ClientModel> apps = realm.getClientNameMap();
|
|
||||||
user.setId(KeycloakModelUtils.generateId());
|
user.setId(KeycloakModelUtils.generateId());
|
||||||
UserModel userModel = RepresentationToModel.createUser(session, realm, user, apps);
|
UserModel userModel = RepresentationToModel.createUser(session, realm, user);
|
||||||
if (userModel == null) throw new RuntimeException("Unable to create user " + getName(user));
|
if (userModel == null) throw new RuntimeException("Unable to create user " + getName(user));
|
||||||
createdIds.put(getName(user), userModel.getId());
|
createdIds.put(getName(user), userModel.getId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,7 +327,7 @@ public class RealmManager implements RealmImporter {
|
||||||
|
|
||||||
|
|
||||||
private void setupAccountManagement(RealmModel realm) {
|
private void setupAccountManagement(RealmModel realm) {
|
||||||
ClientModel client = realm.getClientNameMap().get(Constants.ACCOUNT_MANAGEMENT_CLIENT_ID);
|
ClientModel client = realm.getClientByClientId(Constants.ACCOUNT_MANAGEMENT_CLIENT_ID);
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
client = KeycloakModelUtils.createClient(realm, Constants.ACCOUNT_MANAGEMENT_CLIENT_ID);
|
client = KeycloakModelUtils.createClient(realm, Constants.ACCOUNT_MANAGEMENT_CLIENT_ID);
|
||||||
client.setName("${client_" + Constants.ACCOUNT_MANAGEMENT_CLIENT_ID + "}");
|
client.setName("${client_" + Constants.ACCOUNT_MANAGEMENT_CLIENT_ID + "}");
|
||||||
|
@ -352,7 +352,7 @@ public class RealmManager implements RealmImporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupBrokerService(RealmModel realm) {
|
public void setupBrokerService(RealmModel realm) {
|
||||||
ClientModel client = realm.getClientNameMap().get(Constants.BROKER_SERVICE_CLIENT_ID);
|
ClientModel client = realm.getClientByClientId(Constants.BROKER_SERVICE_CLIENT_ID);
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
client = KeycloakModelUtils.createClient(realm, Constants.BROKER_SERVICE_CLIENT_ID);
|
client = KeycloakModelUtils.createClient(realm, Constants.BROKER_SERVICE_CLIENT_ID);
|
||||||
client.setEnabled(true);
|
client.setEnabled(true);
|
||||||
|
|
|
@ -139,7 +139,7 @@ public class RealmsResource {
|
||||||
public AccountService getAccountService(final @PathParam("realm") String name) {
|
public AccountService getAccountService(final @PathParam("realm") String name) {
|
||||||
RealmModel realm = init(name);
|
RealmModel realm = init(name);
|
||||||
|
|
||||||
ClientModel client = realm.getClientNameMap().get(Constants.ACCOUNT_MANAGEMENT_CLIENT_ID);
|
ClientModel client = realm.getClientByClientId(Constants.ACCOUNT_MANAGEMENT_CLIENT_ID);
|
||||||
if (client == null || !client.isEnabled()) {
|
if (client == null || !client.isEnabled()) {
|
||||||
logger.debug("account management not enabled");
|
logger.debug("account management not enabled");
|
||||||
throw new NotFoundException("account management not enabled");
|
throw new NotFoundException("account management not enabled");
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class AccountTest {
|
||||||
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
||||||
UserModel user = manager.getSession().users().getUserByUsername("test-user@localhost", appRealm);
|
UserModel user = manager.getSession().users().getUserByUsername("test-user@localhost", appRealm);
|
||||||
|
|
||||||
ClientModel accountApp = appRealm.getClientNameMap().get(org.keycloak.models.Constants.ACCOUNT_MANAGEMENT_CLIENT_ID);
|
ClientModel accountApp = appRealm.getClientByClientId(org.keycloak.models.Constants.ACCOUNT_MANAGEMENT_CLIENT_ID);
|
||||||
|
|
||||||
UserModel user2 = manager.getSession().users().addUser(appRealm, "test-user-no-access@localhost");
|
UserModel user2 = manager.getSession().users().addUser(appRealm, "test-user-no-access@localhost");
|
||||||
user2.setEnabled(true);
|
user2.setEnabled(true);
|
||||||
|
|
|
@ -46,6 +46,8 @@ import javax.mail.internet.MimeMessage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
@ -542,8 +544,11 @@ public class ResetPasswordTest {
|
||||||
keycloakRule.configure(new KeycloakRule.KeycloakSetup() {
|
keycloakRule.configure(new KeycloakRule.KeycloakSetup() {
|
||||||
@Override
|
@Override
|
||||||
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
||||||
host[0] = appRealm.getSmtpConfig().get("host");
|
Map<String, String> smtpConfig = new HashMap<>();
|
||||||
appRealm.getSmtpConfig().put("host", "invalid_host");
|
smtpConfig.putAll(appRealm.getSmtpConfig());
|
||||||
|
host[0] = smtpConfig.get("host");
|
||||||
|
smtpConfig.put("host", "invalid_host");
|
||||||
|
appRealm.setSmtpConfig(smtpConfig);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -568,7 +573,10 @@ public class ResetPasswordTest {
|
||||||
keycloakRule.configure(new KeycloakRule.KeycloakSetup() {
|
keycloakRule.configure(new KeycloakRule.KeycloakSetup() {
|
||||||
@Override
|
@Override
|
||||||
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
||||||
appRealm.getSmtpConfig().put("host",host[0]);
|
Map<String, String> smtpConfig = new HashMap<>();
|
||||||
|
smtpConfig.putAll(appRealm.getSmtpConfig());
|
||||||
|
smtpConfig.put("host",host[0]);
|
||||||
|
appRealm.setSmtpConfig(smtpConfig);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class ClientModelTest extends AbstractModelTest {
|
||||||
public void persist() {
|
public void persist() {
|
||||||
RealmModel persisted = realmManager.getRealm(realm.getId());
|
RealmModel persisted = realmManager.getRealm(realm.getId());
|
||||||
|
|
||||||
ClientModel actual = persisted.getClientNameMap().get("app-name");
|
ClientModel actual = persisted.getClientByClientId("app-name");
|
||||||
assertEquals(client, actual);
|
assertEquals(client, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,12 +118,12 @@ public class ImportTest extends AbstractModelTest {
|
||||||
Assert.assertNotNull(application);
|
Assert.assertNotNull(application);
|
||||||
Assert.assertNotNull(otherApp);
|
Assert.assertNotNull(otherApp);
|
||||||
Assert.assertNull(nonExisting);
|
Assert.assertNull(nonExisting);
|
||||||
Map<String, ClientModel> clients = realm.getClientNameMap();
|
List<ClientModel> clients = realm.getClients();
|
||||||
Assert.assertEquals(8, clients.size());
|
Assert.assertEquals(8, clients.size());
|
||||||
Assert.assertTrue(clients.values().contains(application));
|
Assert.assertTrue(clients.contains(application));
|
||||||
Assert.assertTrue(clients.values().contains(otherApp));
|
Assert.assertTrue(clients.contains(otherApp));
|
||||||
Assert.assertTrue(clients.values().contains(accountApp));
|
Assert.assertTrue(clients.contains(accountApp));
|
||||||
realm.getClients().containsAll(clients.values());
|
realm.getClients().containsAll(clients);
|
||||||
|
|
||||||
Assert.assertEquals("Applicationn", application.getName());
|
Assert.assertEquals("Applicationn", application.getName());
|
||||||
Assert.assertEquals(50, application.getNodeReRegistrationTimeout());
|
Assert.assertEquals(50, application.getNodeReRegistrationTimeout());
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class AuthorizationCodeTest {
|
||||||
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
||||||
@Override
|
@Override
|
||||||
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
||||||
appRealm.getClientNameMap().get("test-app").addRedirectUri(Constants.INSTALLED_APP_URN);
|
appRealm.getClientByClientId("test-app").addRedirectUri(Constants.INSTALLED_APP_URN);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
oauth.redirectUri(Constants.INSTALLED_APP_URN);
|
oauth.redirectUri(Constants.INSTALLED_APP_URN);
|
||||||
|
@ -110,7 +110,7 @@ public class AuthorizationCodeTest {
|
||||||
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
||||||
@Override
|
@Override
|
||||||
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
||||||
appRealm.getClientNameMap().get("test-app").removeRedirectUri(Constants.INSTALLED_APP_URN);
|
appRealm.getClientByClientId("test-app").removeRedirectUri(Constants.INSTALLED_APP_URN);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class OAuthRedirectUriTest {
|
||||||
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
||||||
@Override
|
@Override
|
||||||
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
||||||
appRealm.getClientNameMap().get("test-app").addRedirectUri("http://localhost:8081/app2");
|
appRealm.getClientByClientId("test-app").addRedirectUri("http://localhost:8081/app2");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ public class OAuthRedirectUriTest {
|
||||||
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
||||||
@Override
|
@Override
|
||||||
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
||||||
appRealm.getClientNameMap().get("test-app").removeRedirectUri("http://localhost:8081/app2");
|
appRealm.getClientByClientId("test-app").removeRedirectUri("http://localhost:8081/app2");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ public class OAuthRedirectUriTest {
|
||||||
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
||||||
@Override
|
@Override
|
||||||
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
||||||
appRealm.getClientNameMap().get("test-app").removeRedirectUri("http://localhost:8081/app/*");
|
appRealm.getClientByClientId("test-app").removeRedirectUri("http://localhost:8081/app/*");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ public class OAuthRedirectUriTest {
|
||||||
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
||||||
@Override
|
@Override
|
||||||
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
||||||
appRealm.getClientNameMap().get("test-app").addRedirectUri("http://localhost:8081/app/*");
|
appRealm.getClientByClientId("test-app").addRedirectUri("http://localhost:8081/app/*");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ public class OAuthRedirectUriTest {
|
||||||
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
||||||
@Override
|
@Override
|
||||||
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
||||||
appRealm.getClientNameMap().get("test-app").removeRedirectUri("http://localhost:8081/app/*");
|
appRealm.getClientByClientId("test-app").removeRedirectUri("http://localhost:8081/app/*");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ public class OAuthRedirectUriTest {
|
||||||
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
keycloakRule.update(new KeycloakRule.KeycloakSetup() {
|
||||||
@Override
|
@Override
|
||||||
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
|
||||||
appRealm.getClientNameMap().get("test-app").addRedirectUri("http://localhost:8081/app/*");
|
appRealm.getClientByClientId("test-app").addRedirectUri("http://localhost:8081/app/*");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue