Search in sources :

Example 1 with CachedFederatedIdentityLinks

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

the class UserCacheSession method getFederatedIdentitiesStream.

@Override
public Stream<FederatedIdentityModel> getFederatedIdentitiesStream(RealmModel realm, UserModel user) {
    logger.tracev("getFederatedIdentities: {0}", user.getUsername());
    String cacheKey = getFederatedIdentityLinksCacheKey(user.getId());
    if (realmInvalidations.contains(realm.getId()) || invalidations.contains(user.getId()) || invalidations.contains(cacheKey)) {
        return getDelegate().getFederatedIdentitiesStream(realm, user);
    }
    CachedFederatedIdentityLinks cachedLinks = cache.get(cacheKey, CachedFederatedIdentityLinks.class);
    if (cachedLinks == null) {
        Long loaded = cache.getCurrentRevision(cacheKey);
        Set<FederatedIdentityModel> federatedIdentities = getDelegate().getFederatedIdentitiesStream(realm, user).collect(Collectors.toSet());
        cachedLinks = new CachedFederatedIdentityLinks(loaded, cacheKey, realm, federatedIdentities);
        cache.addRevisioned(cachedLinks, startupRevision);
        return federatedIdentities.stream();
    } else {
        return cachedLinks.getFederatedIdentities().stream();
    }
}
Also used : FederatedIdentityModel(org.keycloak.models.FederatedIdentityModel) CachedFederatedIdentityLinks(org.keycloak.models.cache.infinispan.entities.CachedFederatedIdentityLinks)

Aggregations

FederatedIdentityModel (org.keycloak.models.FederatedIdentityModel)1 CachedFederatedIdentityLinks (org.keycloak.models.cache.infinispan.entities.CachedFederatedIdentityLinks)1