Search in sources :

Example 6 with SecurityEntry

use of org.xwiki.security.authorization.SecurityEntry in project xwiki-platform by xwiki.

the class DefaultSecurityCacheTest method checkEntries.

private void checkEntries(Map<String, SecurityEntry> entries, KeepEntries keeper) {
    for (Iterator<Map.Entry<String, SecurityEntry>> it = entries.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry<String, SecurityEntry> entry = it.next();
        if (entry.getValue() instanceof SecurityRuleEntry) {
            SecurityRuleEntry sentry = (SecurityRuleEntry) entry.getValue();
            if (keeper.keepRule(sentry)) {
                assertThat(((DefaultSecurityCache) securityCache).get(entry.getKey()), sameInstance(entry.getValue()));
            } else {
                it.remove();
                assertThat(((DefaultSecurityCache) securityCache).get(entry.getKey()), nullValue());
            }
        } else if (entry.getValue() instanceof SecurityAccessEntry) {
            SecurityAccessEntry sentry = (SecurityAccessEntry) entry.getValue();
            if (keeper.keepAccess(sentry)) {
                assertThat(((DefaultSecurityCache) securityCache).get(entry.getKey()), sameInstance(entry.getValue()));
            } else {
                it.remove();
                assertThat(((DefaultSecurityCache) securityCache).get(entry.getKey()), nullValue());
            }
        } else {
            SecurityShadowEntry sentry = (SecurityShadowEntry) entry.getValue();
            if (keeper.keepShadow(sentry)) {
                assertThat(((DefaultSecurityCache) securityCache).get(entry.getKey()), sameInstance(entry.getValue()));
            } else {
                it.remove();
                assertThat(((DefaultSecurityCache) securityCache).get(entry.getKey()), nullValue());
            }
        }
    }
}
Also used : SecurityAccessEntry(org.xwiki.security.authorization.SecurityAccessEntry) SecurityRuleEntry(org.xwiki.security.authorization.SecurityRuleEntry) SecurityShadowEntry(org.xwiki.security.authorization.cache.SecurityShadowEntry) SecurityEntry(org.xwiki.security.authorization.SecurityEntry) SecurityAccessEntry(org.xwiki.security.authorization.SecurityAccessEntry) SecurityRuleEntry(org.xwiki.security.authorization.SecurityRuleEntry) SecurityEntry(org.xwiki.security.authorization.SecurityEntry) SecurityShadowEntry(org.xwiki.security.authorization.cache.SecurityShadowEntry) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

SecurityEntry (org.xwiki.security.authorization.SecurityEntry)6 GroupSecurityReference (org.xwiki.security.GroupSecurityReference)5 SecurityReference (org.xwiki.security.SecurityReference)5 UserSecurityReference (org.xwiki.security.UserSecurityReference)5 HashMap (java.util.HashMap)4 SecurityRuleEntry (org.xwiki.security.authorization.SecurityRuleEntry)3 SecurityShadowEntry (org.xwiki.security.authorization.cache.SecurityShadowEntry)3 SecurityAccessEntry (org.xwiki.security.authorization.SecurityAccessEntry)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Test (org.junit.Test)1 ConflictingInsertionException (org.xwiki.security.authorization.cache.ConflictingInsertionException)1 ParentEntryEvictedException (org.xwiki.security.authorization.cache.ParentEntryEvictedException)1