/** * @see org.modeshape.jcr.security.SecurityContext#hasRole(java.lang.String) */ @Override public boolean hasRole(String roleName) { return delegate.hasRole(roleName); }
/** * Returns whether the authenticated user has the given role. * * @param context the security context * @param roleName the name of the role to check * @param repositoryName the name of the repository * @param workspaceName the workspace under which the user must have the role. This may be different from the current * workspace. * @return true if the user has the role and is logged in; false otherwise */ static boolean hasRole( SecurityContext context, String roleName, String repositoryName, String workspaceName ) { if (context.hasRole(roleName)) return true; roleName = roleName + "." + repositoryName; if (context.hasRole(roleName)) return true; roleName = roleName + "." + workspaceName; return context.hasRole(roleName); }
/** * Returns whether the authenticated user has the given role. * * @param context the security context * @param roleName the name of the role to check * @param repositoryName the name of the repository * @param workspaceName the workspace under which the user must have the role. This may be different from the current * workspace. * @return true if the user has the role and is logged in; false otherwise */ static boolean hasRole( SecurityContext context, String roleName, String repositoryName, String workspaceName ) { if (context.hasRole(roleName)) return true; roleName = roleName + "." + repositoryName; if (context.hasRole(roleName)) return true; roleName = roleName + "." + workspaceName; return context.hasRole(roleName); }
/** * Lists all privileges defined by this access list for the given user. * * @param context the security context of the user; never null * @return list of privilege objects. */ public Privilege[] getPrivileges( SecurityContext context ) { ArrayList<Privilege> privs = new ArrayList<Privilege>(); for (AccessControlEntryImpl ace : principals.values()) { // add privileges granted for everyone if (ace.getPrincipal().equals(SimplePrincipal.EVERYONE)) { privs.addAll(Arrays.asList(ace.getPrivileges())); } // add privileges granted for given user if (ace.getPrincipal().getName().equals(username(context.getUserName()))) { privs.addAll(Arrays.asList(ace.getPrivileges())); } // add privileges granted for given role if (context.hasRole(ace.getPrincipal().getName())) { privs.addAll(Arrays.asList(ace.getPrivileges())); } } Privilege[] res = new Privilege[privs.size()]; privs.toArray(res); return res; }
/** * Lists all privileges defined by this access list for the given user. * * @param context the security context of the user; never null * @return list of privilege objects. */ public Privilege[] getPrivileges( SecurityContext context ) { ArrayList<Privilege> privs = new ArrayList<Privilege>(); for (AccessControlEntryImpl ace : principals.values()) { // add privileges granted for everyone if (ace.getPrincipal().equals(SimplePrincipal.EVERYONE)) { privs.addAll(Arrays.asList(ace.getPrivileges())); } // add privileges granted for given user if (ace.getPrincipal().getName().equals(username(context.getUserName()))) { privs.addAll(Arrays.asList(ace.getPrivileges())); } // add privileges granted for given role if (context.hasRole(ace.getPrincipal().getName())) { privs.addAll(Arrays.asList(ace.getPrivileges())); } } Privilege[] res = new Privilege[privs.size()]; privs.toArray(res); return res; }
if (sc.hasRole(ace.getPrincipal().getName())) { if (ace.hasPrivileges(privileges)) { return true;
if (sc.hasRole(ace.getPrincipal().getName())) { if (ace.hasPrivileges(privileges)) { return true;