@Override public Map<String, String> getAttributes() { if (updated != null) return updated.getAttributes(); Map<String, String> copy = new HashMap<String, String>(); copy.putAll(cached.getAttributes()); return copy; }
@Override public String getDescription() { if (updated != null) return updated.getDescription(); return cached.getDescription(); }
@Override public ClientTemplateModel getClientTemplateById(String id, RealmModel realm) { if (!cache.isEnabled()) return getDelegate().getClientTemplateById(id, realm); CachedClientTemplate cached = cache.getClientTemplate(id); if (cached != null && !cached.getRealm().equals(realm.getId())) { cached = null; } if (cached == null) { ClientTemplateModel model = getDelegate().getClientTemplateById(id, realm); if (model == null) return null; if (clientTemplateInvalidations.contains(id)) return model; cached = new CachedClientTemplate(cache, getDelegate(), realm, model); cache.addCachedClientTemplate(cached); } else if (clientTemplateInvalidations.contains(id)) { return getDelegate().getClientTemplateById(id, realm); } else if (managedClientTemplates.containsKey(id)) { return managedClientTemplates.get(id); } ClientTemplateModel adapter = new ClientTemplateAdapter(realm, cached, this, cache); managedClientTemplates.put(id, adapter); return adapter; }
@Override public boolean hasScope(RoleModel role) { if (updated != null) return updated.hasScope(role); if (cached.isFullScopeAllowed() || cached.getScope().contains(role.getId())) return true; Set<RoleModel> roles = getScopeMappings(); for (RoleModel mapping : roles) { if (mapping.hasRole(role)) return true; } return false; }
CachedClientTemplate cachedClient = new CachedClientTemplate(cache, delegate, model, template); cache.addCachedClientTemplate(cachedClient);
@Override public Set<ProtocolMapperModel> getProtocolMappers() { if (updated != null) return updated.getProtocolMappers(); return cached.getProtocolMappers(); }
@Override public String getName() { if (updated != null) return updated.getName(); return cached.getName(); }
@Override public String getProtocol() { if (updated != null) return updated.getProtocol(); return cached.getProtocol(); }
@Override public boolean isBearerOnly() { if (updated != null) return updated.isBearerOnly(); return cached.isBearerOnly(); }
public Set<RoleModel> getScopeMappings() { if (updated != null) return updated.getScopeMappings(); Set<RoleModel> roles = new HashSet<RoleModel>(); for (String id : cached.getScope()) { roles.add(cacheSession.getRoleById(id, getRealm())); } return roles; }
@Override public ProtocolMapperModel getProtocolMapperById(String id) { for (ProtocolMapperModel mapping : cached.getProtocolMappers()) { if (mapping.getId().equals(id)) return mapping; } return null; }
@Override public ProtocolMapperModel getProtocolMapperByName(String protocol, String name) { for (ProtocolMapperModel mapping : cached.getProtocolMappers()) { if (mapping.getProtocol().equals(protocol) && mapping.getName().equals(name)) return mapping; } return null; }
@Override public String getAttribute(String name) { if (updated != null) return updated.getAttribute(name); return cached.getAttributes().get(name); }
@Override public String getId() { if (updated != null) return updated.getId(); return cached.getId(); }