|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.crowd.integration.directory.internal.InternalDirectory
public class InternalDirectory
Internal directory connector. Stores all entity information to the database used by the Crowd Server.
| Field Summary | |
|---|---|
static java.lang.String |
ATTRIBUTE_PASSWORD_HISTORY_COUNT
|
static java.lang.String |
ATTRIBUTE_PASSWORD_MAX_ATTEMPTS
|
static java.lang.String |
ATTRIBUTE_PASSWORD_MAX_CHANGE_TIME
|
static java.lang.String |
ATTRIBUTE_PASSWORD_REGEX
|
static java.lang.String |
ATTRIBUTE_USER_ENCRYPTION_METHOD
|
protected AttributeValuesHolder |
attributes
|
static java.lang.String |
DESCRIPTIVE_NAME
|
protected DirectoryDAO |
directoryDAO
|
protected GroupDAO |
groupDAO
|
protected I18nHelper |
i18nHelper
|
protected org.apache.log4j.Logger |
logger
|
protected MembershipDAO |
membershipDAO
|
protected PasswordEncoderFactory |
passwordEncoderFactory
|
protected PasswordHelper |
passwordHelper
|
protected UserDAO |
userDAO
|
| Constructor Summary | |
|---|---|
InternalDirectory()
|
|
| Method Summary | |
|---|---|
java.util.Collection<Group> |
addAllGroups(java.util.Set<GroupTemplate> groups)
Adds a collection of groups to the directory store. |
java.util.Collection<User> |
addAllUsers(java.util.Set<UserTemplateWithCredentialAndAttributes> users)
Adds a collection of users to the directory store. |
java.util.Collection<java.lang.String> |
addAllUsersToGroup(java.util.Set<java.lang.String> userNames,
java.lang.String groupName)
Adds a collection of group memberships to the directory store. |
Group |
addGroup(GroupTemplate group)
Adds a group. |
void |
addGroupToGroup(java.lang.String childGroup,
java.lang.String parentGroup)
Adds a group as a member of a parent group. |
User |
addUser(UserTemplate user,
PasswordCredential credential)
Adds a user and the following custom attributes: - RemotePrincipalConstants.PASSWORD_LASTCHANGED set to the current time. |
void |
addUserToGroup(java.lang.String username,
java.lang.String groupName)
Adds a user as a member of a group. |
User |
authenticate(java.lang.String name,
PasswordCredential credential)
Authenticates a user with the directory store. |
protected long |
currentPrincipalInvalidPasswordAttempts(InternalUserWithAttributes user)
|
Group |
findGroupByName(java.lang.String name)
Finds the group that matches the supplied name. |
java.util.Collection<Group> |
findGroupsByNames(java.util.Collection<java.lang.String> names)
Finds a collection of groups matching a collection of names. |
GroupWithAttributes |
findGroupWithAttributesByName(java.lang.String name)
Finds the group that matches the supplied name. |
User |
findUserByName(java.lang.String name)
Finds the user that matches the supplied name. |
java.util.Collection<User> |
findUsersByNames(java.util.Collection<java.lang.String> names)
Finds a collection of users matching a collection of names. |
UserWithAttributes |
findUserWithAttributesByName(java.lang.String name)
Finds the user that matches the supplied name. |
java.lang.String |
getAttribute(java.lang.String name)
|
java.util.Set<java.lang.String> |
getAttributeNames()
|
java.util.List<java.lang.String> |
getAttributes(java.lang.String name)
|
java.lang.String |
getDescriptiveName()
Returns a descriptive name for the type of directory. |
long |
getDirectoryId()
Gets the internal unique directoryId of the directory store. |
protected PasswordEncoder |
getEncoder()
|
boolean |
hasAttribute(java.lang.String name)
|
boolean |
isGroupDirectGroupMember(java.lang.String childGroup,
java.lang.String parentGroup)
Determines if a group is a direct member of another group. |
boolean |
isUserDirectGroupMember(java.lang.String username,
java.lang.String groupName)
Determines if a user is a direct member of a group. |
void |
removeGroup(java.lang.String name)
Removes the group that matches the supplied name. |
void |
removeGroupAttributes(java.lang.String groupName,
java.lang.String attributeName)
Removes all the values for a single attribute key for a group. |
void |
removeGroupFromGroup(java.lang.String childGroup,
java.lang.String parentGroup)
Removes a group as a member of a parent group. |
void |
removeUser(java.lang.String name)
Removes the user that matches the supplied name. |
void |
removeUserAttributes(java.lang.String username,
java.lang.String attributeName)
Removes all the values for a single attribute key for a user. |
void |
removeUserFromGroup(java.lang.String username,
java.lang.String groupName)
Removes a user as a member of a group. |
Group |
renameGroup(java.lang.String oldName,
java.lang.String newName)
Renames a group. |
User |
renameUser(java.lang.String oldName,
java.lang.String newName)
Renames a user. |
protected boolean |
requiresPasswordChange(InternalUserWithAttributes user)
|
java.util.List |
searchGroupRelationships(MembershipQuery query)
Searches for membership information. |
java.util.List |
searchGroups(EntityQuery query)
Searches for groups that match the supplied query criteria. |
java.util.List |
searchUsers(EntityQuery query)
Searches for users that match the supplied query criteria. |
void |
setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
Called by the DirectoryInstanceLoader after
constructing an InternalDirectory. |
void |
setDirectoryDAO(DirectoryDAO directoryDAO)
|
void |
setDirectoryId(long id)
Called by the DirectoryInstanceLoader after
constructing an InternalDirectory. |
void |
setGroupDAO(GroupDAO groupDAO)
|
void |
setI18nHelper(I18nHelper i18nHelper)
|
void |
setMembershipDAO(MembershipDAO membershipDAO)
|
void |
setPasswordEncoderFactory(PasswordEncoderFactory passwordEncoderFactory)
|
void |
setPasswordHelper(PasswordHelper passwordHelper)
|
void |
setUserDAO(UserDAO userDAO)
|
void |
storeGroupAttributes(java.lang.String groupName,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> attributes)
Adds or updates a group's attributes with the new Map of attribute values in the directory specified by the passed in directoryId. |
void |
storeUserAttributes(java.lang.String username,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> attributes)
Adds or updates a user's attributes with the new Map of attribute values in the directory specified by the passed in directoryId. |
boolean |
supportsNestedGroups()
Allows us to only display nested-group related UI for directories that support it. |
void |
testConnection()
Does nothing, connection is determined by the ability to communicate with the database. |
Group |
updateGroup(GroupTemplate group)
Updates the group. |
User |
updateUser(UserTemplate user)
Updates the user. |
void |
updateUserCredential(java.lang.String name,
PasswordCredential credential)
Updates the password for a user. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String DESCRIPTIVE_NAME
public static final java.lang.String ATTRIBUTE_PASSWORD_REGEX
public static final java.lang.String ATTRIBUTE_PASSWORD_MAX_ATTEMPTS
public static final java.lang.String ATTRIBUTE_PASSWORD_HISTORY_COUNT
public static final java.lang.String ATTRIBUTE_USER_ENCRYPTION_METHOD
public static final java.lang.String ATTRIBUTE_PASSWORD_MAX_CHANGE_TIME
protected final org.apache.log4j.Logger logger
protected AttributeValuesHolder attributes
protected PasswordHelper passwordHelper
protected PasswordEncoderFactory passwordEncoderFactory
protected DirectoryDAO directoryDAO
protected UserDAO userDAO
protected GroupDAO groupDAO
protected MembershipDAO membershipDAO
protected I18nHelper i18nHelper
| Constructor Detail |
|---|
public InternalDirectory()
| Method Detail |
|---|
public long getDirectoryId()
RemoteDirectorydirectoryId of the directory store.
getDirectoryId in interface RemoteDirectorydirectoryId.public void setDirectoryId(long id)
DirectoryInstanceLoader after
constructing an InternalDirectory.
setDirectoryId in interface RemoteDirectoryid - The unique id of the Directory stored in the database.public void setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
DirectoryInstanceLoader after
constructing an InternalDirectory.
setAttributes in interface RemoteDirectoryattributes - attributes map.public java.util.List<java.lang.String> getAttributes(java.lang.String name)
getAttributes in interface AttributeAwarename - attribute name.
public java.lang.String getAttribute(java.lang.String name)
getAttribute in interface AttributeAwarename - attribute name.
null
if the attribute with the given name does not exist.
If multiple attribute values exist, any one could be
returned.public java.util.Set<java.lang.String> getAttributeNames()
getAttributeNames in interface AttributeAwarepublic boolean hasAttribute(java.lang.String name)
hasAttribute in interface AttributeAwarename - attribute name.
true if an only if the
user has an attribute with the supplied name
and has one or more values.public java.lang.String getDescriptiveName()
RemoteDirectory
getDescriptiveName in interface RemoteDirectory
public User findUserByName(java.lang.String name)
throws ObjectNotFoundException
RemoteDirectoryuser that matches the supplied name.
findUserByName in interface RemoteDirectoryname - the name of the user (username).
ObjectNotFoundException - a user with the supplied name does not exist.
public UserWithAttributes findUserWithAttributesByName(java.lang.String name)
throws ObjectNotFoundException
RemoteDirectoryuser that matches the supplied name.
findUserWithAttributesByName in interface RemoteDirectoryname - the name of the user (username).
ObjectNotFoundException - a user with the supplied name does not exist.
public User authenticate(java.lang.String name,
PasswordCredential credential)
throws ObjectNotFoundException,
InactiveAccountException,
InvalidAuthenticationException
RemoteDirectoryuser with the directory store.
authenticate in interface RemoteDirectoryname - The name of the user (username).credential - The supplied credentials (password).
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.
ObjectNotFoundException - The user wth the supplied name does not exist.protected long currentPrincipalInvalidPasswordAttempts(InternalUserWithAttributes user)
user - user with attributes.
protected boolean requiresPasswordChange(InternalUserWithAttributes user)
user - user with attributes.
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).
public User addUser(UserTemplate user,
PasswordCredential credential)
throws ObjectNotFoundException,
InvalidCredentialException,
InvalidUserException
addUser in interface RemoteDirectoryuser - template of the user to add.credential - password. May be null, since JIRA creates a user in two steps
ObjectNotFoundException - the user could not be looked up after creation or the directory with the ID of user.directoryId does not exist.
InvalidCredentialException - the password does not match the regular expression standard defined by the directory.
InvalidUserException - The supplied user is invalid.protected PasswordEncoder getEncoder()
public User updateUser(UserTemplate user)
throws InvalidUserException,
ObjectNotFoundException
RemoteDirectoryuser.
updateUser in interface RemoteDirectoryuser - The user to update.
InvalidUserException - the supplied user is invalid.
ObjectNotFoundException - the user does not exist in the directory store.
public void updateUserCredential(java.lang.String name,
PasswordCredential credential)
throws ObjectNotFoundException,
InvalidCredentialException
RemoteDirectorypassword for a user.
updateUserCredential in interface RemoteDirectoryname - The name of the user (username).credential - The new credential (password).
ObjectNotFoundException - The user does not exist.
InvalidCredentialException - The supplied credential is invalid.
public User renameUser(java.lang.String oldName,
java.lang.String newName)
throws ObjectNotFoundException,
InvalidUserException
RemoteDirectoryuser.
renameUser in interface RemoteDirectoryoldName - name of existing user.newName - desired name of user.
ObjectNotFoundException - if the user with the existing name does not exist.
InvalidUserException - if the new username is invalid or already exists in the directory.
public void storeUserAttributes(java.lang.String username,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> attributes)
throws ObjectNotFoundException
RemoteDirectorydirectoryId.
The attributes map represents new or updated attributes and does not replace existing attributes unless the key of an attribute
matches the key of an existing
storeUserAttributes in interface RemoteDirectoryusername - name of user to update.attributes - new or updated attributes (attributes that don't need changing should not appear in this Map).
ObjectNotFoundException - user with supplied username does not exist.
public void removeUserAttributes(java.lang.String username,
java.lang.String attributeName)
throws ObjectNotFoundException
RemoteDirectory
removeUserAttributes in interface RemoteDirectoryusername - name of the user to update.attributeName - name of attribute to remove.
ObjectNotFoundException - user with supplied username does not exist.
public void removeUser(java.lang.String name)
throws ObjectNotFoundException
RemoteDirectoryuser that matches the supplied name.
removeUser in interface RemoteDirectoryname - The name of the user (username).
ObjectNotFoundException - The user does not exist.public java.util.List searchUsers(EntityQuery query)
RemoteDirectoryusers that match the supplied query criteria.
searchUsers in interface RemoteDirectoryquery - EntityQuery for Entity.USER.
List<User> or List<String> of users/usernames
matching the search criteria. An empty List will be returned
if no users matching the criteria are found.
public Group findGroupByName(java.lang.String name)
throws ObjectNotFoundException
RemoteDirectorygroup that matches the supplied name.
findGroupByName in interface RemoteDirectoryname - the name of the group.
ObjectNotFoundException - a group with the supplied name does not exist.
public GroupWithAttributes findGroupWithAttributesByName(java.lang.String name)
throws ObjectNotFoundException
RemoteDirectorygroup that matches the supplied name.
findGroupWithAttributesByName in interface RemoteDirectoryname - the name of the group.
ObjectNotFoundException - a group with the supplied name does not exist.
public Group addGroup(GroupTemplate group)
throws InvalidGroupException,
ObjectNotFoundException
addGroup in interface RemoteDirectorygroup - template of the group to add.
ObjectNotFoundException - the group could not be looked up after creation or the directory with the ID of group.directoryId does not exist.
InvalidGroupException - the group name or type was not specified.
public Group updateGroup(GroupTemplate group)
throws InvalidGroupException,
ObjectNotFoundException
RemoteDirectorygroup.
updateGroup in interface RemoteDirectorygroup - The group to update.
InvalidGroupException - the supplied group is invalid.
ObjectNotFoundException - the group does not exist in the directory store.
public Group renameGroup(java.lang.String oldName,
java.lang.String newName)
throws ObjectNotFoundException,
InvalidGroupException
RemoteDirectorygroup.
renameGroup in interface RemoteDirectoryoldName - name of existing group.newName - desired name of group.
ObjectNotFoundException - if the group with the existing name does not exist.
InvalidGroupException - if the new groupname is invalid or already exists in the directory.
public void storeGroupAttributes(java.lang.String groupName,
java.util.Map<java.lang.String,java.util.List<java.lang.String>> attributes)
throws ObjectNotFoundException
RemoteDirectorydirectoryId.
The attributes map represents new or updated attributes and does not replace existing attributes unless the key of an attribute
matches the key of an existing
storeGroupAttributes in interface RemoteDirectorygroupName - name of group to update.attributes - new or updated attributes (attributes that don't need changing should not appear in this Map).
ObjectNotFoundException - group with supplied groupName does not exist.
public void removeGroupAttributes(java.lang.String groupName,
java.lang.String attributeName)
throws ObjectNotFoundException
RemoteDirectory
removeGroupAttributes in interface RemoteDirectorygroupName - name of the group to update.attributeName - name of attribute to remove.
ObjectNotFoundException - group with supplied groupName does not exist.
public void removeGroup(java.lang.String name)
throws ObjectNotFoundException
RemoteDirectorygroup that matches the supplied name.
removeGroup in interface RemoteDirectoryname - The name of the group.
ObjectNotFoundException - The group does not exist.public java.util.List searchGroups(EntityQuery query)
RemoteDirectorygroups that match the supplied query criteria.
searchGroups in interface RemoteDirectoryquery - EntityQuery for Entity.GROUP.
List or List of groups/groupnames
matching the search criteria. An empty List will be returned
if no groups matching the criteria are found.
public boolean isUserDirectGroupMember(java.lang.String username,
java.lang.String groupName)
RemoteDirectory
isUserDirectGroupMember in interface RemoteDirectoryusername - name of user.groupName - name of group.
true iff the user is a direct member of the group.
public boolean isGroupDirectGroupMember(java.lang.String childGroup,
java.lang.String parentGroup)
RemoteDirectory
isGroupDirectGroupMember in interface RemoteDirectorychildGroup - name of child group.parentGroup - name of parent group.
true iff the childGroup is a direct member of the parentGroup.
public void addUserToGroup(java.lang.String username,
java.lang.String groupName)
throws ObjectNotFoundException
RemoteDirectorychildGroup will
appear as members of parentGroup to querying applications.
addUserToGroup in interface RemoteDirectoryusername - The user that will become a member of groupNamegroupName - The group that will gain a new member.
ObjectNotFoundException - If the user or group cannot be found.
public void addGroupToGroup(java.lang.String childGroup,
java.lang.String parentGroup)
throws ObjectNotFoundException,
InvalidMembershipException
RemoteDirectory
addGroupToGroup in interface RemoteDirectorychildGroup - The group that will become a member of parentGroupparentGroup - The group that will gain a new member
ObjectNotFoundException - One or both of the groups cannot be found.
InvalidMembershipException - if the childGroup and parentGroup exist but are of different GroupTypes.
public void removeUserFromGroup(java.lang.String username,
java.lang.String groupName)
throws ObjectNotFoundException,
MembershipNotFoundException
RemoteDirectory
removeUserFromGroup in interface RemoteDirectoryusername - The user that will be removed from parentGroupgroupName - The group that will lose the member.
ObjectNotFoundException - If either the user or group cannot be found.
MembershipNotFoundException - if the user is not a direct member of the group.
public void removeGroupFromGroup(java.lang.String childGroup,
java.lang.String parentGroup)
throws ObjectNotFoundException,
InvalidMembershipException,
MembershipNotFoundException
RemoteDirectory
removeGroupFromGroup in interface RemoteDirectorychildGroup - The group that will be removed from parentGroupparentGroup - The group that will lose the member.
ObjectNotFoundException - One or both of the groups cannot be found.
InvalidMembershipException - if the childGroup and parentGroup exist but are of different GroupTypes.
MembershipNotFoundException - if the childGroup is not a direct member of the parentGroup.public java.util.List searchGroupRelationships(MembershipQuery query)
RemoteDirectory
searchGroupRelationships in interface RemoteDirectoryquery - query for memberships.
public java.util.Collection<User> addAllUsers(java.util.Set<UserTemplateWithCredentialAndAttributes> users)
throws ObjectNotFoundException
BatchingRemoteDirectory
addAllUsers in interface BatchingRemoteDirectoryusers - set of users to add.
ObjectNotFoundException - directory has been deleted and cannot be found.
public java.util.Collection<Group> addAllGroups(java.util.Set<GroupTemplate> groups)
throws ObjectNotFoundException
BatchingRemoteDirectory
addAllGroups in interface BatchingRemoteDirectorygroups - set of groups to add.
ObjectNotFoundException
public java.util.Collection<java.lang.String> addAllUsersToGroup(java.util.Set<java.lang.String> userNames,
java.lang.String groupName)
throws ObjectNotFoundException
BatchingRemoteDirectory
addAllUsersToGroup in interface BatchingRemoteDirectoryuserNames - names of users to add.groupName - name of group to add users to.
ObjectNotFoundException - if the group does not exist.public java.util.Collection<User> findUsersByNames(java.util.Collection<java.lang.String> names)
BatchingRemoteDirectory
findUsersByNames in interface BatchingRemoteDirectorynames - names of users to find.
public java.util.Collection<Group> findGroupsByNames(java.util.Collection<java.lang.String> names)
BatchingRemoteDirectory
findGroupsByNames in interface BatchingRemoteDirectorynames - names of groups to find.
public void testConnection()
throws DirectoryAccessException
testConnection in interface RemoteDirectoryjava.rmi.RemoteException - never.
DirectoryAccessException - An unknown wire exception occurred.public boolean supportsNestedGroups()
RemoteDirectory
supportsNestedGroups in interface RemoteDirectorytrue because Internal Directories support nested groups as of Crowd 2.0.public void setPasswordHelper(PasswordHelper passwordHelper)
public void setPasswordEncoderFactory(PasswordEncoderFactory passwordEncoderFactory)
public void setDirectoryDAO(DirectoryDAO directoryDAO)
public void setUserDAO(UserDAO userDAO)
public void setGroupDAO(GroupDAO groupDAO)
public void setMembershipDAO(MembershipDAO membershipDAO)
public void setI18nHelper(I18nHelper i18nHelper)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||