Package africa.absa.inception.security
Class UserDirectoryBase
java.lang.Object
africa.absa.inception.security.UserDirectoryBase
- Direct Known Subclasses:
InternalUserDirectory,LDAPUserDirectory
The UserDirectoryBase class provides the base class from which all user directory classes
should be derived.
- Author:
- Marcus Portmann
-
Constructor Summary
ConstructorsConstructorDescriptionUserDirectoryBase(UUID userDirectoryId, List<UserDirectoryParameter> parameters, GroupRepository groupRepository, UserRepository userRepository, RoleRepository roleRepository) Constructs a new UserDirectoryBase. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMemberToGroup(String groupName, GroupMemberType memberType, String memberName) Add the group member to the group.voidaddRoleToGroup(String groupName, String roleCode) Add the role to the group.voidaddUserToGroup(String groupName, String username) Add the user to the group.voidadminChangePassword(String username, String newPassword, boolean expirePassword, boolean lockUser, boolean resetPasswordHistory, PasswordChangeReason reason) Administratively change the password for the user.voidauthenticate(String username, String password) Authenticate the user.voidchangePassword(String username, String password, String newPassword) Change the password for the user.voidcreateGroup(Group group) Create the new group.voidcreateUser(User user, boolean expiredPassword, boolean userLocked) Create the new user.voiddeleteGroup(String groupName) Delete the group.voiddeleteUser(String username) Delete the user.findUsers(List<UserAttribute> userAttributes) Retrieve the users matching the user attribute criteria.Retrieve the capabilities the user directory supports.getFunctionCodesForUser(String username) Retrieve the function codes for the user.Retrieve the group.Retrieve all the group names.getGroupNamesForUser(String username) Retrieve the names of the groups the user is a member of.Returns the Group Repository.Retrieve all the groups.getGroups(String filter, africa.absa.inception.core.sorting.SortDirection sortDirection, Integer pageIndex, Integer pageSize) Retrieve the groups.getGroupsForUser(String username) Retrieve the groups the user is a member of.getMembersForGroup(String groupName) Retrieve the group members for the group.getMembersForGroup(String groupName, String filter, africa.absa.inception.core.sorting.SortDirection sortDirection, Integer pageIndex, Integer pageSize) Retrieve the group members for the group.Returns the parameters for the user directory.getRoleCodesForGroup(String groupName) Retrieve the codes for the roles that have been assigned to the group.getRoleCodesForUser(String username) Retrieve the codes for the roles that the user has been assigned.Returns the Role Repository.getRolesForGroup(String groupName) Retrieve the roles that have been assigned to the group.Retrieve the user.Returns the ID for the user directory.getUserName(String username) Retrieve the name of the user.Returns the User Repository.getUsers()Retrieve all the users.getUsers(String filter, UserSortBy sortBy, africa.absa.inception.core.sorting.SortDirection sortDirection, Integer pageIndex, Integer pageSize) Retrieve the users.booleanisExistingUser(String username) Does the user with the specified username exist?protected booleanisNullOrEmpty(Object value) Checks whether the specified value is null or blank.booleanisUserInGroup(String groupName, String username) Is the user in the group?voidremoveMemberFromGroup(String groupName, GroupMemberType memberType, String memberName) Remove the group member from the group.voidremoveRoleFromGroup(String groupName, String roleCode) Remove the role from the group.voidremoveUserFromGroup(String groupName, String username) Remove the user from the group.voidresetPassword(String username, String newPassword) Reset the password for the user.voidupdateGroup(Group group) Update the group.voidupdateUser(User user, boolean expirePassword, boolean lockUser) Update the user.
-
Constructor Details
-
UserDirectoryBase
public UserDirectoryBase(UUID userDirectoryId, List<UserDirectoryParameter> parameters, GroupRepository groupRepository, UserRepository userRepository, RoleRepository roleRepository) Constructs a new UserDirectoryBase.- Parameters:
userDirectoryId- the ID for the user directoryparameters- the parameters for the user directorygroupRepository- the Group RepositoryuserRepository- the User RepositoryroleRepository- the Role Repository
-
-
Method Details
-
getGroupRepository
Returns the Group Repository.- Returns:
- the Group Repository
-
getParameters
Returns the parameters for the user directory.- Returns:
- the parameters for the user directory
-
getRoleRepository
Returns the Role Repository.- Returns:
- the Role Repository
-
getUserDirectoryId
Returns the ID for the user directory.- Returns:
- the ID for the user directory
-
getUserRepository
Returns the User Repository.- Returns:
- the User Repository
-
isNullOrEmpty
Checks whether the specified value is null or blank.- Parameters:
value- the value to check- Returns:
- true if the value is null or blank
-
addMemberToGroup
void addMemberToGroup(String groupName, GroupMemberType memberType, String memberName) throws GroupNotFoundException, UserNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Add the group member to the group.- Parameters:
groupName- the name of the groupmemberType- the group member typememberName- the group member name- Throws:
GroupNotFoundException- if the group could not be foundUserNotFoundException- if the user could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the group member could not be added to the group
-
addRoleToGroup
void addRoleToGroup(String groupName, String roleCode) throws GroupNotFoundException, RoleNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Add the role to the group.- Parameters:
groupName- the name of the grouproleCode- the code for the role- Throws:
GroupNotFoundException- if the group could not be foundRoleNotFoundException- if the role could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the role could not be added to the group
-
addUserToGroup
void addUserToGroup(String groupName, String username) throws GroupNotFoundException, UserNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Add the user to the group.- Parameters:
groupName- the name of the groupusername- the username for the user- Throws:
GroupNotFoundException- if the group could not be foundUserNotFoundException- if the user could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the user could not be added to the group
-
adminChangePassword
void adminChangePassword(String username, String newPassword, boolean expirePassword, boolean lockUser, boolean resetPasswordHistory, PasswordChangeReason reason) throws UserNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Administratively change the password for the user.- Parameters:
username- the username for the usernewPassword- the new passwordexpirePassword- expire the user's passwordlockUser- lock the userresetPasswordHistory- reset the user's password historyreason- the reason for changing the password- Throws:
UserNotFoundException- if the user could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the password could not be administratively changed
-
authenticate
void authenticate(String username, String password) throws AuthenticationFailedException, UserLockedException, ExpiredPasswordException, UserNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Authenticate the user.- Parameters:
username- the username for the userpassword- the password being used to authenticate- Throws:
AuthenticationFailedException- if the authentication failedUserLockedException- if the user is lockedExpiredPasswordException- if the password for the user has expiredUserNotFoundException- if the user could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the user could not be authenticated
-
changePassword
void changePassword(String username, String password, String newPassword) throws AuthenticationFailedException, UserLockedException, ExistingPasswordException, africa.absa.inception.core.service.ServiceUnavailableException Change the password for the user.- Parameters:
username- the username for the userpassword- the password for the user that is used to authorise the operationnewPassword- the new password- Throws:
AuthenticationFailedException- if the authentication failedUserLockedException- if the user is lockedExistingPasswordException- if the user has previously used the new passwordafrica.absa.inception.core.service.ServiceUnavailableException- if the password could not be changed
-
createGroup
void createGroup(Group group) throws DuplicateGroupException, africa.absa.inception.core.service.ServiceUnavailableException Create the new group.- Parameters:
group- the group- Throws:
DuplicateGroupException- if the group already existsafrica.absa.inception.core.service.ServiceUnavailableException- if the group could not be created
-
createUser
void createUser(User user, boolean expiredPassword, boolean userLocked) throws DuplicateUserException, africa.absa.inception.core.service.ServiceUnavailableException Create the new user.- Parameters:
user- the userexpiredPassword- create the user with its password expireduserLocked- create the user locked- Throws:
DuplicateUserException- if the user already existsafrica.absa.inception.core.service.ServiceUnavailableException- if the user could not be created
-
deleteGroup
void deleteGroup(String groupName) throws GroupNotFoundException, ExistingGroupMembersException, africa.absa.inception.core.service.ServiceUnavailableException Delete the group.- Parameters:
groupName- the name of the group- Throws:
GroupNotFoundException- if the group could not be foundExistingGroupMembersException- if the group has existing membersafrica.absa.inception.core.service.ServiceUnavailableException- if the group could not be deleted
-
deleteUser
void deleteUser(String username) throws UserNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Delete the user.- Parameters:
username- the username for the user- Throws:
UserNotFoundException- if the user could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the user could not be deleted
-
findUsers
List<User> findUsers(List<UserAttribute> userAttributes) throws InvalidAttributeException, africa.absa.inception.core.service.ServiceUnavailableException Retrieve the users matching the user attribute criteria.- Parameters:
userAttributes- the user attribute criteria used to select the users- Returns:
- the users whose attributes match the user attribute criteria
- Throws:
InvalidAttributeException- if an attribute is invalidafrica.absa.inception.core.service.ServiceUnavailableException- if the users matching the user attribute criteria could not be found
-
getCapabilities
UserDirectoryCapabilities getCapabilities() throws africa.absa.inception.core.service.ServiceUnavailableExceptionRetrieve the capabilities the user directory supports.- Returns:
- the capabilities the user directory supports
- Throws:
africa.absa.inception.core.service.ServiceUnavailableException- if the user directory capabilities could not be retrieved
-
getFunctionCodesForUser
List<String> getFunctionCodesForUser(String username) throws UserNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Retrieve the function codes for the user.- Parameters:
username- the username for the user- Returns:
- the function codes for the user
- Throws:
UserNotFoundException- if the user could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the function codes could not be retrieved for the user
-
getGroup
Group getGroup(String groupName) throws GroupNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Retrieve the group.- Parameters:
groupName- the name of the group- Returns:
- the group
- Throws:
GroupNotFoundException- if the group could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the group could not be retrieved
-
getGroupNames
Retrieve all the group names.- Returns:
- the group names
- Throws:
africa.absa.inception.core.service.ServiceUnavailableException- if the group names could not be retrieved
-
getGroupNamesForUser
List<String> getGroupNamesForUser(String username) throws UserNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Retrieve the names of the groups the user is a member of.- Parameters:
username- the username for the user- Returns:
- the names of the groups the user is a member of
- Throws:
UserNotFoundException- if the user could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the names of the groups the user is a member of could not be retrieved
-
getGroups
Retrieve all the groups.- Returns:
- the groups
- Throws:
africa.absa.inception.core.service.ServiceUnavailableException- if the groups could not be retrieved
-
getGroups
Groups getGroups(String filter, africa.absa.inception.core.sorting.SortDirection sortDirection, Integer pageIndex, Integer pageSize) throws africa.absa.inception.core.service.ServiceUnavailableException Retrieve the groups.- Parameters:
filter- the optional filter to apply to the groupssortDirection- the optional sort direction to apply to the groupspageIndex- the optional page indexpageSize- the optional page size- Returns:
- the groups
- Throws:
africa.absa.inception.core.service.ServiceUnavailableException- if the groups could not be retrieved
-
getGroupsForUser
List<Group> getGroupsForUser(String username) throws UserNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Retrieve the groups the user is a member of.- Parameters:
username- the username for the user- Returns:
- the groups the user is a member of
- Throws:
UserNotFoundException- if the user could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the groups the user is a member of could not be retrieved
-
getMembersForGroup
List<GroupMember> getMembersForGroup(String groupName) throws GroupNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Retrieve the group members for the group.- Parameters:
groupName- the name of the group- Returns:
- the group members for the group
- Throws:
GroupNotFoundException- if the group could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the group members could not be retrieved for the group
-
getMembersForGroup
GroupMembers getMembersForGroup(String groupName, String filter, africa.absa.inception.core.sorting.SortDirection sortDirection, Integer pageIndex, Integer pageSize) throws GroupNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Retrieve the group members for the group.- Parameters:
groupName- the name of the groupfilter- the optional filter to apply to the group memberssortDirection- the optional sort direction to apply to the group memberspageIndex- the optional page indexpageSize- the optional page size- Returns:
- the group members for the group
- Throws:
GroupNotFoundException- if the group could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the group members could not be retrieved for the group
-
getRoleCodesForGroup
List<String> getRoleCodesForGroup(String groupName) throws GroupNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Retrieve the codes for the roles that have been assigned to the group.- Parameters:
groupName- the name of the group- Returns:
- the codes for the roles that have been assigned to the group
- Throws:
GroupNotFoundException- if the group could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the codes for the roles assigned to the group could not be retrieved
-
getRoleCodesForUser
List<String> getRoleCodesForUser(String username) throws UserNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Retrieve the codes for the roles that the user has been assigned.- Parameters:
username- the username for the user- Returns:
- the codes for the roles that the user has been assigned
- Throws:
UserNotFoundException- if the user could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the codes for the roles assigned to the user could not be retrieved
-
getRolesForGroup
List<GroupRole> getRolesForGroup(String groupName) throws GroupNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Retrieve the roles that have been assigned to the group.- Parameters:
groupName- the name of the group- Returns:
- the roles that have been assigned to the group
- Throws:
GroupNotFoundException- if the group could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the codes for the roles assigned to the group could not be retrieved
-
getUser
User getUser(String username) throws UserNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Retrieve the user.- Parameters:
username- the username for the user- Returns:
- the user
- Throws:
UserNotFoundException- if the user could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the user could not be retrieved
-
getUserName
String getUserName(String username) throws UserNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Retrieve the name of the user.- Parameters:
username- the username for the user- Returns:
- the name of the user
- Throws:
UserNotFoundException- if the user could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the name of the user could not be retrieved
-
getUsers
Retrieve all the users.- Returns:
- the users
- Throws:
africa.absa.inception.core.service.ServiceUnavailableException- if the users could not be retrieved
-
getUsers
Users getUsers(String filter, UserSortBy sortBy, africa.absa.inception.core.sorting.SortDirection sortDirection, Integer pageIndex, Integer pageSize) throws africa.absa.inception.core.service.ServiceUnavailableException Retrieve the users.- Parameters:
filter- the optional filter to apply to the userssortBy- the optional method used to sort the users e.g. by namesortDirection- the optional sort direction to apply to the userspageIndex- the optional page indexpageSize- the optional page size- Returns:
- the users
- Throws:
africa.absa.inception.core.service.ServiceUnavailableException- if the users could not be retrieved
-
isExistingUser
boolean isExistingUser(String username) throws africa.absa.inception.core.service.ServiceUnavailableException Does the user with the specified username exist?- Parameters:
username- the username for the user- Returns:
- true if a user with specified username exists or false otherwise
- Throws:
africa.absa.inception.core.service.ServiceUnavailableException- if the check for the existing user failed
-
isUserInGroup
boolean isUserInGroup(String groupName, String username) throws UserNotFoundException, GroupNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Is the user in the group?- Parameters:
groupName- the name of the groupusername- the username for the user- Returns:
- true if the user is a member of the group or false otherwise
- Throws:
UserNotFoundException- if the user could not be foundGroupNotFoundException- if the group could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the check to confirm if the user is a member of the group failed
-
removeMemberFromGroup
void removeMemberFromGroup(String groupName, GroupMemberType memberType, String memberName) throws GroupNotFoundException, GroupMemberNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Remove the group member from the group.- Parameters:
groupName- the name of the groupmemberType- the group member typememberName- the group member name- Throws:
GroupNotFoundException- if the group could not be foundGroupMemberNotFoundException- if the group member could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the group member could not be removed from the group
-
removeRoleFromGroup
void removeRoleFromGroup(String groupName, String roleCode) throws GroupNotFoundException, GroupRoleNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Remove the role from the group.- Parameters:
groupName- the name of the grouproleCode- the code for the role- Throws:
GroupNotFoundException- if the group could not be foundGroupRoleNotFoundException- if the group role could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the role could not be removed from the group
-
removeUserFromGroup
void removeUserFromGroup(String groupName, String username) throws GroupNotFoundException, UserNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Remove the user from the group.- Parameters:
groupName- the name of the groupusername- the username for the user- Throws:
GroupNotFoundException- if the group could not be foundUserNotFoundException- if the user could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the user could not be removed from the group
-
resetPassword
void resetPassword(String username, String newPassword) throws UserNotFoundException, UserLockedException, ExistingPasswordException, africa.absa.inception.core.service.ServiceUnavailableException Reset the password for the user.- Parameters:
username- the username for the usernewPassword- the new password- Throws:
UserNotFoundException- if the user could not be foundUserLockedException- if the user is lockedExistingPasswordException- if the user has previously used the new passwordafrica.absa.inception.core.service.ServiceUnavailableException- if the password for the user could not be reset
-
updateGroup
void updateGroup(Group group) throws GroupNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Update the group.- Parameters:
group- the group- Throws:
GroupNotFoundException- if the group could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the group could not be updated
-
updateUser
void updateUser(User user, boolean expirePassword, boolean lockUser) throws UserNotFoundException, africa.absa.inception.core.service.ServiceUnavailableException Update the user.- Parameters:
user- the userexpirePassword- expire the user's password as part of the updatelockUser- lock the user as part of the update- Throws:
UserNotFoundException- if the user could not be foundafrica.absa.inception.core.service.ServiceUnavailableException- if the user could not be updated
-