@Override public void setAttribute(String name, String value) { getDelegateForUpdate(); updated.setAttribute(name, value); }
@Override public int hashCode() { return getId().hashCode(); }
@Override public boolean hasScope(RoleModel role) { if (isUpdated()) return updated.hasScope(role); if (cached.getScope().contains(role.getId())) return true; Set<RoleModel> roles = getScopeMappings(); for (RoleModel mapping : roles) { if (mapping.hasRole(role)) return true; } return false; }
@Override public Map<String, String> getAttributes() { if (isUpdated()) return updated.getAttributes(); Map<String, String> copy = new HashMap<String, String>(); copy.putAll(cached.getAttributes()); return copy; }
private void invalidateClientScope(String id) { invalidations.add(id); ClientScopeAdapter adapter = managedClientScopes.get(id); if (adapter != null) adapter.invalidate(); }
public Set<RoleModel> getRealmScopeMappings() { Set<RoleModel> roleMappings = getScopeMappings(); Set<RoleModel> appRoles = new HashSet<RoleModel>(); for (RoleModel role : roleMappings) { RoleContainerModel container = role.getContainer(); if (container instanceof RealmModel) { if (((RealmModel) container).getId().equals(cachedRealm.getId())) { appRoles.add(role); } } } return appRoles; }
@Override public ClientScopeModel getClientScopeById(String id, RealmModel realm) { CachedClientScope cached = cache.get(id, CachedClientScope.class); if (cached != null && !cached.getRealm().equals(realm.getId())) { cached = null; } if (cached == null) { Long loaded = cache.getCurrentRevision(id); ClientScopeModel model = getRealmDelegate().getClientScopeById(id, realm); if (model == null) return null; if (invalidations.contains(id)) return model; cached = new CachedClientScope(loaded, realm, model); cache.addRevisioned(cached, startupRevision); } else if (invalidations.contains(id)) { return getRealmDelegate().getClientScopeById(id, realm); } else if (managedClientScopes.containsKey(id)) { return managedClientScopes.get(id); } ClientScopeAdapter adapter = new ClientScopeAdapter(realm, cached, this); managedClientScopes.put(id, adapter); return adapter; }
@Override public String getAttribute(String name) { if (isUpdated()) return updated.getAttribute(name); return cached.getAttributes().get(name); }
private void roleRemovalInvalidations(String roleId, String roleName, String roleContainerId) { Set<String> newInvalidations = new HashSet<>(); cache.roleRemoval(roleId, roleName, roleContainerId, newInvalidations); invalidations.addAll(newInvalidations); // need to make sure that scope and group mapping clients and groups are invalidated for (String id : newInvalidations) { ClientModel adapter = managedApplications.get(id); if (adapter != null && adapter instanceof ClientAdapter){ ((ClientAdapter)adapter).invalidate(); continue; } GroupAdapter group = managedGroups.get(id); if (group != null) { group.invalidate(); continue; } ClientScopeAdapter clientScope = managedClientScopes.get(id); if (clientScope != null) { clientScope.invalidate(); continue; } RoleAdapter role = managedRoles.get(id); if (role != null) { role.invalidate(); continue; } } }
@Override public void setProtocol(String protocol) { getDelegateForUpdate(); updated.setProtocol(protocol); }
@Override public String getId() { if (isUpdated()) return updated.getId(); return cached.getId(); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof ClientModel)) return false; ClientScopeModel that = (ClientScopeModel) o; return that.getId().equals(getId()); }
@Override public ProtocolMapperModel addProtocolMapper(ProtocolMapperModel model) { getDelegateForUpdate(); return updated.addProtocolMapper(model); }
@Override public String getName() { if (isUpdated()) return updated.getName(); return cached.getName(); }
@Override public void updateProtocolMapper(ProtocolMapperModel mapping) { getDelegateForUpdate(); updated.updateProtocolMapper(mapping); }
@Override public Set<ProtocolMapperModel> getProtocolMappers() { if (isUpdated()) return updated.getProtocolMappers(); return cached.getProtocolMappers(); }
@Override public void setDescription(String description) { getDelegateForUpdate(); updated.setDescription(description); }
@Override public String getDescription() { if (isUpdated()) return updated.getDescription(); return cached.getDescription(); }
public void deleteScopeMapping(RoleModel role) { getDelegateForUpdate(); updated.deleteScopeMapping(role); }