import org.apache.log4j.Logger;
-import java.security.NoSuchAlgorithmException;
-
/**
* User administration initializer. It populates the user administration with a
* number of groups and users but only in case no users exist.
*
*/
public UserAdminInitializer(UserAdministration aAdmin, String[] aUsers,
- String[] aGroups, String[] aPasswords) throws UserMgtException,
- NoSuchAlgorithmException {
+ String[] aGroups, String[] aPasswords) throws UserMgtException {
if ((aUsers.length != aGroups.length) ||
(aUsers.length != aPasswords.length)) {
throw new IllegalArgumentException(
String group = aGroups[i];
String password = aPasswords[i];
- if (aAdmin.getUser(user) == null) {
- // must create user.
- Group groupObj = aAdmin.getGroup(group);
-
- if (groupObj == null) {
+ if (!aAdmin.checkUser(user)) {
+ if (!(aAdmin.checkGroup(group))) {
// must create group
LOGGER.info("Creating group: " + group);
- groupObj = aAdmin.createGroup(group);
+ aAdmin.createGroup(group);
}
- assert groupObj != null;
-
LOGGER
.info("Creating user: " + user + " password: " + password);
- aAdmin.createUser(user, password, groupObj);
+ aAdmin.createUser(user, password);
+ aAdmin.addUserToGroup(user, group);
}
}
}