53 Set<ClientModel> offlineClients =
new UserSessionManager(session).findClientsWithOfflineToken(realm, user);
55 List<ClientModel> realmClients = realm.getClients();
56 for (ClientModel client : realmClients) {
58 if (client.isBearerOnly()) {
62 Set<RoleModel> availableRoles =
new HashSet<>();
63 if (client.getClientId().equals(Constants.ADMIN_CLI_CLIENT_ID)
64 || client.getClientId().equals(Constants.ADMIN_CONSOLE_CLIENT_ID)) {
65 if (!AdminPermissions.realms(session, realm, user).isAdmin())
continue;
69 Set<ClientScopeModel> allClientScopes =
new HashSet<>(client.getClientScopes(
true,
true).values());
70 allClientScopes.addAll(client.getClientScopes(
false,
true).values());
71 allClientScopes.add(client);
73 availableRoles = TokenManager.getAccess(user, client, allClientScopes);
75 List<RoleModel> realmRolesAvailable =
new LinkedList<RoleModel>();
76 MultivaluedHashMap<String, ClientRoleEntry> resourceRolesAvailable =
new MultivaluedHashMap<String, ClientRoleEntry>();
77 processRoles(availableRoles, realmRolesAvailable, resourceRolesAvailable);
79 List<ClientScopeModel> orderedScopes =
new ArrayList<>();
80 if (client.isConsentRequired()) {
81 UserConsentModel consent = session.users().getConsentByClient(realm, user.getId(), client.getId());
83 if (consent != null) {
84 orderedScopes.addAll(consent.getGrantedClientScopes());
85 orderedScopes.sort(
new OrderedModel.OrderedModelComparator<>());
88 List<String> clientScopesGranted = orderedScopes.stream()
89 .map(ClientScopeModel::getConsentScreenText)
90 .collect(Collectors.toList());
92 List<String> additionalGrants =
new ArrayList<>();
93 if (offlineClients.contains(client)) {
94 additionalGrants.add(
"${offlineToken}");
97 ApplicationEntry appEntry =
new ApplicationEntry(realmRolesAvailable, resourceRolesAvailable, client,
98 clientScopesGranted, additionalGrants);
List< ApplicationEntry > applications
Definition: ApplicationsBean.java:49
void processRoles(Set< RoleModel > inputRoles, List< RoleModel > realmRoles, MultivaluedHashMap< String, ClientRoleEntry > clientRoles)
Definition: ApplicationsBean.java:103