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.
-
-
Field Summary
Fields Modifier and Type Field Description protected static Repository
_repository
The repositoryprotected static AmetysObjectResolver
_resolver
The AmetysObject resolver
-
Constructor Summary
Constructors Constructor Description ACLJCRAmetysObjectHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
-
-
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.
-
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
-
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
-
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
-
-