org.wamblee.usermgt
Class UserAdministrationImpl

java.lang.Object
  extended by org.wamblee.usermgt.UserAdministrationImpl
All Implemented Interfaces:
UserAdministration

public class UserAdministrationImpl
extends java.lang.Object
implements UserAdministration

Administration of users and groups.

Author:
Erik Brakkee

Constructor Summary
UserAdministrationImpl(UserSet aUsers, GroupSet aGroups, NameValidator aUserValidator, NameValidator aGroupValidator)
          Constructs empty user administration.
 
Method Summary
 void addUserToGroup(User aUser, Group aGroup)
          Adds a user to a group.
 Group createGroup(java.lang.String aName)
          Creates a new group.
 User createUser(java.lang.String aUser, java.lang.String aPassword, Group aGroup)
          Creates a new user.
 Group getGroup(java.lang.String aName)
          Gets the group for a given group name.
 int getGroupCount()
           
 java.util.Set<Group> getGroups()
          Gets all known groups.
 User getUser(java.lang.String aName)
          Gets the user for a given name.
 int getUserCount()
           
 java.util.Set<User> getUsers()
          Get the users.
 java.util.Set<User> getUsers(Group aGroup)
          Gets the users for a given group.
 void groupModified(Group aGroup)
          Must be called when the group is modified.
 void removeGroup(Group aGroup)
          Removes the group.
 void removeUser(User aUser)
          Removes the user.
 void removeUserFromGroup(User aUser, Group aGroup)
          Removes a user from a group.
 void renameGroup(Group aGroup, java.lang.String aGroupName)
          Renames a group.
 void renameUser(User aUser, java.lang.String aUserName)
          Renames a user.
 void userModified(User aUser)
          Must be called when the user is modified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserAdministrationImpl

public UserAdministrationImpl(UserSet aUsers,
                              GroupSet aGroups,
                              NameValidator aUserValidator,
                              NameValidator aGroupValidator)
Constructs empty user administration.

Method Detail

createUser

public User createUser(java.lang.String aUser,
                       java.lang.String aPassword,
                       Group aGroup)
                throws UserMgtException
Description copied from interface: UserAdministration
Creates a new user.

Specified by:
createUser in interface UserAdministration
Parameters:
aUser - Username.
aPassword - Password.
aGroup - Group.
Returns:
User.
Throws:
UserMgtException - In case there is a conflict with an existing user.

createGroup

public Group createGroup(java.lang.String aName)
                  throws UserMgtException
Description copied from interface: UserAdministration
Creates a new group.

Specified by:
createGroup in interface UserAdministration
Parameters:
aName - Group name.
Returns:
Group
Throws:
UserMgtException - In case there is a conflict with an existing group.

userModified

public void userModified(User aUser)
Description copied from interface: UserAdministration
Must be called when the user is modified.

Specified by:
userModified in interface UserAdministration
Parameters:
aUser - User.

groupModified

public void groupModified(Group aGroup)
Description copied from interface: UserAdministration
Must be called when the group is modified.

Specified by:
groupModified in interface UserAdministration
Parameters:
aGroup - Group.

getUser

public User getUser(java.lang.String aName)
Description copied from interface: UserAdministration
Gets the user for a given name.

Specified by:
getUser in interface UserAdministration
Parameters:
aName - User name.
Returns:
User or null if not found.

getGroup

public Group getGroup(java.lang.String aName)
Description copied from interface: UserAdministration
Gets the group for a given group name.

Specified by:
getGroup in interface UserAdministration
Parameters:
aName - Group name.
Returns:
Group or null if not found.

getUsers

public java.util.Set<User> getUsers()
Description copied from interface: UserAdministration
Get the users.

Specified by:
getUsers in interface UserAdministration
Returns:
All known users.

getUsers

public java.util.Set<User> getUsers(Group aGroup)
Description copied from interface: UserAdministration
Gets the users for a given group.

Specified by:
getUsers in interface UserAdministration
Parameters:
aGroup - Group.
Returns:
Set of users (always non-null).

getGroups

public java.util.Set<Group> getGroups()
Description copied from interface: UserAdministration
Gets all known groups.

Specified by:
getGroups in interface UserAdministration
Returns:
Groups.

removeUser

public void removeUser(User aUser)
                throws UserMgtException
Description copied from interface: UserAdministration
Removes the user.

Specified by:
removeUser in interface UserAdministration
Parameters:
aUser - User to remove.
Throws:
UserMgtException - In case the user does not exist.

removeGroup

public void removeGroup(Group aGroup)
                 throws UserMgtException
Description copied from interface: UserAdministration
Removes the group.

Specified by:
removeGroup in interface UserAdministration
Parameters:
aGroup - Group to remove.
Throws:
UserMgtException - In case there are still users that are in the given group.

renameUser

public void renameUser(User aUser,
                       java.lang.String aUserName)
                throws UserMgtException
Description copied from interface: UserAdministration
Renames a user.

Specified by:
renameUser in interface UserAdministration
Parameters:
aUser - User object for which user name must be changed.
aUserName - New user name.
Throws:
UserMgtException - In case the user is not known or the new user name is already in use by another user.

renameGroup

public void renameGroup(Group aGroup,
                        java.lang.String aGroupName)
                 throws UserMgtException
Description copied from interface: UserAdministration
Renames a group.

Specified by:
renameGroup in interface UserAdministration
Parameters:
aGroup - Group to rename.
aGroupName - New name for the group.
Throws:
UserMgtException - In case the new group name is already used by another group of if the existing group is unknown.

addUserToGroup

public void addUserToGroup(User aUser,
                           Group aGroup)
                    throws UserMgtException
Description copied from interface: UserAdministration
Adds a user to a group.

Specified by:
addUserToGroup in interface UserAdministration
Parameters:
aUser - User.
aGroup - Group.
Throws:
UserMgtException - In case the user or group or not known or if the user is already part of the group.

removeUserFromGroup

public void removeUserFromGroup(User aUser,
                                Group aGroup)
                         throws UserMgtException
Description copied from interface: UserAdministration
Removes a user from a group.

Specified by:
removeUserFromGroup in interface UserAdministration
Parameters:
aUser - User
aGroup - Group
Throws:
UserMgtException - In case the user or group are unknown or if the user is not part of the group.

getUserCount

public int getUserCount()
Specified by:
getUserCount in interface UserAdministration
Returns:
Number of users.

getGroupCount

public int getGroupCount()
Specified by:
getGroupCount in interface UserAdministration
Returns:
Number of groups.


Copyright © 2010. All Rights Reserved.