public class AccessManagerUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
AccessManagerUtils.CompiledAce
Ace node representation to be store in cache
|
static class |
AccessManagerUtils.CompiledAcl
Acl node representation to be store in cache
|
| Modifier and Type | Field and Description |
|---|---|
static ThreadLocal<Collection<String>> |
deniedPathes |
| Constructor and Description |
|---|
AccessManagerUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
flushMatchingPermissions()
Flush matchingPermissions cache
|
static void |
flushPrivilegesInRoles()
Flush privilegesInRole cache
|
static Set<javax.jcr.security.Privilege> |
getPermissionsInRole(String role,
JahiaPrivilegeRegistry privilegeRegistry)
Retrieve permissions of a given role
The privilegesInRole cache will be used to read the permissions, if not found we used a system session in default workspace to read the role node
|
static String |
getPrivilegeName(String privilegeName,
String workspace)
Get the full privilege name combine privilege name with workspace to generate the permission name used in jahia
exemple: privilege: Privilege.JCR_REMOVE_NODE and workspace: Constants.EDIT_WORKSPACE
result: "{http://www.jcp.org/jcr/1.0}removeNode_default"
|
static javax.jcr.security.Privilege[] |
getPrivileges(javax.jcr.Node node,
org.jahia.jaas.JahiaPrincipal jahiaPrincipal,
JahiaPrivilegeRegistry privilegeRegistry)
Get the list Privilege from granted roles for a given principal on a node, recursive check on parents nodes
when the acl node have the "inherit" flag, the getRoles(...) function is used to retrieve the roles.
|
static javax.jcr.security.Privilege[] |
getPrivileges(String absPath,
String workspace,
org.jahia.jaas.JahiaPrincipal jahiaPrincipal,
JahiaPrivilegeRegistry privilegeRegistry)
Get the list Privilege from granted roles for a given principal on a node, recursive check on parents nodes
when the acl node have the "inherit" flag, the getRoles(...) function is used to retrieve the roles.
|
static Set<String> |
getRoles(javax.jcr.Node node,
org.jahia.jaas.JahiaPrincipal jahiaPrincipal)
Get the list of granted role for a given principal on a node, recursive check on parents when the acl node have the "inherit" flag
|
static Set<String> |
getRoles(String absPath,
String workspace,
org.jahia.jaas.JahiaPrincipal jahiaPrincipal)
Get the list of granted role for a given principal on a node, recursive check on parents when the acl node have the "inherit" flag
|
static void |
initCaches()
Init privilegesInRole and matchingPermissions static cache
|
static boolean |
isAdmin(String siteKey,
org.jahia.jaas.JahiaPrincipal jahiaPrincipal)
Test if the given JahiaPrincipal is administrator, store the result in the jahiaPrincipal so we don't query the groupService in next calls
|
static boolean |
isGranted(PathWrapper pathWrapper,
Set<String> permissions,
javax.jcr.Session securitySession,
org.jahia.jaas.JahiaPrincipal jahiaPrincipal,
String workspaceName,
boolean isAliased,
Map<String,Boolean> pathPermissionCache,
Map<Object,AccessManagerUtils.CompiledAcl> compiledAcls,
JahiaPrivilegeRegistry privilegeRegistry)
Entry point to test if the given jahiaPrincipal match the given permissions on a node
|
static boolean |
isSystemPrincipal(org.jahia.jaas.JahiaPrincipal jahiaPrincipal)
check if the principal is system
|
static boolean |
matchPermission(Set<String> permissions,
String role,
boolean isAliased,
JahiaPrivilegeRegistry privilegeRegistry,
String workspaceName)
Test if a given role contains the list of permissions
|
static void |
setDeniedPaths(Collection<String> denied)
add pathes to list of always denied pathes
|
public static ThreadLocal<Collection<String>> deniedPathes
public static void initCaches()
public static void flushPrivilegesInRoles()
public static void flushMatchingPermissions()
public static String getPrivilegeName(String privilegeName, String workspace)
privilegeName - privilege name, like Privilege.JCR_REMOVE_NODEworkspace - workspace name, like Constants.EDIT_WORKSPACEpublic static void setDeniedPaths(Collection<String> denied)
denied - list of pathpublic static boolean isSystemPrincipal(org.jahia.jaas.JahiaPrincipal jahiaPrincipal)
jahiaPrincipal - jahiaPrincipal to testpublic static boolean isGranted(PathWrapper pathWrapper, Set<String> permissions, javax.jcr.Session securitySession, org.jahia.jaas.JahiaPrincipal jahiaPrincipal, String workspaceName, boolean isAliased, Map<String,Boolean> pathPermissionCache, Map<Object,AccessManagerUtils.CompiledAcl> compiledAcls, JahiaPrivilegeRegistry privilegeRegistry) throws javax.jcr.RepositoryException
pathWrapper - the path to the nodepermissions - the permissions ask for checksecuritySession - the session used to read the j:acl nodes, it should be a system session to be sure that nodes are readable in any case,
the workspace of the session is important because acls under nodes can be different depending on the workspace.
Normally the workspace of this session should be the same ot the workspace where you want to do the check of permissions.jahiaPrincipal - the jahiaPrincipal to testworkspaceName - the workspace to check (used to construct the privilege names)isAliased - if the current user is aliasedpathPermissionCache - Map used as a cache in memory to store the result of this function, to avoid recalculate everything if check is ask with similar parameters aftercompiledAcls - Map used as a cache in memory to store the j:acl result for a given node, to avoid read jcr again to retrieve the acls in next callsprivilegeRegistry - Jahia Privilege registry, used to read Privilege or retrieve them using names.javax.jcr.RepositoryException - in case of JCR-related errorspublic static Set<javax.jcr.security.Privilege> getPermissionsInRole(String role, JahiaPrivilegeRegistry privilegeRegistry) throws javax.jcr.RepositoryException
role - Role nameprivilegeRegistry - JahiaPrivilegeRegistryjavax.jcr.RepositoryException - in case of JCR-related errorspublic static boolean matchPermission(Set<String> permissions, String role, boolean isAliased, JahiaPrivilegeRegistry privilegeRegistry, String workspaceName) throws javax.jcr.RepositoryException
permissions - list of permissions to testrole - the roleisAliased - if the current user is aliasedprivilegeRegistry - the JahiaPrivilegedRegistryworkspaceName - the workspacejavax.jcr.RepositoryException - in case of JCR-related errorspublic static javax.jcr.security.Privilege[] getPrivileges(String absPath, String workspace, org.jahia.jaas.JahiaPrincipal jahiaPrincipal, JahiaPrivilegeRegistry privilegeRegistry) throws javax.jcr.PathNotFoundException, javax.jcr.RepositoryException
absPath - the path to the nodeworkspace - the workspacejahiaPrincipal - the principalprivilegeRegistry - the JahiaPrivilegeRegistryjavax.jcr.PathNotFoundExceptionjavax.jcr.RepositoryException - in case of JCR-related errorspublic static javax.jcr.security.Privilege[] getPrivileges(javax.jcr.Node node,
org.jahia.jaas.JahiaPrincipal jahiaPrincipal,
JahiaPrivilegeRegistry privilegeRegistry)
throws javax.jcr.PathNotFoundException,
javax.jcr.RepositoryException
node - the nodejahiaPrincipal - the principalprivilegeRegistry - the JahiaPrivilegeRegistryjavax.jcr.PathNotFoundExceptionjavax.jcr.RepositoryException - in case of JCR-related errorspublic static boolean isAdmin(String siteKey, org.jahia.jaas.JahiaPrincipal jahiaPrincipal)
siteKey - if set, the test will check if the user is site administratorjahiaPrincipal - the principalpublic static Set<String> getRoles(String absPath, String workspace, org.jahia.jaas.JahiaPrincipal jahiaPrincipal) throws javax.jcr.PathNotFoundException, javax.jcr.RepositoryException
absPath - the path of the nodeworkspace - the workspacejahiaPrincipal - the jahiaPrincipaljavax.jcr.PathNotFoundExceptionjavax.jcr.RepositoryException - in case of JCR-related errorspublic static Set<String> getRoles(javax.jcr.Node node, org.jahia.jaas.JahiaPrincipal jahiaPrincipal) throws javax.jcr.PathNotFoundException, javax.jcr.RepositoryException
node - the node, the session of the should allow to read under j:acl and ace nodesjahiaPrincipal - the jahiaPrincipaljavax.jcr.PathNotFoundExceptionjavax.jcr.RepositoryException - in case of JCR-related errorsCopyright © 2004–2020 Jahia Solutions Group SA. All rights reserved.