/**
* Administration of users and groups.
+ *
+ * @author Erik Brakkee
*/
public class UserAdministrationImpl implements UserAdministration {
/**
* All known users.
*/
- private UserSet _users;
+ private UserSet users;
/**
* All known groups.
*/
- private GroupSet _groups;
+ private GroupSet groups;
/**
* Validator for user names.
*/
- private NameValidator _userValidator;
+ private NameValidator userValidator;
/**
* Validator for group names.
*/
- private NameValidator _groupValidator;
+ private NameValidator groupValidator;
/**
* Constructs empty user administration.
*/
public UserAdministrationImpl(UserSet aUsers, GroupSet aGroups, NameValidator aUserValidator,
NameValidator aGroupValidator) {
- _users = aUsers;
- _groups = aGroups;
- _userValidator = aUserValidator;
- _groupValidator = aGroupValidator;
+ users = aUsers;
+ groups = aGroups;
+ userValidator = aUserValidator;
+ groupValidator = aGroupValidator;
}
/*
*/
public User createUser(String aUser, String aPassword, Group aGroup)
throws UserMgtException {
- _userValidator.validate(aUser);
+ userValidator.validate(aUser);
checkGroup(aGroup);
- User user = _users.createUser(aUser, aPassword, aGroup);
+ User user = users.createUser(aUser, aPassword, aGroup);
return new User(user);
}
* @see org.wamblee.usermgt.UserAdministration#createGroup(java.lang.String)
*/
public Group createGroup(String aName) throws UserMgtException {
- _groupValidator.validate(aName);
+ groupValidator.validate(aName);
Group group = new Group(aName);
- if (_groups.contains(group)) {
+ if (groups.contains(group)) {
throw new UserMgtException(DUPLICATE_GROUP, group);
}
- _groups.add(group);
+ groups.add(group);
return new Group(group);
}
* @see org.wamblee.usermgt.UserAdministration#userModified(org.wamblee.usermgt.User)
*/
public void userModified(User aUser) {
- _users.userModified(aUser);
+ users.userModified(aUser);
}
/*
* @see org.wamblee.usermgt.UserAdministration#groupModified(org.wamblee.usermgt.Group)
*/
public void groupModified(Group aGroup) {
- _groups.groupModified(aGroup);
+ groups.groupModified(aGroup);
}
/*
* @see org.wamblee.usermgt.UserAdministration#getUser(java.lang.String)
*/
public User getUser(String aName) {
- return _users.find(aName);
+ return users.find(aName);
}
/*
* @see org.wamblee.usermgt.UserAdministration#getGroup(java.lang.String)
*/
public Group getGroup(String aName) {
- return _groups.find(aName);
+ return groups.find(aName);
}
/*
* @see org.wamblee.usermgt.UserAdministration#getUsers()
*/
public Set<User> getUsers() {
- return _users.list();
+ return users.list();
}
/*
* @see org.wamblee.usermgt.UserAdministration#getUsers(org.wamblee.usermgt.Group)
*/
public Set<User> getUsers(Group aGroup) {
- return _users.list(aGroup);
+ return users.list(aGroup);
}
/*
* @see org.wamblee.usermgt.UserAdministration#getGroups()
*/
public Set<Group> getGroups() {
- return _groups.list();
+ return groups.list();
}
/*
*/
public void removeUser(User aUser) throws UserMgtException {
checkUser(aUser);
- _users.remove(aUser);
+ users.remove(aUser);
}
/*
if (getUsers(aGroup).size() > 0) {
throw new UserMgtException(GROUP_STILL_OCCUPIED, aGroup);
}
- _groups.remove(aGroup);
+ groups.remove(aGroup);
}
/*
if (aUser.getName().equals(aUserName)) {
throw new UserMgtException(TRIVIAL_RENAME, aUser);
}
- if (_users.find(aUserName) != null) {
+ if (users.find(aUserName) != null) {
throw new UserMgtException(DUPLICATE_USER, aUser);
}
- _userValidator.validate(aUserName);
+ userValidator.validate(aUserName);
// we are modifying the user so we should re-insert it into the set
// after renaming it.
- _users.remove(aUser);
+ users.remove(aUser);
aUser.setName(aUserName);
- _users.add(aUser);
+ users.add(aUser);
}
/*
if (aGroup.getName().equals(aGroupName)) {
throw new UserMgtException(TRIVIAL_RENAME, aGroup);
}
- if (_groups.find(aGroupName) != null) {
+ if (groups.find(aGroupName) != null) {
throw new UserMgtException(DUPLICATE_GROUP, aGroup);
}
- _groupValidator.validate(aGroupName);
+ groupValidator.validate(aGroupName);
// we are renaming the group so we should re-insert it into the set
// after renaming it.
- _groups.remove(aGroup);
+ groups.remove(aGroup);
aGroup.setName(aGroupName);
- _groups.add(aGroup);
+ groups.add(aGroup);
}
/*
checkUser(aUser);
checkGroup(aGroup);
aUser.addGroup(aGroup);
- _users.userModified(aUser);
+ users.userModified(aUser);
}
/*
checkUser(aUser);
checkGroup(aGroup);
aUser.removeGroup(aGroup);
- _users.userModified(aUser);
+ users.userModified(aUser);
}
/**
* @throws UserMgtException
*/
private void checkUser(User aUser) throws UserMgtException {
- if (!_users.contains(aUser)) {
+ if (!users.contains(aUser)) {
throw new UserMgtException(UNKNOWN_USER, aUser);
}
}
* @throws UserMgtException
*/
private void checkGroup(Group aGroup) throws UserMgtException {
- if (!_groups.contains(aGroup)) {
+ if (!groups.contains(aGroup)) {
throw new UserMgtException(UNKNOWN_GROUP, aGroup);
}
}
* @see org.wamblee.usermgt.UserAdministration#getUserCount()
*/
public int getUserCount() {
- return _users.size();
+ return users.size();
}
/* (non-Javadoc)
* @see org.wamblee.usermgt.UserAdministration#getGroupCount()
*/
public int getGroupCount() {
- return _groups.size();
+ return groups.size();
}
}