@Override public List<ClientScopeModel> getClientScopes() { if (isUpdated()) return updated.getClientScopes(); List<String> clientScopes = cached.getClientScopes(); if (clientScopes.isEmpty()) return Collections.EMPTY_LIST; List<ClientScopeModel> apps = new LinkedList<ClientScopeModel>(); for (String id : clientScopes) { ClientScopeModel model = cacheSession.getClientScopeById(id, this); if (model == null) { throw new IllegalStateException("Cached clientScope not found: " + id); } apps.add(model); } return Collections.unmodifiableList(apps); }
@Override public ClientScopeModel getClientScopeById(String id) { if (isUpdated()) return updated.getClientScopeById(id); return cacheSession.getClientScopeById(id, this); }
@Override public List<ClientScopeModel> getDefaultClientScopes(boolean defaultScope) { if (isUpdated()) return updated.getDefaultClientScopes(defaultScope); List<String> clientScopeIds = defaultScope ? cached.getDefaultDefaultClientScopes() : cached.getOptionalDefaultClientScopes(); List<ClientScopeModel> clientScopes = new LinkedList<>(); for (String scopeId : clientScopeIds) { ClientScopeModel clientScope = cacheSession.getClientScopeById(scopeId, this); if (clientScope != null) { clientScopes.add(clientScope); } } return clientScopes; }
@Override public Map<String, ClientScopeModel> getClientScopes(boolean defaultScope, boolean filterByProtocol) { if (isUpdated()) return updated.getClientScopes(defaultScope, filterByProtocol); List<String> clientScopeIds = defaultScope ? cached.getDefaultClientScopesIds() : cached.getOptionalClientScopesIds(); // Defaults to openid-connect String clientProtocol = getProtocol() == null ? "openid-connect" : getProtocol(); Map<String, ClientScopeModel> clientScopes = new HashMap<>(); for (String scopeId : clientScopeIds) { ClientScopeModel clientScope = cacheSession.getClientScopeById(scopeId, cachedRealm); if (clientScope != null) { if (!filterByProtocol || clientScope.getProtocol().equals(clientProtocol)) { clientScopes.put(clientScope.getName(), clientScope); } } } return clientScopes; }