com.atlassian.crowd.directory
Class AbstractInternalDirectory
java.lang.Object
com.atlassian.crowd.directory.AbstractInternalDirectory
- All Implemented Interfaces:
- InternalRemoteDirectory, RemoteDirectory, Attributes
- Direct Known Subclasses:
- CachingDirectory, InternalDirectory
public abstract class AbstractInternalDirectory
- extends Object
- implements InternalRemoteDirectory
This class holds methods that are common to both InternalDirectory and CachingDirectory.
|
Method Summary |
Group |
addGroup(GroupTemplate group)
|
void |
addGroupToGroup(String childGroup,
String parentGroup)
|
abstract Group |
addLocalGroup(GroupTemplate group)
|
abstract User |
addUser(UserTemplate user,
PasswordCredential credential)
|
void |
addUserToGroup(String username,
String groupName)
|
User |
authenticate(String name,
PasswordCredential credential)
|
protected long |
currentPrincipalInvalidPasswordAttempts(UserWithAttributes user)
|
protected PasswordCredential |
encryptedCredential(PasswordCredential passwordCredential)
|
InternalDirectoryGroup |
findGroupByName(String name)
|
GroupWithAttributes |
findGroupWithAttributesByName(String name)
|
TimestampedUser |
findUserByExternalId(String externalId)
|
TimestampedUser |
findUserByName(String name)
|
UserWithAttributes |
findUserWithAttributesByName(String name)
|
User |
forceRenameUser(User oldUser,
String newName)
|
RemoteDirectory |
getAuthoritativeDirectory()
|
String |
getDescriptiveName()
|
long |
getDirectoryId()
|
protected PasswordEncoder |
getEncoder()
|
Set<String> |
getKeys()
|
Iterable<Membership> |
getMemberships()
|
String |
getValue(String name)
|
Set<String> |
getValues(String name)
|
boolean |
isEmpty()
|
boolean |
isGroupDirectGroupMember(String childGroup,
String parentGroup)
|
boolean |
isRolesDisabled()
|
boolean |
isUserDirectGroupMember(String username,
String groupName)
|
BatchResult<String> |
removeAllGroups(Set<String> groupNames)
|
BatchResult<String> |
removeAllUsers(Set<String> userNames)
|
void |
removeGroup(String name)
|
void |
removeGroupAttributes(String groupName,
String attributeName)
|
void |
removeGroupFromGroup(String childGroup,
String parentGroup)
|
void |
removeUser(String name)
|
void |
removeUserAttributes(String username,
String attributeName)
|
void |
removeUserFromGroup(String username,
String groupName)
|
Group |
renameGroup(String oldName,
String newName)
|
User |
renameUser(String oldName,
String newName)
|
protected boolean |
requiresPasswordChange(UserWithAttributes user)
|
|
searchGroupRelationships(MembershipQuery<T> query)
|
|
searchGroups(EntityQuery<T> query)
|
|
searchUsers(EntityQuery<T> query)
|
void |
setAttributes(Map<String,String> attributes)
Called by the DirectoryInstanceLoader after
constructing an InternalDirectory. |
void |
setDirectoryId(long id)
Called by the DirectoryInstanceLoader after
constructing an InternalDirectory. |
void |
storeGroupAttributes(String groupName,
Map<String,Set<String>> attributes)
|
void |
storeUserAttributes(String username,
Map<String,Set<String>> attributes)
|
boolean |
supportsInactiveAccounts()
Internal directories always support inactive accounts. |
boolean |
supportsNestedGroups()
|
void |
testConnection()
Does nothing, connection is determined by the ability to communicate with the database. |
Group |
updateGroup(GroupTemplate group)
|
void |
updateUserCredential(String name,
PasswordCredential newCredential)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DESCRIPTIVE_NAME
public static final String DESCRIPTIVE_NAME
- See Also:
- Constant Field Values
ATTRIBUTE_PASSWORD_REGEX
public static final String ATTRIBUTE_PASSWORD_REGEX
- See Also:
- Constant Field Values
ATTRIBUTE_PASSWORD_COMPLEXITY_MESSAGE
public static final String ATTRIBUTE_PASSWORD_COMPLEXITY_MESSAGE
- See Also:
- Constant Field Values
ATTRIBUTE_PASSWORD_MAX_ATTEMPTS
public static final String ATTRIBUTE_PASSWORD_MAX_ATTEMPTS
- See Also:
- Constant Field Values
ATTRIBUTE_PASSWORD_HISTORY_COUNT
public static final String ATTRIBUTE_PASSWORD_HISTORY_COUNT
- See Also:
- Constant Field Values
ATTRIBUTE_USER_ENCRYPTION_METHOD
public static final String ATTRIBUTE_USER_ENCRYPTION_METHOD
- See Also:
- Constant Field Values
ATTRIBUTE_PASSWORD_MAX_CHANGE_TIME
public static final String ATTRIBUTE_PASSWORD_MAX_CHANGE_TIME
- See Also:
- Constant Field Values
directoryId
protected long directoryId
attributes
protected AttributeValuesHolder attributes
passwordEncoderFactory
protected final PasswordEncoderFactory passwordEncoderFactory
directoryDao
protected final DirectoryDao directoryDao
userDao
protected final UserDao userDao
groupDao
protected final GroupDao groupDao
membershipDao
protected final MembershipDao membershipDao
internalDirectoryUtils
protected final InternalDirectoryUtils internalDirectoryUtils
AbstractInternalDirectory
public AbstractInternalDirectory(InternalDirectoryUtils internalDirectoryUtils,
PasswordEncoderFactory passwordEncoderFactory,
DirectoryDao directoryDao,
UserDao userDao,
GroupDao groupDao,
MembershipDao membershipDao)
getDirectoryId
public long getDirectoryId()
- Specified by:
getDirectoryId in interface RemoteDirectory
setDirectoryId
public void setDirectoryId(long id)
- Called by the
DirectoryInstanceLoader after
constructing an InternalDirectory.
- Specified by:
setDirectoryId in interface RemoteDirectory
- Parameters:
id - The unique id of the Directory stored in the database.
setAttributes
public void setAttributes(Map<String,String> attributes)
- Called by the
DirectoryInstanceLoader after
constructing an InternalDirectory.
- Specified by:
setAttributes in interface RemoteDirectory
- Parameters:
attributes - attributes map.
getValues
public Set<String> getValues(String name)
- Specified by:
getValues in interface Attributes
getValue
public String getValue(String name)
- Specified by:
getValue in interface Attributes
getKeys
public Set<String> getKeys()
- Specified by:
getKeys in interface Attributes
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty in interface Attributes
getDescriptiveName
public String getDescriptiveName()
- Specified by:
getDescriptiveName in interface RemoteDirectory
findUserByName
public TimestampedUser findUserByName(String name)
throws UserNotFoundException
- Specified by:
findUserByName in interface InternalRemoteDirectory- Specified by:
findUserByName in interface RemoteDirectory
- Throws:
UserNotFoundException
findUserByExternalId
public TimestampedUser findUserByExternalId(String externalId)
throws UserNotFoundException
- Specified by:
findUserByExternalId in interface InternalRemoteDirectory- Specified by:
findUserByExternalId in interface RemoteDirectory
- Throws:
UserNotFoundException
findUserWithAttributesByName
public UserWithAttributes findUserWithAttributesByName(String name)
throws UserNotFoundException
- Specified by:
findUserWithAttributesByName in interface RemoteDirectory
- Throws:
UserNotFoundException
authenticate
public User authenticate(String name,
PasswordCredential credential)
throws InactiveAccountException,
InvalidAuthenticationException,
ExpiredCredentialException,
UserNotFoundException
- Specified by:
authenticate in interface RemoteDirectory
- 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.
currentPrincipalInvalidPasswordAttempts
protected long currentPrincipalInvalidPasswordAttempts(UserWithAttributes user)
- Parameters:
user - user with attributes.
- Returns:
- long value of the invalid password attempts attribute on the user.
requiresPasswordChange
protected boolean requiresPasswordChange(UserWithAttributes user)
- Parameters:
user - user with attributes.
- Returns:
true if 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 User addUser(UserTemplate user,
PasswordCredential credential)
throws InvalidCredentialException,
InvalidUserException,
UserAlreadyExistsException,
OperationFailedException
- Specified by:
addUser in interface RemoteDirectory
- Throws:
InvalidCredentialException
InvalidUserException
UserAlreadyExistsException
OperationFailedException
encryptedCredential
protected PasswordCredential encryptedCredential(PasswordCredential passwordCredential)
getEncoder
protected PasswordEncoder getEncoder()
updateUserCredential
public void updateUserCredential(String name,
PasswordCredential newCredential)
throws InvalidCredentialException,
UserNotFoundException
- Specified by:
updateUserCredential in interface RemoteDirectory
- Throws:
InvalidCredentialException
UserNotFoundException
renameUser
public User renameUser(String oldName,
String newName)
throws InvalidUserException,
UserNotFoundException,
UserAlreadyExistsException
- Specified by:
renameUser in interface RemoteDirectory
- Throws:
InvalidUserException
UserNotFoundException
UserAlreadyExistsException
forceRenameUser
public User forceRenameUser(@Nonnull
User oldUser,
@Nonnull
String newName)
throws UserNotFoundException
- Specified by:
forceRenameUser in interface InternalRemoteDirectory
- Throws:
UserNotFoundException
storeUserAttributes
public void storeUserAttributes(String username,
Map<String,Set<String>> attributes)
throws UserNotFoundException
- Specified by:
storeUserAttributes in interface RemoteDirectory
- Throws:
UserNotFoundException
removeUserAttributes
public void removeUserAttributes(String username,
String attributeName)
throws UserNotFoundException
- Specified by:
removeUserAttributes in interface RemoteDirectory
- Throws:
UserNotFoundException
removeUser
public void removeUser(String name)
throws UserNotFoundException
- Specified by:
removeUser in interface RemoteDirectory
- Throws:
UserNotFoundException
removeAllUsers
public BatchResult<String> removeAllUsers(Set<String> userNames)
- Specified by:
removeAllUsers in interface InternalRemoteDirectory
removeAllGroups
public BatchResult<String> removeAllGroups(Set<String> groupNames)
- Specified by:
removeAllGroups in interface InternalRemoteDirectory
searchUsers
public <T> List<T> searchUsers(EntityQuery<T> query)
- Specified by:
searchUsers in interface RemoteDirectory
findGroupByName
public InternalDirectoryGroup findGroupByName(String name)
throws GroupNotFoundException
- Specified by:
findGroupByName in interface InternalRemoteDirectory- Specified by:
findGroupByName in interface RemoteDirectory
- Throws:
GroupNotFoundException
findGroupWithAttributesByName
public GroupWithAttributes findGroupWithAttributesByName(String name)
throws GroupNotFoundException
- Specified by:
findGroupWithAttributesByName in interface RemoteDirectory
- Throws:
GroupNotFoundException
addGroup
public Group addGroup(GroupTemplate group)
throws InvalidGroupException,
OperationFailedException
- Specified by:
addGroup in interface RemoteDirectory
- Throws:
InvalidGroupException
OperationFailedException
addLocalGroup
public abstract Group addLocalGroup(GroupTemplate group)
throws InvalidGroupException,
OperationFailedException
- Specified by:
addLocalGroup in interface InternalRemoteDirectory
- Throws:
InvalidGroupException
OperationFailedException
updateGroup
public Group updateGroup(GroupTemplate group)
throws InvalidGroupException,
GroupNotFoundException
- Specified by:
updateGroup in interface RemoteDirectory
- Throws:
InvalidGroupException
GroupNotFoundException
renameGroup
public Group renameGroup(String oldName,
String newName)
throws InvalidGroupException,
GroupNotFoundException
- Specified by:
renameGroup in interface RemoteDirectory
- Throws:
InvalidGroupException
GroupNotFoundException
storeGroupAttributes
public void storeGroupAttributes(String groupName,
Map<String,Set<String>> attributes)
throws GroupNotFoundException
- Specified by:
storeGroupAttributes in interface RemoteDirectory
- Throws:
GroupNotFoundException
removeGroupAttributes
public void removeGroupAttributes(String groupName,
String attributeName)
throws GroupNotFoundException
- Specified by:
removeGroupAttributes in interface RemoteDirectory
- Throws:
GroupNotFoundException
removeGroup
public void removeGroup(String name)
throws GroupNotFoundException
- Specified by:
removeGroup in interface RemoteDirectory
- Throws:
GroupNotFoundException
searchGroups
public <T> List<T> searchGroups(EntityQuery<T> query)
- Specified by:
searchGroups in interface RemoteDirectory
isUserDirectGroupMember
public boolean isUserDirectGroupMember(String username,
String groupName)
- Specified by:
isUserDirectGroupMember in interface RemoteDirectory
isGroupDirectGroupMember
public boolean isGroupDirectGroupMember(String childGroup,
String parentGroup)
- Specified by:
isGroupDirectGroupMember in interface RemoteDirectory
addUserToGroup
public void addUserToGroup(String username,
String groupName)
throws UserNotFoundException,
GroupNotFoundException,
MembershipAlreadyExistsException
- Specified by:
addUserToGroup in interface RemoteDirectory
- Throws:
UserNotFoundException
GroupNotFoundException
MembershipAlreadyExistsException
addGroupToGroup
public void addGroupToGroup(String childGroup,
String parentGroup)
throws InvalidMembershipException,
GroupNotFoundException,
MembershipAlreadyExistsException
- Specified by:
addGroupToGroup in interface RemoteDirectory
- Throws:
InvalidMembershipException
GroupNotFoundException
MembershipAlreadyExistsException
removeUserFromGroup
public void removeUserFromGroup(String username,
String groupName)
throws MembershipNotFoundException,
GroupNotFoundException,
UserNotFoundException
- Specified by:
removeUserFromGroup in interface RemoteDirectory
- Throws:
MembershipNotFoundException
GroupNotFoundException
UserNotFoundException
removeGroupFromGroup
public void removeGroupFromGroup(String childGroup,
String parentGroup)
throws InvalidMembershipException,
MembershipNotFoundException,
GroupNotFoundException
- Specified by:
removeGroupFromGroup in interface RemoteDirectory
- Throws:
InvalidMembershipException
MembershipNotFoundException
GroupNotFoundException
searchGroupRelationships
public <T> List<T> searchGroupRelationships(MembershipQuery<T> query)
- Specified by:
searchGroupRelationships in interface RemoteDirectory
testConnection
public void testConnection()
throws OperationFailedException
- 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:
testConnection in interface RemoteDirectory
- Throws:
OperationFailedException
supportsInactiveAccounts
public boolean supportsInactiveAccounts()
- Internal directories always support inactive accounts.
- Specified by:
supportsInactiveAccounts in interface RemoteDirectory
- Returns:
- true
supportsNestedGroups
public boolean supportsNestedGroups()
- Specified by:
supportsNestedGroups in interface RemoteDirectory
- Returns:
true because Internal Directories support nested groups as of Crowd 2.0.
isRolesDisabled
public boolean isRolesDisabled()
- Specified by:
isRolesDisabled in interface RemoteDirectory
getMemberships
public Iterable<Membership> getMemberships()
throws OperationFailedException
- Specified by:
getMemberships in interface RemoteDirectory
- Throws:
OperationFailedException
getAuthoritativeDirectory
public RemoteDirectory getAuthoritativeDirectory()
- Specified by:
getAuthoritativeDirectory in interface RemoteDirectory
Copyright © 2014 Atlassian. All Rights Reserved.