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());
}
}
}
}
Aggregations