Package com.atlassian.crowd.directory
Class RFC4519Directory
java.lang.Object
com.atlassian.crowd.directory.SpringLDAPConnector
com.atlassian.crowd.directory.RFC4519Directory
- All Implemented Interfaces:
LDAPDirectory,RemoteDirectory,Attributes
- Direct Known Subclasses:
ApacheDS,MicrosoftActiveDirectory,NovelleDirectory,OpenLDAP,SunONE
Read-write, nesting-aware implementation of RFC4519 user-group membership
interactions.
A user is a member of a group if either:
- the DN of user is present in the collection of member attribute values of the group
- the user has a memberOf attribute which contains the DN of the group (must be enabled via LDAPPropertiesMapper)
- See Also:
-
Field Summary
FieldsFields inherited from class com.atlassian.crowd.directory.SpringLDAPConnector
attributes, contextSource, contextSourceTransactionManager, DEFAULT_PAGE_SIZE, eventPublisher, ldapPropertiesMapper, ldapQueryTranslater, ldapTemplate, nameConverter, searchDN -
Constructor Summary
ConstructorsConstructorDescriptionRFC4519Directory(LDAPQueryTranslater ldapQueryTranslater, com.atlassian.event.api.EventPublisher eventPublisher, InstanceFactory instanceFactory, LdapContextSourceProvider ldapContextSourceProvider) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddDnToGroup(String dn, LDAPGroupWithAttributes group) voidaddGroupToGroup(String childGroup, String parentGroup) Adds a group as a member of a parent group.voidaddUserToGroup(String username, String groupName) Adds a user as a member of a group.protected Iterable<CrowdLdapName> findAdditionalDirectMembers(CrowdLdapName groupDn, Supplier<Optional<LDAPGroupWithAttributes>> group, GroupUserCache groupUserCache) findDirectMembersOfGroup(CrowdLdapName groupDn, ContextMapperWithRequiredAttributes<CrowdLdapName> dnMapper, GroupUserCache groupUserCache) This method is not part ofRemoteDirectory's contract.protected List<? extends LDAPGroupWithAttributes> findGroupMemberships(MembershipQuery<? extends LDAPGroupWithAttributes> query) protected <T> List<T> findGroupMembershipsOfUserViaMemberOf(String username, int startIndex, int maxResults, com.atlassian.crowd.directory.RFC4519Directory.LookupByDn<T> mapper) protected List<LDAPUserWithAttributes> findUserMembersOfGroupViaMemberDN(String groupName, GroupType groupType, int startIndex, int maxResults) protected Iterable<LDAPUserWithAttributes> findUserMembersOfGroupViaMemberOf(String groupName, GroupType groupType, int startIndex, int maxResults) protected List<AttributeMapper> As a minimum, this SHOULD provide an attribute mapper that maps the group members attribute (if available).protected List<AttributeMapper> protected List<AttributeMapper> protected List<AttributeMapper> As a minimum, this SHOULD provide an attribute mapper that maps the group members attribute (if available).Get an iterable view of the available group memberships.protected booleanisDirectGroupMemberOf(LDAPUserWithAttributes user, String groupDN) protected booleanisDnDirectGroupMember(String memberDN, LDAPGroupWithAttributes parentGroup) booleanisGroupDirectGroupMember(String childGroup, String parentGroup) Determines if a group is a direct member of another group.booleanisUserDirectGroupMember(String username, String groupName) Determines if a user is a direct member of a group.protected org.springframework.ldap.filter.AndFilterprepareOrFilterForGroupProperty(String propertyName, List<String> propertyValues) protected voidremoveDnFromGroup(String dn, LDAPGroupWithAttributes group) voidremoveGroupFromGroup(String childGroup, String parentGroup) Removes a group as a member of a parent group.voidremoveUserFromGroup(String username, String groupName) Removes a user as a member of a group.protected <T> Iterable<T> Execute the search for group relationships given that a group of type GROUP or LEGACY_ROLE has been specified in the EntityDescriptor for the group(s).protected Collection<LDAPGroupWithAttributes> searchGroupsByAttribute(Set<String> propertyValues, Function<List<String>, org.springframework.ldap.filter.Filter> filterFunction) searchGroupsByDns(Set<String> groupsDn) protected static <T> Iterable<T> toGenericIterable(Iterable list) Converts an Iterable to a generic Iterable.Methods inherited from class com.atlassian.crowd.directory.SpringLDAPConnector
addDefaultSnToUserAttributes, addDefaultValueToUserAttributesForAttribute, addGroup, addUser, addUser, authenticate, avatarMapper, countDirectMembersOfGroup, createModificationItem, expireAllPasswords, findEntityByDN, findEntityByDN, findEntityByDN, findGroupByName, findGroupByNameAndType, findGroupWithAttributesByName, findUserByExternalId, findUserByName, findUserWithAttributesByName, getAttributeAsBoolean, getAttributeAsLong, getAuthoritativeDirectory, getBaseEnvironmentProperties, getContextSource, getCredentialEncoder, getDirectoryId, getGroupContextMapper, getGroupContextMapper, getInitialGroupMemberDN, getKeys, getLdapPropertiesMapper, getNewGroupAttributes, getNewGroupDirectorySpecificAttributes, getNewUserAttributes, getNewUserDirectorySpecificAttributes, getRequiredCustomGroupAttributeMappers, getSearchControls, getSearchDN, getUserAvatarByName, getUserModificationItems, getValue, getValues, isEmpty, isRolesDisabled, pageSearchResults, postprocessGroup, postprocessGroups, removeGroup, removeGroupAttributes, removeUser, removeUserAttributes, renameGroup, renameUser, searchEntities, searchEntitiesWithRequestControls, searchGroupObjects, searchGroupObjectsOfSpecifiedGroupType, searchGroupRelationships, searchGroups, searchUserObjects, searchUsers, searchUsers, setAttributes, setDirectoryId, setLdapPropertiesMapperAttributes, storeGroupAttributes, storeUserAttributes, supportsInactiveAccounts, supportsNestedGroups, supportsPasswordExpiration, supportsSettingEncryptedCredential, testConnection, typedEntityNotFoundException, updateGroup, updateUser, updateUserCredentialMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.crowd.directory.RemoteDirectory
authenticate, getDescriptiveName, getLocallyFilteredGroupNames, updateUserFromRemoteDirectory, userAuthenticated
-
Field Details
-
DN_MAPPER
-
-
Constructor Details
-
RFC4519Directory
public RFC4519Directory(LDAPQueryTranslater ldapQueryTranslater, com.atlassian.event.api.EventPublisher eventPublisher, InstanceFactory instanceFactory, LdapContextSourceProvider ldapContextSourceProvider)
-
-
Method Details
-
getCustomGroupAttributeMappers
Description copied from class:SpringLDAPConnectorAs a minimum, this SHOULD provide an attribute mapper that maps the group members attribute (if available).- Overrides:
getCustomGroupAttributeMappersin classSpringLDAPConnector- Returns:
- collection of custom attribute mappers (cannot be
nullbut can be an empty list).
-
getMemberOnlyGroupAttributeMappers
Description copied from class:SpringLDAPConnectorAs a minimum, this SHOULD provide an attribute mapper that maps the group members attribute (if available).- Overrides:
getMemberOnlyGroupAttributeMappersin classSpringLDAPConnector- Returns:
- collection of custom attribute mappers (cannot be
nullbut can be an empty list).
-
getMemberDnMappers
-
getCustomUserAttributeMappers
- Overrides:
getCustomUserAttributeMappersin classSpringLDAPConnector- Returns:
- a collection of custom attribute mappers. By default just return an empty list.
-
searchGroupsByDns
public Collection<LDAPGroupWithAttributes> searchGroupsByDns(Set<String> groupsDn) throws OperationFailedException - Throws:
OperationFailedException
-
searchGroupsByAttribute
protected Collection<LDAPGroupWithAttributes> searchGroupsByAttribute(Set<String> propertyValues, Function<List<String>, org.springframework.ldap.filter.Filter> filterFunction) throws OperationFailedException- Throws:
OperationFailedException
-
prepareOrFilterForGroupProperty
-
isDnDirectGroupMember
-
isDirectGroupMemberOf
-
isUserDirectGroupMember
public boolean isUserDirectGroupMember(String username, String groupName) throws OperationFailedException Description copied from interface:RemoteDirectoryDetermines if a user is a direct member of a group. The directory is NOT expected to resolve any transitive group relationships.- Parameters:
username- name of user.groupName- name of group.- Returns:
trueiff the user is a direct member of the group.- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.
-
isGroupDirectGroupMember
public boolean isGroupDirectGroupMember(String childGroup, String parentGroup) throws OperationFailedException Description copied from interface:RemoteDirectoryDetermines if a group is a direct member of another group. The directory is NOT expected to resolve any transitive group relationships.- Parameters:
childGroup- name of child group.parentGroup- name of parent group.- Returns:
trueiff the childGroup is a direct member of the parentGroup.- Throws:
OperationFailedException- underlying directory implementation failed to execute the operation.
-
addDnToGroup
protected void addDnToGroup(String dn, LDAPGroupWithAttributes group) throws OperationFailedException - Throws:
OperationFailedException
-
addUserToGroup
public void addUserToGroup(String username, String groupName) throws GroupNotFoundException, OperationFailedException, UserNotFoundException, MembershipAlreadyExistsException Description copied from interface:RemoteDirectoryAdds a user as a member of a group. This means that all user members ofchildGroupwill appear as members ofparentGroupto querying applications.- Parameters:
username- The user that will become a member ofgroupNamegroupName- The group that will gain a new member.- Throws:
GroupNotFoundException- If the group cannot be found.OperationFailedException- underlying directory implementation failed to execute the operation.UserNotFoundException- If the user cannot be found.MembershipAlreadyExistsException- if the user is already a member of the group
-
addGroupToGroup
public void addGroupToGroup(String childGroup, String parentGroup) throws GroupNotFoundException, InvalidMembershipException, OperationFailedException, MembershipAlreadyExistsException Description copied from interface:RemoteDirectoryAdds a group as a member of a parent group.- Parameters:
childGroup- The group that will become a member ofparentGroupparentGroup- The group that will gain a new member- Throws:
GroupNotFoundException- One or both of the groups cannot be found.InvalidMembershipException- if the childGroup and parentGroup exist but are of different GroupTypes.OperationFailedException- underlying directory implementation failed to execute the operation.MembershipAlreadyExistsException- if the child group is already a child of the parent group
-
removeDnFromGroup
protected void removeDnFromGroup(String dn, LDAPGroupWithAttributes group) throws OperationFailedException - Throws:
OperationFailedException
-
removeUserFromGroup
public void removeUserFromGroup(String username, String groupName) throws UserNotFoundException, GroupNotFoundException, MembershipNotFoundException, OperationFailedException Description copied from interface:RemoteDirectoryRemoves a user as a member of a group.- Parameters:
username- The user that will be removed fromparentGroupgroupName- The group that will lose the member.- Throws:
UserNotFoundException- If the user cannot be found.GroupNotFoundException- If the group cannot be found.MembershipNotFoundException- if the user is not a direct member of the group.OperationFailedException- underlying directory implementation failed to execute the operation.
-
removeGroupFromGroup
public void removeGroupFromGroup(String childGroup, String parentGroup) throws GroupNotFoundException, MembershipNotFoundException, InvalidMembershipException, OperationFailedException Description copied from interface:RemoteDirectoryRemoves a group as a member of a parent group.- Parameters:
childGroup- The group that will be removed fromparentGroupparentGroup- The group that will lose the member.- Throws:
GroupNotFoundException- One or both of the groups cannot be found.MembershipNotFoundException- if the childGroup is not a direct member of the parentGroup.InvalidMembershipException- if the childGroup and parentGroup exist but are of different GroupTypes.OperationFailedException- underlying directory implementation failed to execute the operation.
-
getMemberships
Description copied from interface:RemoteDirectoryGet an iterable view of the available group memberships. This may be implemented as a single remote call or separate calls, depending on the directory.
If there is a failure in the underlying retrieval, the iterator may throw
Membership.MembershipIterationExceptionat runtime.If the directory does not have a bulk call interface then a typical implementation would be:
return new DirectoryMembershipsIterable(this);- Returns:
- an iterable view of the available group memberships
- Throws:
OperationFailedException- if the underlying directory implementation failed to execute the operation
-
searchGroupRelationshipsWithGroupTypeSpecified
protected <T> Iterable<T> searchGroupRelationshipsWithGroupTypeSpecified(MembershipQuery<T> query) throws OperationFailedException Description copied from class:SpringLDAPConnectorExecute the search for group relationships given that a group of type GROUP or LEGACY_ROLE has been specified in the EntityDescriptor for the group(s).- Specified by:
searchGroupRelationshipsWithGroupTypeSpecifiedin classSpringLDAPConnector- Parameters:
query- membership query with all GroupType's not null.- Returns:
- list of members or memberships depending on the query.
- Throws:
OperationFailedException- if the operation failed due to a communication error with the remote directory, or if the query is invalid
-
findGroupMemberships
protected List<? extends LDAPGroupWithAttributes> findGroupMemberships(MembershipQuery<? extends LDAPGroupWithAttributes> query) throws OperationFailedException - Throws:
OperationFailedException
-
findGroupMembershipNames
protected Iterable<String> findGroupMembershipNames(MembershipQuery<String> query) throws OperationFailedException - Throws:
OperationFailedException
-
findGroupMembershipsOfUserViaMemberOf
protected <T> List<T> findGroupMembershipsOfUserViaMemberOf(String username, int startIndex, int maxResults, com.atlassian.crowd.directory.RFC4519Directory.LookupByDn<T> mapper) throws OperationFailedException - Throws:
OperationFailedException
-
findUserMembersOfGroupViaMemberDN
protected List<LDAPUserWithAttributes> findUserMembersOfGroupViaMemberDN(String groupName, GroupType groupType, int startIndex, int maxResults) throws OperationFailedException - Throws:
OperationFailedException
-
findUserMembersOfGroupViaMemberOf
protected Iterable<LDAPUserWithAttributes> findUserMembersOfGroupViaMemberOf(String groupName, GroupType groupType, int startIndex, int maxResults) throws OperationFailedException - Throws:
OperationFailedException
-
toGenericIterable
Converts an Iterable to a generic Iterable. -
findDirectMembersOfGroup
public Iterable<CrowdLdapName> findDirectMembersOfGroup(CrowdLdapName groupDn, ContextMapperWithRequiredAttributes<CrowdLdapName> dnMapper, GroupUserCache groupUserCache) throws OperationFailedException This method is not part ofRemoteDirectory's contract. It is introduced byRFC4519Directoryto supportRFC4519DirectoryMembershipsIterable. Children of this class can add additional groups by overridingfindAdditionalDirectMembers(CrowdLdapName, Supplier, GroupUserCache)- Parameters:
groupDn- LDAP name of a groupdnMapper- mapper that converts the LDAP search result into an CrowdLdapNamegroupUserCache- Contains details of any groups/users that have already been retrieved.- Returns:
- the LDAP names of the direct members (users and groups) of the given group
- Throws:
OperationFailedException- if the operation fails for any reason
-
findAdditionalDirectMembers
protected Iterable<CrowdLdapName> findAdditionalDirectMembers(CrowdLdapName groupDn, @Nullable Supplier<Optional<LDAPGroupWithAttributes>> group, GroupUserCache groupUserCache) throws OperationFailedException - Throws:
OperationFailedException
-