/** * This method registers a new administrator in the system. The authentication object must be from * an administrator. * * @param a the authentication object * @param ui the new user's information * @param pw the new user's password * @return the authentication of the registered user */ public boolean newAdmin(Auth a, UserInfo ui, String pw) { if (!dbc.loadUser(a.getUserID()).isAdministrator()) return false; User u = new User(ui); u.setPassword(pw); if (dbc.newUser(u)) { User nu = dbc.loadUser(u.getId()); return nu != null; } return false; }
/** * This method registers a new user in the system * * @param ui the new user's information * @param pw the new user's password * @return the authentication of the registered user */ public Auth newUser(UserInfo ui, String pw) { User u = new User(ui); u.setPassword(pw); u.setAdministrator(false); if (dbc.newUser(u)) { User nu = dbc.loadUser(u.getId()); return new SAuth(Auths.getInstance().login(nu, nu.getPassword())); } return null; }