Package com.atlassian.crowd.directory
Class AbstractInternalDirectory
java.lang.Object
com.atlassian.crowd.directory.AbstractInternalDirectory
- All Implemented Interfaces:
FastEntityCountProvider,InternalRemoteDirectory,MultiValuesQueriesSupport,RemoteDirectory,Attributes
- Direct Known Subclasses:
CachingDirectory,InternalDirectory
This class holds methods that are common to both
InternalDirectory and CachingDirectory.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe minimum password score allowed for new passwords for users in this directory, stored asPasswordScore.getRanking().static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected AttributeValuesHolderstatic final Stringprotected final DirectoryDaoprotected longprotected final GroupDaoprotected final InternalDirectoryUtilsprotected final MembershipDaoprotected final PasswordEncoderFactoryprotected final TombstoneDaoprotected final UserDao -
Constructor Summary
ConstructorsConstructorDescriptionAbstractInternalDirectory(InternalDirectoryUtils internalDirectoryUtils, PasswordEncoderFactory passwordEncoderFactory, DirectoryDao directoryDao, UserDao userDao, GroupDao groupDao, MembershipDao membershipDao, TombstoneDao tombstoneDao, PasswordConstraintsLoader passwordConstraints) -
Method Summary
Modifier and TypeMethodDescriptionaddAllGroupsToGroup(Collection<String> childGroupNames, String groupName) addGroup(GroupTemplate group) voidaddGroupToGroup(String childGroup, String parentGroup) abstract GroupaddLocalGroup(GroupTemplate group) abstract UserWithAttributesaddUser(UserTemplateWithAttributes user, PasswordCredential credential) voidaddUserToGroup(String username, String groupName) addUserToGroups(String username, Set<String> groupNames) authenticate(String name, PasswordCredential credential) Generate the list of default attributes and values relating to passwords, for use when creating or resetting a passwordcountDirectMembersOfGroup(String groupName, int querySizeHint) protected longprotected PasswordCredentialencryptedCredential(PasswordCredential passwordCredential) voidfindGroupByName(String name) findUserByExternalId(String externalId) findUserByName(String name) forceRenameUser(User oldUser, String newName) longprotected PasswordEncoderlonggetKeys()protected final Set<PasswordConstraint>getUserAvatarByName(String username, int sizeHint) longbooleanisEmpty()booleanisGroupDirectGroupMember(String childGroup, String parentGroup) booleanbooleanisUserDirectGroupMember(String username, String groupName) removeAllGroups(Set<String> groupNames) removeAllUsers(Set<String> userNames) voidremoveGroup(String name) voidremoveGroupAttributes(String groupName, String attributeName) voidremoveGroupFromGroup(String childGroup, String parentGroup) removeGroupsFromGroup(Collection<String> childGroupNames, String groupName) voidremoveUser(String name) voidremoveUserAttributes(String username, String attributeName) voidremoveUserFromGroup(String username, String groupName) removeUsersFromGroup(Set<String> usernames, String groupName) renameGroup(String oldName, String newName) renameUser(String oldName, String newName) protected boolean<T> List<T>searchGroupRelationships(MembershipQuery<T> query) <T> List<T>searchGroups(EntityQuery<T> query) <T> List<T>searchUsers(EntityQuery<T> query) voidsetAttributes(Map<String, String> attributes) Called by theDirectoryInstanceLoaderafter constructing an InternalDirectory.voidsetDirectoryId(long id) Called by theDirectoryInstanceLoaderafter constructing an InternalDirectory.voidvoidbooleanInternal directories always support inactive accounts.booleanbooleanInternal Directories always support expiring passwordsbooleanInternal directories always support setting passwords by hash.voidDoes nothing, connection is determined by the ability to communicate with the database.updateGroup(GroupTemplate group) voidupdateUserCredential(String name, PasswordCredential newCredential) userAuthenticated(String username) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.crowd.directory.InternalRemoteDirectory
addAllGroups, addAllUsers, addAllUsersToGroup, isLocalUserStatusEnabledMethods inherited from interface com.atlassian.crowd.directory.RemoteDirectory
addUser, getLocallyFilteredGroupNames, updateUser, updateUserFromRemoteDirectory
-
Field Details
-
DESCRIPTIVE_NAME
- See Also:
-
ATTRIBUTE_PASSWORD_REGEX
- See Also:
-
ATTRIBUTE_PASSWORD_POLICY_PRESET
- See Also:
-
ATTRIBUTE_PASSWORD_MINIMUM_LENGTH
- See Also:
-
ATTRIBUTE_PASSWORD_MINIMUM_UPPERCASE
- See Also:
-
ATTRIBUTE_PASSWORD_MINIMUM_LOWERCASE
- See Also:
-
ATTRIBUTE_PASSWORD_MINIMUM_DIGITS
- See Also:
-
ATTRIBUTE_PASSWORD_MINIMUM_SPECIAL_CHARACTERS
- See Also:
-
ATTRIBUTE_PASSWORD_MINIMUM_RULES_MATCHED
- See Also:
-
ATTRIBUTE_PASSWORD_COMPLEXITY_MESSAGE
- See Also:
-
ATTRIBUTE_PASSWORD_MAX_ATTEMPTS
- See Also:
-
ATTRIBUTE_PASSWORD_HISTORY_COUNT
- See Also:
-
ATTRIBUTE_USER_ENCRYPTION_METHOD
- See Also:
-
ATTRIBUTE_PASSWORD_MAX_CHANGE_TIME
- See Also:
-
ATTRIBUTE_PASSWORD_EXPIRATION_NOTIFICATION_PERIODS
- See Also:
-
ATTRIBUTE_PASSWORD_MINIMUM_SCORE
The minimum password score allowed for new passwords for users in this directory, stored asPasswordScore.getRanking().- See Also:
-
CHARACTER_CLASS_CONSTRAINT_ATTRIBUTES
-
directoryId
protected long directoryId -
attributes
-
passwordEncoderFactory
-
directoryDao
-
userDao
-
groupDao
-
membershipDao
-
tombstoneDao
-
internalDirectoryUtils
-
-
Constructor Details
-
AbstractInternalDirectory
public AbstractInternalDirectory(InternalDirectoryUtils internalDirectoryUtils, PasswordEncoderFactory passwordEncoderFactory, DirectoryDao directoryDao, UserDao userDao, GroupDao groupDao, MembershipDao membershipDao, TombstoneDao tombstoneDao, PasswordConstraintsLoader passwordConstraints)
-
-
Method Details
-
getDirectoryId
public long getDirectoryId()- Specified by:
getDirectoryIdin interfaceRemoteDirectory
-
setDirectoryId
public void setDirectoryId(long id) Called by theDirectoryInstanceLoaderafter constructing an InternalDirectory.- Specified by:
setDirectoryIdin interfaceRemoteDirectory- Parameters:
id- The uniqueidof the Directory stored in the database.
-
setAttributes
Called by theDirectoryInstanceLoaderafter constructing an InternalDirectory.- Specified by:
setAttributesin interfaceRemoteDirectory- Parameters:
attributes- attributes map.
-
getValues
- Specified by:
getValuesin interfaceAttributes
-
getValue
- Specified by:
getValuein interfaceAttributes
-
getKeys
- Specified by:
getKeysin interfaceAttributes
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceAttributes
-
getDescriptiveName
- Specified by:
getDescriptiveNamein interfaceRemoteDirectory
-
findUserByName
- Specified by:
findUserByNamein interfaceInternalRemoteDirectory- Specified by:
findUserByNamein interfaceRemoteDirectory- Throws:
UserNotFoundException
-
findUserByExternalId
- Specified by:
findUserByExternalIdin interfaceInternalRemoteDirectory- Specified by:
findUserByExternalIdin interfaceRemoteDirectory- Throws:
UserNotFoundException
-
findUserWithAttributesByName
- Specified by:
findUserWithAttributesByNamein interfaceRemoteDirectory- Throws:
UserNotFoundException
-
authenticate
public User authenticate(String name, PasswordCredential credential) throws InactiveAccountException, InvalidAuthenticationException, ExpiredCredentialException, UserNotFoundException - Specified by:
authenticatein interfaceRemoteDirectory- Parameters:
name- The name of the user (username).credential- The supplied credentials (password).- Returns:
- user entity.
- Throws:
InactiveAccountException- The supplied user is inactive.InvalidAuthenticationException- Authentication with the provided credentials failed OR the user has exceeded the maximum number of failed authentication attempts.UserNotFoundException- The user wth the supplied name does not exist.ExpiredCredentialException- The user's credentials have expired. The user must change their credentials in order to successfully authenticate.
-
userAuthenticated
public User userAuthenticated(String username) throws OperationFailedException, UserNotFoundException, InactiveAccountException - Specified by:
userAuthenticatedin interfaceRemoteDirectory- Throws:
OperationFailedExceptionUserNotFoundExceptionInactiveAccountException
-
currentPrincipalInvalidPasswordAttempts
- Parameters:
user- user with attributes.- Returns:
- long value of the invalid password attempts attribute on the user.
-
requiresPasswordChange
- Parameters:
user- user with attributes.- Returns:
trueif the requires password change attribute on the user is set to true, or if the password last changed attribute on the user exceeds the password max change time attribute on the directory (ie. password timeout).
-
addUser
public abstract UserWithAttributes addUser(UserTemplateWithAttributes user, PasswordCredential credential) throws InvalidCredentialException, InvalidUserException, UserAlreadyExistsException, OperationFailedException - Specified by:
addUserin interfaceRemoteDirectory- Throws:
InvalidCredentialExceptionInvalidUserExceptionUserAlreadyExistsExceptionOperationFailedException
-
encryptedCredential
-
getEncoder
-
updateUserCredential
public void updateUserCredential(String name, PasswordCredential newCredential) throws InvalidCredentialException, UserNotFoundException - Specified by:
updateUserCredentialin interfaceRemoteDirectory- Throws:
InvalidCredentialExceptionUserNotFoundException
-
calculatePostPasswordUpdateAttributes
Generate the list of default attributes and values relating to passwords, for use when creating or resetting a password- Returns:
- A map containing the values to then be stored
-
renameUser
public User renameUser(String oldName, String newName) throws InvalidUserException, UserNotFoundException, UserAlreadyExistsException - Specified by:
renameUserin interfaceRemoteDirectory- Throws:
InvalidUserExceptionUserNotFoundExceptionUserAlreadyExistsException
-
forceRenameUser
public User forceRenameUser(@Nonnull User oldUser, @Nonnull String newName) throws UserNotFoundException - Specified by:
forceRenameUserin interfaceInternalRemoteDirectory- Throws:
UserNotFoundException
-
getPasswordConstraints
-
getAllUserExternalIds
- Specified by:
getAllUserExternalIdsin interfaceInternalRemoteDirectory- Throws:
OperationFailedException
-
getUserCount
- Specified by:
getUserCountin interfaceFastEntityCountProvider- Throws:
OperationFailedException
-
getGroupCount
- Specified by:
getGroupCountin interfaceFastEntityCountProvider- Throws:
OperationFailedException
-
storeUserAttributes
public void storeUserAttributes(String username, Map<String, Set<String>> attributes) throws UserNotFoundException, OperationFailedException- Specified by:
storeUserAttributesin interfaceRemoteDirectory- Throws:
UserNotFoundExceptionOperationFailedException
-
removeUserAttributes
public void removeUserAttributes(String username, String attributeName) throws UserNotFoundException - Specified by:
removeUserAttributesin interfaceRemoteDirectory- Throws:
UserNotFoundException
-
removeUser
- Specified by:
removeUserin interfaceRemoteDirectory- Throws:
UserNotFoundException
-
removeAllUsers
- Specified by:
removeAllUsersin interfaceInternalRemoteDirectory
-
removeAllGroups
- Specified by:
removeAllGroupsin interfaceInternalRemoteDirectory
-
searchUsers
- Specified by:
searchUsersin interfaceRemoteDirectory
-
findGroupByName
- Specified by:
findGroupByNamein interfaceInternalRemoteDirectory- Specified by:
findGroupByNamein interfaceRemoteDirectory- Throws:
GroupNotFoundException
-
findGroupWithAttributesByName
- Specified by:
findGroupWithAttributesByNamein interfaceRemoteDirectory- Throws:
GroupNotFoundException
-
addGroup
- Specified by:
addGroupin interfaceRemoteDirectory- Throws:
InvalidGroupExceptionOperationFailedException
-
addLocalGroup
public abstract Group addLocalGroup(GroupTemplate group) throws InvalidGroupException, OperationFailedException - Specified by:
addLocalGroupin interfaceInternalRemoteDirectory- Throws:
InvalidGroupExceptionOperationFailedException
-
updateGroup
- Specified by:
updateGroupin interfaceRemoteDirectory- Throws:
InvalidGroupExceptionGroupNotFoundException
-
renameGroup
public Group renameGroup(String oldName, String newName) throws InvalidGroupException, GroupNotFoundException - Specified by:
renameGroupin interfaceRemoteDirectory- Throws:
InvalidGroupExceptionGroupNotFoundException
-
storeGroupAttributes
public void storeGroupAttributes(String groupName, Map<String, Set<String>> attributes) throws GroupNotFoundException- Specified by:
storeGroupAttributesin interfaceRemoteDirectory- Throws:
GroupNotFoundException
-
removeGroupAttributes
public void removeGroupAttributes(String groupName, String attributeName) throws GroupNotFoundException - Specified by:
removeGroupAttributesin interfaceRemoteDirectory- Throws:
GroupNotFoundException
-
removeGroup
- Specified by:
removeGroupin interfaceRemoteDirectory- Throws:
GroupNotFoundException
-
searchGroups
- Specified by:
searchGroupsin interfaceRemoteDirectory
-
isUserDirectGroupMember
- Specified by:
isUserDirectGroupMemberin interfaceRemoteDirectory
-
isGroupDirectGroupMember
- Specified by:
isGroupDirectGroupMemberin interfaceRemoteDirectory
-
addUserToGroups
public BatchResult<String> addUserToGroups(String username, Set<String> groupNames) throws UserNotFoundException - Specified by:
addUserToGroupsin interfaceInternalRemoteDirectory- Throws:
UserNotFoundException
-
addUserToGroup
public void addUserToGroup(String username, String groupName) throws UserNotFoundException, GroupNotFoundException, MembershipAlreadyExistsException - Specified by:
addUserToGroupin interfaceRemoteDirectory- Throws:
UserNotFoundExceptionGroupNotFoundExceptionMembershipAlreadyExistsException
-
addGroupToGroup
public void addGroupToGroup(String childGroup, String parentGroup) throws InvalidMembershipException, GroupNotFoundException, MembershipAlreadyExistsException - Specified by:
addGroupToGroupin interfaceRemoteDirectory- Throws:
InvalidMembershipExceptionGroupNotFoundExceptionMembershipAlreadyExistsException
-
addAllGroupsToGroup
public BatchResult<String> addAllGroupsToGroup(Collection<String> childGroupNames, String groupName) throws GroupNotFoundException - Specified by:
addAllGroupsToGroupin interfaceInternalRemoteDirectory- Throws:
GroupNotFoundException
-
removeUserFromGroup
public void removeUserFromGroup(String username, String groupName) throws MembershipNotFoundException, GroupNotFoundException, UserNotFoundException - Specified by:
removeUserFromGroupin interfaceRemoteDirectory- Throws:
MembershipNotFoundExceptionGroupNotFoundExceptionUserNotFoundException
-
removeUsersFromGroup
public BatchResult<String> removeUsersFromGroup(Set<String> usernames, String groupName) throws GroupNotFoundException - Specified by:
removeUsersFromGroupin interfaceInternalRemoteDirectory- Throws:
GroupNotFoundException
-
removeGroupFromGroup
public void removeGroupFromGroup(String childGroup, String parentGroup) throws InvalidMembershipException, MembershipNotFoundException, GroupNotFoundException - Specified by:
removeGroupFromGroupin interfaceRemoteDirectory- Throws:
InvalidMembershipExceptionMembershipNotFoundExceptionGroupNotFoundException
-
removeGroupsFromGroup
public BatchResult<String> removeGroupsFromGroup(Collection<String> childGroupNames, String groupName) throws GroupNotFoundException - Specified by:
removeGroupsFromGroupin interfaceInternalRemoteDirectory- Throws:
GroupNotFoundException
-
countDirectMembersOfGroup
- Specified by:
countDirectMembersOfGroupin interfaceRemoteDirectory
-
searchGroupRelationships
- Specified by:
searchGroupRelationshipsin interfaceMultiValuesQueriesSupport- Specified by:
searchGroupRelationshipsin interfaceRemoteDirectory
-
searchGroupRelationshipsGroupedByName
- Specified by:
searchGroupRelationshipsGroupedByNamein interfaceMultiValuesQueriesSupport
-
testConnection
Does nothing, connection is determined by the ability to communicate with the database. Crowd wouldn't have started if the database connection failed.- Specified by:
testConnectionin interfaceRemoteDirectory- Throws:
OperationFailedException
-
supportsInactiveAccounts
public boolean supportsInactiveAccounts()Internal directories always support inactive accounts.- Specified by:
supportsInactiveAccountsin interfaceRemoteDirectory- Returns:
true, always
-
supportsNestedGroups
public boolean supportsNestedGroups()- Specified by:
supportsNestedGroupsin interfaceRemoteDirectory- Returns:
truebecause Internal Directories support nested groups as of Crowd 2.0.
-
supportsPasswordExpiration
public boolean supportsPasswordExpiration()Internal Directories always support expiring passwords- Specified by:
supportsPasswordExpirationin interfaceRemoteDirectory- Returns:
true, always.
-
supportsSettingEncryptedCredential
public boolean supportsSettingEncryptedCredential()Internal directories always support setting passwords by hash.- Specified by:
supportsSettingEncryptedCredentialin interfaceRemoteDirectory- Returns:
true, always.
-
isRolesDisabled
public boolean isRolesDisabled()- Specified by:
isRolesDisabledin interfaceRemoteDirectory
-
getMemberships
- Specified by:
getMembershipsin interfaceRemoteDirectory- Throws:
OperationFailedException
-
getAuthoritativeDirectory
- Specified by:
getAuthoritativeDirectoryin interfaceRemoteDirectory
-
expireAllPasswords
public void expireAllPasswords()- Specified by:
expireAllPasswordsin interfaceRemoteDirectory
-
getUserAvatarByName
public AvatarReference getUserAvatarByName(String username, int sizeHint) throws OperationFailedException - Specified by:
getUserAvatarByNamein interfaceRemoteDirectory- Throws:
OperationFailedException
-