Class ACLJCRAmetysObjectHelper
- java.lang.Object
-
- org.ametys.plugins.repository.jcr.ACLJCRAmetysObjectHelper
-
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
public class ACLJCRAmetysObjectHelper extends Object implements Component, Serviceable, LogEnabled
Helper for implementingModifiableACLAmetysObject
in JCR under its node.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ACLJCRAmetysObjectHelper.ACLProfileExpression
(package private) static class
ACLJCRAmetysObjectHelper.AllowedProfileExpression
(package private) static class
ACLJCRAmetysObjectHelper.AnonymousAllowedProfileExpression
(package private) static class
ACLJCRAmetysObjectHelper.AnonymousDeniedProfileExpression
(package private) static class
ACLJCRAmetysObjectHelper.AnyConnectedAllowedProfileExpression
(package private) static class
ACLJCRAmetysObjectHelper.AnyConnectedDeniedProfileExpression
(package private) static class
ACLJCRAmetysObjectHelper.DeniedProfileExpression
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ACLJCRAmetysObjectHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
_addProperty(Node node, String propertyName, String profileToAdd)
private static void
_checkLock(Node node)
private static Set<String>
_convertNodeToPath(Set<? extends Object> rootNodes)
private static Node
_getACLNode(Node node)
private static NodeIterator
_getApprochingACLGroups(Set<GroupIdentity> groups, String rootPath, Expression predicat)
private static Node
_getGroupsNode(Node node)
private static Node
_getOrCreateACLNode(Node node)
private static Node
_getOrCreateGroupNode(Node node, GroupIdentity groupIdentity)
private static Node
_getOrCreateGroupsNode(Node node)
private static Node
_getOrCreateUserNode(Node node, UserIdentity userIdentity)
private static Node
_getOrCreateUsersNode(Node node)
private static Set<String>
_getProperty(Node node, String propertyName)
private static Node
_getUserNode(Node node, UserIdentity user)
private static Node
_getUsersNode(Node node)
private static NodeIterator
_query(String jcrQuery)
private static void
_removeProperty(Node node, String propertyName, String profileToRemove)
private static void
_save(Node node)
private static void
_setProperty(Node node, String propertyName, Set<String> profiles)
static void
addAllowedGroups(Set<GroupIdentity> groups, Node node, String profileId)
static void
addAllowedProfilesForAnonymous(Node node, Set<String> profileIds)
static void
addAllowedProfilesForAnyConnectedUser(Node node, Set<String> profileIds)
static void
addAllowedUsers(Set<UserIdentity> users, Node node, String profileId)
static void
addDeniedGroups(Set<GroupIdentity> groups, Node node, String profileId)
static void
addDeniedProfilesForAnonymous(Node node, Set<String> profileIds)
static void
addDeniedProfilesForAnyConnectedUser(Node node, Set<String> profileIds)
static void
addDeniedUsers(Set<UserIdentity> users, Node node, String profileId)
static void
disallowInheritance(Node node, boolean disallow)
static NodeIterator
getACLGroups(GroupIdentity group, String rootPath, Expression predicat)
Returns all ACL objects for a given group (ametys:acl-group nodes)static NodeIterator
getACLGroups(Expression predicat)
Returns all ACL objects for groups (ametys:acl-group nodes)static NodeIterator
getACLRoots(String rootPath, Expression predicat)
Returns all ACL root objects (ametys:acl nodes)static NodeIterator
getACLUsers(UserIdentity user, String rootPath, Expression predicat)
Returns all ACL objects for a given user (ametys:acl-user nodes)static NodeIterator
getACLUsers(Expression predicat)
Returns all ACL objects for users (ametys:acl-user nodes)static Map<ProfileAssignmentStorage.AnonymousOrAnyConnectedKeys,Set<String>>
getProfilesForAnonymousAndAnyConnectedUser(Node node)
static Map<GroupIdentity,Map<ProfileAssignmentStorage.UserOrGroup,Set<String>>>
getProfilesForGroups(Node node, Set<GroupIdentity> groups)
static Map<UserIdentity,Map<ProfileAssignmentStorage.UserOrGroup,Set<String>>>
getProfilesForUsers(Node node, UserIdentity user)
static Set<String>
hasAnonymousAnyAllowedProfile(Set<? extends Object> rootNodes, Set<String> profileIds)
Returns some profiles that are matching if any ACL Ametys object has one of the given profiles as allowed for anonymousstatic Set<String>
hasAnyConnectedAnyAllowedProfile(Set<? extends Object> rootNodes, Set<String> profileIds)
Returns some profiles that are matching if any ACL Ametys object has one of the given profiles as allowed for any connected userstatic Set<String>
hasGroupAnyAllowedProfile(Set<? extends Object> rootNodes, Set<GroupIdentity> groups, Set<String> profileIds)
Returns some profiles that are matching if any ACL Ametys object has one of the given profiles as allowed for the groupstatic Set<String>
hasUserAnyAllowedProfile(Set<? extends Object> rootNodes, UserIdentity user, Set<String> profileIds)
Returns some profiles that are matching if any ACL Ametys object has one of the given profiles as allowed for the userstatic boolean
isInheritanceDisallowed(Node node)
Helper forACLAmetysObject.isInheritanceDisallowed()
static void
removeAllowedGroups(Set<GroupIdentity> groups, Node node)
static void
removeAllowedGroups(Set<GroupIdentity> groups, Node node, String profileId)
static void
removeAllowedProfilesForAnonymous(Node node, Set<String> profileIds)
static void
removeAllowedProfilesForAnyConnectedUser(Node node, Set<String> profileIds)
static void
removeAllowedUsers(Set<UserIdentity> users, Node node)
static void
removeAllowedUsers(Set<UserIdentity> users, Node node, String profileId)
static void
removeDeniedGroups(Set<GroupIdentity> groups, Node node)
static void
removeDeniedGroups(Set<GroupIdentity> groups, Node node, String profileId)
static void
removeDeniedProfilesForAnonymous(Node node, Set<String> profileIds)
static void
removeDeniedProfilesForAnyConnectedUser(Node node, Set<String> profileIds)
static void
removeDeniedUsers(Set<UserIdentity> users, Node node)
static void
removeDeniedUsers(Set<UserIdentity> users, Node node, String profileId)
static void
removeGroup(GroupIdentity group)
static void
removeProfile(String profileId)
static void
removeUser(UserIdentity user)
void
service(ServiceManager manager)
void
setLogger(org.slf4j.Logger logger)
Called at creation time to provide aLogger
.
-
-
-
Field Detail
-
_resolver
protected static AmetysObjectResolver _resolver
The AmetysObject resolver
-
_repository
protected static Repository _repository
The repository
-
__NODE_NAME_ROOT_ACL
private static final String __NODE_NAME_ROOT_ACL
- See Also:
- Constant Field Values
-
__NODETYPE_ROOT_ACL
private static final String __NODETYPE_ROOT_ACL
- See Also:
- Constant Field Values
-
__NODE_NAME_ACL_USERS
private static final String __NODE_NAME_ACL_USERS
- See Also:
- Constant Field Values
-
__NODE_NAME_ACL_GROUPS
private static final String __NODE_NAME_ACL_GROUPS
- See Also:
- Constant Field Values
-
__NODETYPE_ACL_USER
private static final String __NODETYPE_ACL_USER
- See Also:
- Constant Field Values
-
__NODETYPE_ACL_GROUP
private static final String __NODETYPE_ACL_GROUP
- See Also:
- Constant Field Values
-
__NODETYPE_UNSTRUCTURED
private static final String __NODETYPE_UNSTRUCTURED
- See Also:
- Constant Field Values
-
__PROPERTY_NAME_ALLOWED_ANY_CONNECTED_PROFILES
private static final String __PROPERTY_NAME_ALLOWED_ANY_CONNECTED_PROFILES
- See Also:
- Constant Field Values
-
__PROPERTY_NAME_DENIED_ANY_CONNECTED_PROFILES
private static final String __PROPERTY_NAME_DENIED_ANY_CONNECTED_PROFILES
- See Also:
- Constant Field Values
-
__PROPERTY_NAME_ALLOWED_ANONYMOUS_PROFILES
private static final String __PROPERTY_NAME_ALLOWED_ANONYMOUS_PROFILES
- See Also:
- Constant Field Values
-
__PROPERTY_NAME_DENIED_ANONYMOUS_PROFILES
private static final String __PROPERTY_NAME_DENIED_ANONYMOUS_PROFILES
- See Also:
- Constant Field Values
-
__PROPERTY_NAME_ALLOWED_PROFILES
private static final String __PROPERTY_NAME_ALLOWED_PROFILES
- See Also:
- Constant Field Values
-
__PROPERTY_NAME_DENIED_PROFILES
private static final String __PROPERTY_NAME_DENIED_PROFILES
- See Also:
- Constant Field Values
-
__PROPERTY_NAME_DISALLOW_INHERITANCE
private static final String __PROPERTY_NAME_DISALLOW_INHERITANCE
- See Also:
- Constant Field Values
-
__ANONYMOUS_OR_ANYCONNECTEDUSER_NORIGHT
private static final Map<ProfileAssignmentStorage.AnonymousOrAnyConnectedKeys,Set<String>> __ANONYMOUS_OR_ANYCONNECTEDUSER_NORIGHT
-
__USER_OR_GROUP_NORIGHT
private static final Map<ProfileAssignmentStorage.UserOrGroup,Set<String>> __USER_OR_GROUP_NORIGHT
-
_logger
private static org.slf4j.Logger _logger
-
-
Constructor Detail
-
ACLJCRAmetysObjectHelper
public ACLJCRAmetysObjectHelper()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
setLogger
public void setLogger(org.slf4j.Logger logger)
Description copied from interface:LogEnabled
Called at creation time to provide aLogger
.- Specified by:
setLogger
in interfaceLogEnabled
- Parameters:
logger
- aLogger
for messages.
-
_convertNodeToPath
private static Set<String> _convertNodeToPath(Set<? extends Object> rootNodes)
-
hasUserAnyAllowedProfile
public static Set<String> hasUserAnyAllowedProfile(Set<? extends Object> rootNodes, UserIdentity user, Set<String> profileIds)
Returns some profiles that are matching if any ACL Ametys object has one of the given profiles as allowed for the user- Parameters:
user
- The userprofileIds
- The ids of the profiles to checkrootNodes
- The JCR root nodes where starts the query search (must be something like "//element(myNode, ametys:collection)"), it will be the beginning of the JCR query. Can be null to not restrict the search.- Returns:
- If the Set is empty, it means the user has no matching profile.
If the Set is non empty, it contains at least one of the given profile BUT it may not contains all the matching profiles for the user AND it can contains some other profiles that were not in the given profiles
-
hasGroupAnyAllowedProfile
public static Set<String> hasGroupAnyAllowedProfile(Set<? extends Object> rootNodes, Set<GroupIdentity> groups, Set<String> profileIds)
Returns some profiles that are matching if any ACL Ametys object has one of the given profiles as allowed for the group- Parameters:
groups
- The groupsprofileIds
- The ids of the profilesrootNodes
- The JCR root nodes where starts the query search (must be something like "//element(myNode, ametys:collection)"), it will be the beginning of the JCR query. Can be null to not restrict the search.- Returns:
- If the Set is empty, it means the group has no matching profile.
If the Set is non empty, it contains at least one of the given profile BUT it may not contains all the matching profiles for the group AND it can contains some other profiles that were not in the given profiles
-
hasAnyConnectedAnyAllowedProfile
public static Set<String> hasAnyConnectedAnyAllowedProfile(Set<? extends Object> rootNodes, Set<String> profileIds)
Returns some profiles that are matching if any ACL Ametys object has one of the given profiles as allowed for any connected user- Parameters:
profileIds
- The ids of the profilesrootNodes
- The JCR root nodes where starts the query search (must be something like "//element(myNode, ametys:collection)"), it will be the beginning of the JCR query. Can be null to not restrict the search.- Returns:
- If the Set is empty, it means any connected user has no matching profile.
If the Set is non empty, it contains at least one of the given profile BUT it may not contains all the matching profiles for anyconnected user AND it can contains some other profiles that were not in the given profiles
-
hasAnonymousAnyAllowedProfile
public static Set<String> hasAnonymousAnyAllowedProfile(Set<? extends Object> rootNodes, Set<String> profileIds)
Returns some profiles that are matching if any ACL Ametys object has one of the given profiles as allowed for anonymous- Parameters:
profileIds
- The ids of the profilesrootNodes
- The JCR root nodes where starts the query search (must be something like "//element(myNode, ametys:collection)"), it will be the beginning of the JCR query. Can be null to not restrict the search.- Returns:
- If the Set is empty, it means anonymous has no matching profile.
If the Set is non empty, it contains at least one of the given profile BUT it may not contains all the matching profiles for anonymous AND it can contains some other profiles that were not in the given profiles
-
getACLRoots
public static NodeIterator getACLRoots(String rootPath, Expression predicat)
Returns all ACL root objects (ametys:acl nodes)- Parameters:
rootPath
- The root path to restrict the search. Can be null.predicat
- The predicat expression. Can be null.- Returns:
- The ACL root objects
-
getACLUsers
public static NodeIterator getACLUsers(UserIdentity user, String rootPath, Expression predicat)
Returns all ACL objects for a given user (ametys:acl-user nodes)- Parameters:
user
- The userrootPath
- The root path to restrict the search. Can be null.predicat
- The predicat expression. Can be null.- Returns:
- The ACL user objects for user
-
getACLUsers
public static NodeIterator getACLUsers(Expression predicat)
Returns all ACL objects for users (ametys:acl-user nodes)- Parameters:
predicat
- The predicat expression. Can be null.- Returns:
- The ACL user objects for users
-
getACLGroups
public static NodeIterator getACLGroups(Expression predicat)
Returns all ACL objects for groups (ametys:acl-group nodes)- Parameters:
predicat
- The predicat expression. Can be null.- Returns:
- The ACL group objects for groups
-
_getApprochingACLGroups
private static NodeIterator _getApprochingACLGroups(Set<GroupIdentity> groups, String rootPath, Expression predicat)
-
getACLGroups
public static NodeIterator getACLGroups(GroupIdentity group, String rootPath, Expression predicat)
Returns all ACL objects for a given group (ametys:acl-group nodes)- Parameters:
group
- The grouprootPath
- The root path to restrict the search. Can be null.predicat
- The predicat expression. Can be null.- Returns:
- The ACL user objects for groups
-
_query
private static NodeIterator _query(String jcrQuery)
-
getProfilesForAnonymousAndAnyConnectedUser
public static Map<ProfileAssignmentStorage.AnonymousOrAnyConnectedKeys,Set<String>> getProfilesForAnonymousAndAnyConnectedUser(Node node)
- Parameters:
node
- The JCR node for the Ametys object- Returns:
- a map containing allowed/denied profiles that anonymous and any connected user has on the given object
-
addAllowedProfilesForAnyConnectedUser
public static void addAllowedProfilesForAnyConnectedUser(Node node, Set<String> profileIds)
- Parameters:
node
- The JCR node for the Ametys objectprofileIds
- The profiles to add
-
removeAllowedProfilesForAnyConnectedUser
public static void removeAllowedProfilesForAnyConnectedUser(Node node, Set<String> profileIds)
- Parameters:
node
- The JCR node for the Ametys objectprofileIds
- The profiles to remove
-
addDeniedProfilesForAnyConnectedUser
public static void addDeniedProfilesForAnyConnectedUser(Node node, Set<String> profileIds)
- Parameters:
node
- The JCR node for the Ametys objectprofileIds
- The profiles to add
-
removeDeniedProfilesForAnyConnectedUser
public static void removeDeniedProfilesForAnyConnectedUser(Node node, Set<String> profileIds)
- Parameters:
node
- The JCR node for the Ametys objectprofileIds
- The profiles to remove
-
addAllowedProfilesForAnonymous
public static void addAllowedProfilesForAnonymous(Node node, Set<String> profileIds)
- Parameters:
node
- The JCR node for the Ametys objectprofileIds
- The profiles to add
-
removeAllowedProfilesForAnonymous
public static void removeAllowedProfilesForAnonymous(Node node, Set<String> profileIds)
- Parameters:
node
- The JCR node for the Ametys objectprofileIds
- The profiles to remove
-
addDeniedProfilesForAnonymous
public static void addDeniedProfilesForAnonymous(Node node, Set<String> profileIds)
- Parameters:
node
- The JCR node for the Ametys objectprofileIds
- The profiles to add
-
removeDeniedProfilesForAnonymous
public static void removeDeniedProfilesForAnonymous(Node node, Set<String> profileIds)
- Parameters:
node
- The JCR node for the Ametys objectprofileIds
- The profiles to remove
-
getProfilesForUsers
public static Map<UserIdentity,Map<ProfileAssignmentStorage.UserOrGroup,Set<String>>> getProfilesForUsers(Node node, UserIdentity user)
- Parameters:
node
- The JCR node for the Ametys objectuser
- The user to get profiles for. Can be null to get profiles for all users that have rights- Returns:
- The map of allowed users with their assigned allowed/denied profiles
-
addAllowedUsers
public static void addAllowedUsers(Set<UserIdentity> users, Node node, String profileId)
- Parameters:
users
- The users to addnode
- The JCR node for the Ametys objectprofileId
- The id of the profile
-
removeAllowedUsers
public static void removeAllowedUsers(Set<UserIdentity> users, Node node, String profileId)
- Parameters:
users
- The users to removenode
- The JCR node for the Ametys objectprofileId
- The id of the profile
-
removeAllowedUsers
public static void removeAllowedUsers(Set<UserIdentity> users, Node node)
- Parameters:
users
- The users to removenode
- The JCR node for the Ametys object
-
addDeniedUsers
public static void addDeniedUsers(Set<UserIdentity> users, Node node, String profileId)
- Parameters:
users
- The users to addnode
- The JCR node for the Ametys objectprofileId
- The id of the profile
-
removeDeniedUsers
public static void removeDeniedUsers(Set<UserIdentity> users, Node node, String profileId)
- Parameters:
users
- The users to removenode
- The JCR node for the Ametys objectprofileId
- The id of the profile
-
removeDeniedUsers
public static void removeDeniedUsers(Set<UserIdentity> users, Node node)
- Parameters:
users
- The users to removenode
- The JCR node for the Ametys object
-
getProfilesForGroups
public static Map<GroupIdentity,Map<ProfileAssignmentStorage.UserOrGroup,Set<String>>> getProfilesForGroups(Node node, Set<GroupIdentity> groups)
- Parameters:
node
- The JCR node for the Ametys objectgroups
- The group to get profiles for. Can be null to get profiles for all groups that have rights- Returns:
- The map of allowed/denied groups with their assigned profiles
-
addAllowedGroups
public static void addAllowedGroups(Set<GroupIdentity> groups, Node node, String profileId)
- Parameters:
groups
- The groups to addnode
- The JCR node for the Ametys objectprofileId
- The id of the profile
-
removeAllowedGroups
public static void removeAllowedGroups(Set<GroupIdentity> groups, Node node, String profileId)
- Parameters:
groups
- The groups to removenode
- The JCR node for the Ametys objectprofileId
- The id of the profile
-
removeAllowedGroups
public static void removeAllowedGroups(Set<GroupIdentity> groups, Node node)
- Parameters:
groups
- The groups to removenode
- The JCR node for the Ametys object
-
addDeniedGroups
public static void addDeniedGroups(Set<GroupIdentity> groups, Node node, String profileId)
- Parameters:
groups
- The groups to addnode
- The JCR node for the Ametys objectprofileId
- The id of the profile
-
removeDeniedGroups
public static void removeDeniedGroups(Set<GroupIdentity> groups, Node node, String profileId)
- Parameters:
groups
- The groups to removenode
- The JCR node for the Ametys objectprofileId
- The id of the profile
-
removeDeniedGroups
public static void removeDeniedGroups(Set<GroupIdentity> groups, Node node)
- Parameters:
groups
- The groups to removenode
- The JCR node for the Ametys object
-
removeProfile
public static void removeProfile(String profileId)
- Parameters:
profileId
- The id of the profile
-
removeUser
public static void removeUser(UserIdentity user)
- Parameters:
user
- The user
-
removeGroup
public static void removeGroup(GroupIdentity group)
- Parameters:
group
- The group
-
isInheritanceDisallowed
public static boolean isInheritanceDisallowed(Node node)
Helper forACLAmetysObject.isInheritanceDisallowed()
- Parameters:
node
- The JCR node for the Ametys object- Returns:
- true if the inheritance is disallow of the given node
-
disallowInheritance
public static void disallowInheritance(Node node, boolean disallow)
- Parameters:
node
- The JCR node for the Ametys objectdisallow
- true to disallow the inheritance, false otherwise
-
_checkLock
private static void _checkLock(Node node) throws AmetysRepositoryException
- Throws:
AmetysRepositoryException
-
_getOrCreateACLNode
private static Node _getOrCreateACLNode(Node node)
-
_getACLNode
private static Node _getACLNode(Node node)
-
_getOrCreateUsersNode
private static Node _getOrCreateUsersNode(Node node)
-
_getUserNode
private static Node _getUserNode(Node node, UserIdentity user)
-
_getUsersNode
private static Node _getUsersNode(Node node)
-
_getOrCreateGroupsNode
private static Node _getOrCreateGroupsNode(Node node)
-
_getGroupsNode
private static Node _getGroupsNode(Node node)
-
_getOrCreateUserNode
private static Node _getOrCreateUserNode(Node node, UserIdentity userIdentity)
-
_getOrCreateGroupNode
private static Node _getOrCreateGroupNode(Node node, GroupIdentity groupIdentity)
-
_getProperty
private static Set<String> _getProperty(Node node, String propertyName)
-
_setProperty
private static void _setProperty(Node node, String propertyName, Set<String> profiles)
-
_addProperty
private static void _addProperty(Node node, String propertyName, String profileToAdd)
-
_removeProperty
private static void _removeProperty(Node node, String propertyName, String profileToRemove)
-
-