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 java.lang.Object
- implements InternalRemoteDirectory
This class holds methods that are common to both InternalDirectory and CachingDirectory.
|
Method Summary |
Group |
addGroup(GroupTemplate group)
|
void |
addGroupToGroup(java.lang.String childGroup,
java.lang.String parentGroup)
|
abstract Group |
addLocalGroup(GroupTemplate group)
|
abstract User |
addUser(UserTemplate user,
PasswordCredential credential)
|
void |
addUserToGroup(java.lang.String username,
java.lang.String groupName)
|
User |
authenticate(java.lang.String name,
PasswordCredential credential)
|
protected long |
currentPrincipalInvalidPasswordAttempts(UserWithAttributes user)
|
protected void |
encryptCredential(PasswordCredential passwordCredential)
|
InternalDirectoryGroup |
findGroupByName(java.lang.String name)
|
GroupWithAttributes |
findGroupWithAttributesByName(java.lang.String name)
|
TimestampedUser |
findUserByName(java.lang.String name)
|
UserWithAttributes |
findUserWithAttributesByName(java.lang.String name)
|
RemoteDirectory |
getAuthoritativeDirectory()
|
java.lang.String |
getDescriptiveName()
|
long |
getDirectoryId()
|
protected PasswordEncoder |
getEncoder()
|
java.util.Set<java.lang.String> |
getKeys()
|
java.lang.Iterable<Membership> |
getMemberships()
|
java.lang.String |
getValue(java.lang.String name)
|
java.util.Set<java.lang.String> |
getValues(java.lang.String name)
|
boolean |
isEmpty()
|
boolean |
isGroupDirectGroupMember(java.lang.String childGroup,
java.lang.String parentGroup)
|
boolean |
isRolesDisabled()
|
boolean |
isUserDirectGroupMember(java.lang.String username,
java.lang.String groupName)
|
void |
removeAllGroups(java.util.Set<java.lang.String> groupNames)
|
void |
removeAllUsers(java.util.Set<java.lang.String> userNames)
|
void |
removeGroup(java.lang.String name)
|
void |
removeGroupAttributes(java.lang.String groupName,
java.lang.String attributeName)
|
void |
removeGroupFromGroup(java.lang.String childGroup,
java.lang.String parentGroup)
|
void |
removeUser(java.lang.String name)
|
void |
removeUserAttributes(java.lang.String username,
java.lang.String attributeName)
|
void |
removeUserFromGroup(java.lang.String username,
java.lang.String groupName)
|
Group |
renameGroup(java.lang.String oldName,
java.lang.String newName)
|
User |
renameUser(java.lang.String oldName,
java.lang.String newName)
|
protected boolean |
requiresPasswordChange(UserWithAttributes user)
|
|
searchGroupRelationships(MembershipQuery<T> query)
|
|
searchGroups(EntityQuery<T> query)
|
|
searchUsers(EntityQuery<T> query)
|
void |
setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
Called by the DirectoryInstanceLoader after
constructing an InternalDirectory. |
void |
setDirectoryId(long id)
Called by the DirectoryInstanceLoader after
constructing an InternalDirectory. |
void |
storeGroupAttributes(java.lang.String groupName,
java.util.Map<java.lang.String,java.util.Set<java.lang.String>> attributes)
|
void |
storeUserAttributes(java.lang.String username,
java.util.Map<java.lang.String,java.util.Set<java.lang.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)
|
User |
updateUser(UserTemplate user)
|
void |
updateUserCredential(java.lang.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 java.lang.String DESCRIPTIVE_NAME
- See Also:
- Constant Field Values
ATTRIBUTE_PASSWORD_REGEX
public static final java.lang.String ATTRIBUTE_PASSWORD_REGEX
- See Also:
- Constant Field Values
ATTRIBUTE_PASSWORD_MAX_ATTEMPTS
public static final java.lang.String ATTRIBUTE_PASSWORD_MAX_ATTEMPTS
- See Also:
- Constant Field Values
ATTRIBUTE_PASSWORD_HISTORY_COUNT
public static final java.lang.String ATTRIBUTE_PASSWORD_HISTORY_COUNT
- See Also:
- Constant Field Values
ATTRIBUTE_USER_ENCRYPTION_METHOD
public static final java.lang.String ATTRIBUTE_USER_ENCRYPTION_METHOD
- See Also:
- Constant Field Values
ATTRIBUTE_PASSWORD_MAX_CHANGE_TIME
public static final java.lang.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(java.util.Map<java.lang.String,java.lang.String> attributes)
- Called by the
DirectoryInstanceLoader after
constructing an InternalDirectory.
- Specified by:
setAttributes in interface RemoteDirectory
- Parameters:
attributes - attributes map.
getValues
public java.util.Set<java.lang.String> getValues(java.lang.String name)
- Specified by:
getValues in interface Attributes
getValue
public java.lang.String getValue(java.lang.String name)
- Specified by:
getValue in interface Attributes
getKeys
public java.util.Set<java.lang.String> getKeys()
- Specified by:
getKeys in interface Attributes
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty in interface Attributes
getDescriptiveName
public java.lang.String getDescriptiveName()
- Specified by:
getDescriptiveName in interface RemoteDirectory
findUserByName
public TimestampedUser findUserByName(java.lang.String name)
throws UserNotFoundException
- Specified by:
findUserByName in interface InternalRemoteDirectory- Specified by:
findUserByName in interface RemoteDirectory
- Throws:
UserNotFoundException
findUserWithAttributesByName
public UserWithAttributes findUserWithAttributesByName(java.lang.String name)
throws UserNotFoundException
- Specified by:
findUserWithAttributesByName in interface RemoteDirectory
- Throws:
UserNotFoundException
authenticate
public User authenticate(java.lang.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
encryptCredential
protected void encryptCredential(PasswordCredential passwordCredential)
getEncoder
protected PasswordEncoder getEncoder()
updateUser
public User updateUser(UserTemplate user)
throws InvalidUserException,
UserNotFoundException
- Specified by:
updateUser in interface RemoteDirectory
- Throws:
InvalidUserException
UserNotFoundException
updateUserCredential
public void updateUserCredential(java.lang.String name,
PasswordCredential newCredential)
throws InvalidCredentialException,
UserNotFoundException
- Specified by:
updateUserCredential in interface RemoteDirectory
- Throws:
InvalidCredentialException
UserNotFoundException
renameUser
public User renameUser(java.lang.String oldName,
java.lang.String newName)
throws InvalidUserException,
UserNotFoundException,
UserAlreadyExistsException
- Specified by:
renameUser in interface RemoteDirectory
- Throws:
InvalidUserException
UserNotFoundException
UserAlreadyExistsException
storeUserAttributes
public void storeUserAttributes(java.lang.String username,
java.util.Map<java.lang.String,java.util.Set<java.lang.String>> attributes)
throws UserNotFoundException
- Specified by:
storeUserAttributes in interface RemoteDirectory
- Throws:
UserNotFoundException
removeUserAttributes
public void removeUserAttributes(java.lang.String username,
java.lang.String attributeName)
throws UserNotFoundException
- Specified by:
removeUserAttributes in interface RemoteDirectory
- Throws:
UserNotFoundException
removeUser
public void removeUser(java.lang.String name)
throws UserNotFoundException
- Specified by:
removeUser in interface RemoteDirectory
- Throws:
UserNotFoundException
removeAllUsers
public void removeAllUsers(java.util.Set<java.lang.String> userNames)
- Specified by:
removeAllUsers in interface InternalRemoteDirectory
removeAllGroups
public void removeAllGroups(java.util.Set<java.lang.String> groupNames)
- Specified by:
removeAllGroups in interface InternalRemoteDirectory
searchUsers
public <T> java.util.List<T> searchUsers(EntityQuery<T> query)
- Specified by:
searchUsers in interface RemoteDirectory
findGroupByName
public InternalDirectoryGroup findGroupByName(java.lang.String name)
throws GroupNotFoundException
- Specified by:
findGroupByName in interface InternalRemoteDirectory- Specified by:
findGroupByName in interface RemoteDirectory
- Throws:
GroupNotFoundException
findGroupWithAttributesByName
public GroupWithAttributes findGroupWithAttributesByName(java.lang.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(java.lang.String oldName,
java.lang.String newName)
throws InvalidGroupException,
GroupNotFoundException
- Specified by:
renameGroup in interface RemoteDirectory
- Throws:
InvalidGroupException
GroupNotFoundException
storeGroupAttributes
public void storeGroupAttributes(java.lang.String groupName,
java.util.Map<java.lang.String,java.util.Set<java.lang.String>> attributes)
throws GroupNotFoundException
- Specified by:
storeGroupAttributes in interface RemoteDirectory
- Throws:
GroupNotFoundException
removeGroupAttributes
public void removeGroupAttributes(java.lang.String groupName,
java.lang.String attributeName)
throws GroupNotFoundException
- Specified by:
removeGroupAttributes in interface RemoteDirectory
- Throws:
GroupNotFoundException
removeGroup
public void removeGroup(java.lang.String name)
throws GroupNotFoundException
- Specified by:
removeGroup in interface RemoteDirectory
- Throws:
GroupNotFoundException
searchGroups
public <T> java.util.List<T> searchGroups(EntityQuery<T> query)
- Specified by:
searchGroups in interface RemoteDirectory
isUserDirectGroupMember
public boolean isUserDirectGroupMember(java.lang.String username,
java.lang.String groupName)
- Specified by:
isUserDirectGroupMember in interface RemoteDirectory
isGroupDirectGroupMember
public boolean isGroupDirectGroupMember(java.lang.String childGroup,
java.lang.String parentGroup)
- Specified by:
isGroupDirectGroupMember in interface RemoteDirectory
addUserToGroup
public void addUserToGroup(java.lang.String username,
java.lang.String groupName)
throws UserNotFoundException,
GroupNotFoundException
- Specified by:
addUserToGroup in interface RemoteDirectory
- Throws:
UserNotFoundException
GroupNotFoundException
addGroupToGroup
public void addGroupToGroup(java.lang.String childGroup,
java.lang.String parentGroup)
throws InvalidMembershipException,
GroupNotFoundException
- Specified by:
addGroupToGroup in interface RemoteDirectory
- Throws:
InvalidMembershipException
GroupNotFoundException
removeUserFromGroup
public void removeUserFromGroup(java.lang.String username,
java.lang.String groupName)
throws MembershipNotFoundException,
GroupNotFoundException,
UserNotFoundException
- Specified by:
removeUserFromGroup in interface RemoteDirectory
- Throws:
MembershipNotFoundException
GroupNotFoundException
UserNotFoundException
removeGroupFromGroup
public void removeGroupFromGroup(java.lang.String childGroup,
java.lang.String parentGroup)
throws InvalidMembershipException,
MembershipNotFoundException,
GroupNotFoundException
- Specified by:
removeGroupFromGroup in interface RemoteDirectory
- Throws:
InvalidMembershipException
MembershipNotFoundException
GroupNotFoundException
searchGroupRelationships
public <T> java.util.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 java.lang.Iterable<Membership> getMemberships()
throws OperationFailedException
- Specified by:
getMemberships in interface RemoteDirectory
- Throws:
OperationFailedException
getAuthoritativeDirectory
public RemoteDirectory getAuthoritativeDirectory()
- Specified by:
getAuthoritativeDirectory in interface RemoteDirectory
Copyright © 2012 Atlassian. All Rights Reserved.