org.wamblee.security.authentication
Class UserAdministrationImpl

java.lang.Object
  extended by org.wamblee.security.authentication.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(java.lang.String aUser, java.lang.String aGroup)
          Adds a user to a group.
 boolean changePassword(java.lang.String aUser, java.lang.String aOldPassword, java.lang.String aNewPassword)
          Changes the password.
 boolean checkGroup(java.lang.String aGroup)
          Check if a group exists.
 boolean checkPassword(java.lang.String aUser, java.lang.String aPassword)
          Checks the password.
 boolean checkUser(java.lang.String aUser)
          Checks if a user exists.
 void createGroup(java.lang.String aName)
          Creates a new group.
 void createUser(java.lang.String aUser, java.lang.String aPassword)
          Creates a new user.
 int getGroupCount()
           
 java.util.List<java.lang.String> getGroups()
          Gets all groups.
 java.util.List<java.lang.String> getGroups(java.lang.String aUser)
          Gets all groups for a given user.
 int getUserCount()
           
 java.util.List<java.lang.String> getUsers()
          Get the users.
 java.util.List<java.lang.String> getUsers(java.lang.String aGroup)
          Gets the users for a given group.
 boolean isInGroup(java.lang.String aUser, java.lang.String aGroup)
          Checks if the user belongs to the given group.
 void removeGroup(java.lang.String aGroup)
          Removes the group.
 void removeUser(java.lang.String aUser)
          Removes the user.
 void removeUserFromGroup(java.lang.String aUser, java.lang.String aGroup)
          Removes a user from a group.
 void renameGroup(java.lang.String aOldGroup, java.lang.String aNewGroup)
          Renames a group.
 void renameUser(java.lang.String aOldUsername, java.lang.String aNewUsername)
          Renames a user.
 void setPassword(java.lang.String aUser, java.lang.String aPassword)
           
 
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 void createUser(java.lang.String aUser,
                       java.lang.String aPassword)
Description copied from interface: UserAdministration
Creates a new user.

Specified by:
createUser in interface UserAdministration
Parameters:
aUser - Username.
aPassword - Password.

createGroup

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

Specified by:
createGroup in interface UserAdministration
Parameters:
aName - Group name.

checkUser

public boolean checkUser(java.lang.String aUser)
Description copied from interface: UserAdministration
Checks if a user exists.

Specified by:
checkUser in interface UserAdministration
Parameters:
aUser - User to check.
Returns:
True iff user exists.

checkGroup

public boolean checkGroup(java.lang.String aGroup)
Description copied from interface: UserAdministration
Check if a group exists.

Specified by:
checkGroup in interface UserAdministration
Parameters:
aGroup - Group.
Returns:
True iff group exists.

checkPassword

public boolean checkPassword(java.lang.String aUser,
                             java.lang.String aPassword)
Description copied from interface: UserAdministration
Checks the password.

Specified by:
checkPassword in interface UserAdministration
Parameters:
aUser - User to check password for.
aPassword - Password to check.
Returns:
True iff password is ok.

changePassword

public boolean changePassword(java.lang.String aUser,
                              java.lang.String aOldPassword,
                              java.lang.String aNewPassword)
Description copied from interface: UserAdministration
Changes the password.

Specified by:
changePassword in interface UserAdministration
Parameters:
aUser - User.
aOldPassword - Old password.
aNewPassword - New password.
Returns:
True if the password was changed.

setPassword

public void setPassword(java.lang.String aUser,
                        java.lang.String aPassword)
Specified by:
setPassword in interface UserAdministration
Parameters:
aUser - User.
aPassword - The password to set.

isInGroup

public boolean isInGroup(java.lang.String aUser,
                         java.lang.String aGroup)
Description copied from interface: UserAdministration
Checks if the user belongs to the given group.

Specified by:
isInGroup in interface UserAdministration
Parameters:
aUser - User
aGroup - Group.
Returns:
True iff user is in 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.

getUsers

public java.util.List<java.lang.String> getUsers()
Description copied from interface: UserAdministration
Get the users.

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

getUsers

public java.util.List<java.lang.String> getUsers(java.lang.String 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.List<java.lang.String> getGroups()
Description copied from interface: UserAdministration
Gets all groups.

Specified by:
getGroups in interface UserAdministration
Returns:
Groups.

getGroups

public java.util.List<java.lang.String> getGroups(java.lang.String aUser)
Description copied from interface: UserAdministration
Gets all groups for a given user.

Specified by:
getGroups in interface UserAdministration
Parameters:
aUser - user.
Returns:
Groups.

renameUser

public void renameUser(java.lang.String aOldUsername,
                       java.lang.String aNewUsername)
Description copied from interface: UserAdministration
Renames a user.

Specified by:
renameUser in interface UserAdministration
Parameters:
aOldUsername - Current user name.
aNewUsername - New user name.

renameGroup

public void renameGroup(java.lang.String aOldGroup,
                        java.lang.String aNewGroup)
Description copied from interface: UserAdministration
Renames a group.

Specified by:
renameGroup in interface UserAdministration
aNewGroup - New name for the group.

removeUser

public void removeUser(java.lang.String aUser)
Description copied from interface: UserAdministration
Removes the user.

Specified by:
removeUser in interface UserAdministration
Parameters:
aUser - User to remove.

removeGroup

public void removeGroup(java.lang.String aGroup)
Description copied from interface: UserAdministration
Removes the group.

Specified by:
removeGroup in interface UserAdministration
Parameters:
aGroup - Group to remove.

addUserToGroup

public void addUserToGroup(java.lang.String aUser,
                           java.lang.String aGroup)
Description copied from interface: UserAdministration
Adds a user to a group.

Specified by:
addUserToGroup in interface UserAdministration
Parameters:
aUser - User.
aGroup - Group.

removeUserFromGroup

public void removeUserFromGroup(java.lang.String aUser,
                                java.lang.String aGroup)
Description copied from interface: UserAdministration
Removes a user from a group.

Specified by:
removeUserFromGroup in interface UserAdministration
Parameters:
aUser - User
aGroup - Group


Copyright © 2022. All Rights Reserved.