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) voidaddUserToGroup(String username, String groupName) 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).protected booleanisDirectGroupMemberOf(LDAPUserWithAttributes user, String groupDN) protected booleanisDnDirectGroupMember(String memberDN, LDAPGroupWithAttributes parentGroup) booleanisGroupDirectGroupMember(String childGroup, String parentGroup) booleanisUserDirectGroupMember(String username, String groupName) protected org.springframework.ldap.filter.AndFilterprepareOrFilterForGroupProperty(String propertyName, List<String> propertyValues) protected voidremoveDnFromGroup(String dn, LDAPGroupWithAttributes group) voidremoveGroupFromGroup(String childGroup, String parentGroup) voidremoveUserFromGroup(String username, String groupName) 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
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 - Throws:
OperationFailedException
-
isGroupDirectGroupMember
public boolean isGroupDirectGroupMember(String childGroup, String parentGroup) throws OperationFailedException - Throws:
OperationFailedException
-
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 -
addGroupToGroup
public void addGroupToGroup(String childGroup, String parentGroup) throws GroupNotFoundException, InvalidMembershipException, OperationFailedException, MembershipAlreadyExistsException -
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 -
removeGroupFromGroup
public void removeGroupFromGroup(String childGroup, String parentGroup) throws GroupNotFoundException, MembershipNotFoundException, InvalidMembershipException, OperationFailedException -
getMemberships
- Throws:
OperationFailedException
-
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
-