Search in sources :

Example 1 with CachedUserConsent

use of org.keycloak.models.cache.infinispan.entities.CachedUserConsent in project keycloak by keycloak.

the class UserCacheSession method getConsentByClient.

@Override
public UserConsentModel getConsentByClient(RealmModel realm, String userId, String clientId) {
    logger.tracev("getConsentByClient: {0}", userId);
    String cacheKey = getConsentCacheKey(userId);
    if (realmInvalidations.contains(realm.getId()) || invalidations.contains(userId) || invalidations.contains(cacheKey)) {
        return getDelegate().getConsentByClient(realm, userId, clientId);
    }
    CachedUserConsents cached = cache.get(cacheKey, CachedUserConsents.class);
    if (cached == null) {
        Long loaded = cache.getCurrentRevision(cacheKey);
        List<UserConsentModel> consents = getDelegate().getConsentsStream(realm, userId).collect(Collectors.toList());
        cached = new CachedUserConsents(loaded, cacheKey, realm, consents);
        cache.addRevisioned(cached, startupRevision);
    }
    CachedUserConsent cachedConsent = cached.getConsents().get(clientId);
    if (cachedConsent == null)
        return null;
    return toConsentModel(realm, cachedConsent);
}
Also used : CachedUserConsents(org.keycloak.models.cache.infinispan.entities.CachedUserConsents) CachedUserConsent(org.keycloak.models.cache.infinispan.entities.CachedUserConsent) UserConsentModel(org.keycloak.models.UserConsentModel)

Aggregations

UserConsentModel (org.keycloak.models.UserConsentModel)1 CachedUserConsent (org.keycloak.models.cache.infinispan.entities.CachedUserConsent)1 CachedUserConsents (org.keycloak.models.cache.infinispan.entities.CachedUserConsents)1