public Map<String, Set<String>> getSitePermissions(String siteId) { Map<String, Set<String>> perms = new HashMap(); String userId = getCurrentUserId(); if (userId == null) { throw new SecurityException("This action (perms) is not accessible to anon and there is no current user."); } try { Site site = siteService.getSite(siteId); for (Role role : site.getRoles()) { Set<String> functions = role.getAllowedFunctions(); perms.put(role.getId(), functions.stream().filter(f -> f.startsWith("commons")).collect(Collectors.toSet())); } } catch (Exception e) { log.error("Failed to get current site permissions.", e); } return perms; }
/** * @inheritDoc */ public void save(final AuthzGroup edit) { // pre-check the roles and functions to make sure they are all defined for (Iterator iRoles = ((BaseAuthzGroup) edit).m_roles.values().iterator(); iRoles.hasNext();) { Role role = (Role) iRoles.next(); // make sure the role name is defined / define it checkRoleName(role.getId()); for (Iterator iFunctions = role.getAllowedFunctions().iterator(); iFunctions.hasNext();) { String function = (String) iFunctions.next(); // make sure the role name is defined / define it checkFunctionName(function); } } // run our save code in a transaction that will restart on deadlock // if deadlock retry fails, or any other error occurs, a runtime error will be thrown m_sql.transact(new Runnable() { public void run() { saveTx(edit); } }, "azg:" + edit.getId()); // update with the provider refreshAuthzGroup((BaseAuthzGroup) edit); }
if (anon != null && anon.getAllowedFunctions().contains("content.read"))
Set<String> functions = siteRole.getAllowedFunctions(); if (siteHelperRole != null) { functions.addAll(siteHelperRole.getAllowedFunctions());
for (Iterator iFunctions = role.getAllowedFunctions().iterator(); iFunctions.hasNext();)