@Test @Ignore("This test should be run manually.") public void testListPrivilegeObjectsPerf() { Set<String> privileges = generatePrivilegeStrings(1000, 10); TreePrivilegeCache cache = new TreePrivilegeCache(privileges, null); List<Authorizable[]> authorizables = generateAuthoriables(12000, 10); long start = System.currentTimeMillis(); for (Authorizable[] authorizableHierarchy : authorizables) { Set<Privilege> privilegeSet = cache.listPrivilegeObjects(null, null, null, authorizableHierarchy); for (Privilege currPri : privilegeSet) { currPri.getParts(); } } long end = System.currentTimeMillis(); System.out.println("TreePrivilegeCache - total time on list obj: " + (end - start) + " ms"); }
@Override public Set<Privilege> listPrivilegeObjects(Set<String> groups, Set<String> users, ActiveRoleSet roleSet, Authorizable... authorizationhierarchy) { Set<String> topResourceValues = getTopLevelResourceValues(authorizationhierarchy); Set<Privilege> targetSet = new HashSet<>(); for (String topResourceValue : topResourceValues) { if (StringUtils.isEmpty(topResourceValue)) { continue; } TreePrivilegeNode topNode = cachedPrivilegeMap.get(topResourceValue); if (topNode == null) { continue; } targetSet.addAll(topNode.listPrivilegeObjects(0, authorizationhierarchy)); } return targetSet; }
TreePrivilegeCache implements FilteredPrivilegeCache { @Override public Set<Privilege> listPrivilegeObjects(Set<String> groups, Set<String> users, ActiveRoleSet roleSet, Authorizable... authorizationhierarchy) { Set<String> topResourceValues = getTopLevelResourceValues(authorizationhierarchy); Set<Privilege> targetSet = new HashSet<>(); for (String topResourceValue : topResourceValues) { if (StringUtils.isEmpty(topResourceValue)) { continue; } TreePrivilegeNode topNode = cachedPrivilegeMap.get(topResourceValue); if (topNode == null) { continue; } targetSet.addAll(topNode.listPrivilegeObjects(0, authorizationhierarchy)); } return targetSet; } }
TreePrivilegeCache implements FilteredPrivilegeCache { @Override public Set<Privilege> listPrivilegeObjects(Set<String> groups, Set<String> users, ActiveRoleSet roleSet, Authorizable... authorizationhierarchy) { Set<String> topResourceValues = getTopLevelResourceValues(authorizationhierarchy); Set<Privilege> targetSet = new HashSet<>(); for (String topResourceValue : topResourceValues) { if (StringUtils.isEmpty(topResourceValue)) { continue; } TreePrivilegeNode topNode = cachedPrivilegeMap.get(topResourceValue); if (topNode == null) { continue; } targetSet.addAll(topNode.listPrivilegeObjects(0, authorizationhierarchy)); } return targetSet; } TreePrivilegeCache(Set<String> cachedPrivileges, PrivilegeFactory inPrivilegeFactory); }
TreePrivilegeCache implements FilteredPrivilegeCache { @Override public Set<Privilege> listPrivilegeObjects(Set<String> groups, Set<String> users, ActiveRoleSet roleSet, Authorizable... authorizationhierarchy) { Set<String> topResourceValues = getTopLevelResourceValues(authorizationhierarchy); Set<Privilege> targetSet = new HashSet<>(); for (String topResourceValue : topResourceValues) { if (StringUtils.isEmpty(topResourceValue)) { continue; } TreePrivilegeNode topNode = cachedPrivilegeMap.get(topResourceValue); if (topNode == null) { continue; } targetSet.addAll(topNode.listPrivilegeObjects(0, authorizationhierarchy)); } return targetSet; } TreePrivilegeCache(Set<String> cachedPrivileges, PrivilegeFactory inPrivilegeFactory); @Override Set<String> listPrivileges(Set<String> groups, ActiveRoleSet roleSet); @Override Set<String> listPrivileges(Set<String> groups, Set<String> users, ActiveRoleSet roleSet); @Override Set<String> listPrivileges(Set<String> groups, Set<String> users, ActiveRoleSet roleSet,
    Authorizable... authorizationhierarchy); @Override Set<Privilege> listPrivilegeObjects(Set<String> groups, Set<String> users,
    ActiveRoleSet roleSet, Authorizable... authorizationhierarchy); @Override void close(); }
TreePrivilegeCache implements FilteredPrivilegeCache { @Override public Set<Privilege> listPrivilegeObjects(Set<String> groups, Set<String> users, ActiveRoleSet roleSet, Authorizable... authorizationhierarchy) { Set<String> topResourceValues = getTopLevelResourceValues(authorizationhierarchy); Set<Privilege> targetSet = new HashSet<>(); for (String topResourceValue : topResourceValues) { if (StringUtils.isEmpty(topResourceValue)) { continue; } TreePrivilegeNode topNode = cachedPrivilegeMap.get(topResourceValue); if (topNode == null) { continue; } targetSet.addAll(topNode.listPrivilegeObjects(0, authorizationhierarchy)); } return targetSet; } TreePrivilegeCache(Set<String> cachedPrivileges, PrivilegeFactory inPrivilegeFactory); @Override Set<String> listPrivileges(Set<String> groups, ActiveRoleSet roleSet); @Override Set<String> listPrivileges(Set<String> groups, Set<String> users, ActiveRoleSet roleSet); @Override Set<String> listPrivileges(Set<String> groups, Set<String> users, ActiveRoleSet roleSet,
    Authorizable... authorizationhierarchy); @Override Set<Privilege> listPrivilegeObjects(Set<String> groups, Set<String> users,
    ActiveRoleSet roleSet, Authorizable... authorizationhierarchy); @Override void close();  }