@Override
    @SuppressWarnings("NonApiType")
    protected LinkedHashMap<String, UserProfile> retrieveAll(final boolean readFromSession) {
        val profiles = super.retrieveAll(readFromSession).entrySet();
        val clientId = getClientIdFromRequest();
        val results = profiles
            .stream()
            .filter(it -> {
                val profile = it.getValue();
                return StringUtils.isBlank(clientId)
                       || StringUtils.equals((CharSequence) profile.getAttribute(SESSION_CLIENT_ID), clientId);
            })
            .collect(Collectors.toMap(
                Map.Entry::getKey,
                Map.Entry::getValue,
                (v1, v2) -> {
                    throw new IllegalStateException("Duplicate key");
                },
                LinkedHashMap::new));
        LOGGER.trace("Fetched profiles for this session are [{}]", results);
        return results;
    }
This is {@link OAuth20ClientIdAwareProfileManager}.
It saves returns a profile based on client_id from the request.

@author Kirill Gagarski
@author Misagh Moayyed
@since 6.1.0
support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/OAuth20ClientIdAwareProfileManager.java