public void consentInvalidation(String userId, Set<String> invalidations) { invalidations.add(UserCacheSession.getConsentCacheKey(userId)); }
public void fullUserInvalidation(String userId, String username, String email, String realmId, boolean identityFederationEnabled, Map<String, String> federatedIdentities, Set<String> invalidations) { userUpdatedInvalidations(userId, username, email, realmId, invalidations); if (identityFederationEnabled) { // Invalidate all keys for lookup this user by any identityProvider link for (Map.Entry<String, String> socialLink : federatedIdentities.entrySet()) { String fedIdentityCacheKey = UserCacheSession.getUserByFederatedIdentityCacheKey(realmId, socialLink.getKey(), socialLink.getValue()); invalidations.add(fedIdentityCacheKey); } // Invalidate federationLinks of user invalidations.add(UserCacheSession.getFederatedIdentityLinksCacheKey(userId)); } // Consents invalidations.add(UserCacheSession.getConsentCacheKey(userId)); }
@Override public List<UserConsentModel> getConsents(RealmModel realm, String userId) { logger.tracev("getConsents: {0}", userId); String cacheKey = getConsentCacheKey(userId); if (realmInvalidations.contains(realm.getId()) || invalidations.contains(userId) || invalidations.contains(cacheKey)) { return getDelegate().getConsents(realm, userId); } CachedUserConsents cached = cache.get(cacheKey, CachedUserConsents.class); if (cached == null) { Long loaded = cache.getCurrentRevision(cacheKey); List<UserConsentModel> consents = getDelegate().getConsents(realm, userId); cached = new CachedUserConsents(loaded, cacheKey, realm, consents); cache.addRevisioned(cached, startupRevision); return consents; } else { List<UserConsentModel> result = new LinkedList<>(); for (CachedUserConsent cachedConsent : cached.getConsents().values()) { UserConsentModel consent = toConsentModel(realm, cachedConsent); if (consent != null) { result.add(consent); } } return result; } }
@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().getConsents(realm, userId); 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); }