@Override int doWork() { try (DbConn cnx = Helpers.getNewDbSession()) { Helpers.createUserIfMissing(cnx, login, password, "created through CLI", roles.toArray(new String[roles.size()])); MetaService.changeUserPassword(cnx, login, password); cnx.commit(); return 0; } } }
public static void changeUserPassword(DbConn cnx, String userLogin, String newPassword) { List<RUserDto> dtos = getUsers(cnx, "user_select_by_key", 0, userLogin); if (dtos.size() == 0) { throw new JqmAdminApiUserException("Cannot update the password of a user which does not exist - given login was " + userLogin); } changeUserPassword(cnx, dtos.get(0).getId(), newPassword); }
public static void changeUserPassword(DbConn cnx, String userLogin, String newPassword) { List<RUserDto> dtos = getUsers(cnx, "user_select_by_key", 0, userLogin); if (dtos.size() == 0) { throw new JqmAdminApiUserException("Cannot update the password of a user which does not exist - given login was " + userLogin); } changeUserPassword(cnx, dtos.get(0).getId(), newPassword); }
@Override int doWork() { try (DbConn cnx = Helpers.getNewDbSession()) { Helpers.createRoleIfMissing(cnx, "administrator", "all permissions without exception", "*:*"); Helpers.createUserIfMissing(cnx, "root", password, "all powerful user", "administrator"); MetaService.changeUserPassword(cnx, "root", password); cnx.commit(); return 0; } catch (Exception ex) { jqmlogger.error("Could not reset the root account", ex); return 108; } } }
private static void user(String[] options) { if (options.length < 3) { throw new IllegalArgumentException("-U option requires one login, one password and at least one role (in this order)"); } DbConn cnx = null; try { cnx = Helpers.getNewDbSession(); String[] roles = new String[options.length - 2]; for (int i = 2; i < options.length; i++) { roles[i - 2] = options[i]; } Helpers.createUserIfMissing(cnx, options[0], options[1], "created through CLI", roles); MetaService.changeUserPassword(cnx, options[0], options[1]); cnx.commit(); } finally { Helpers.closeQuietly(cnx); } }
private static void root(String password) { DbConn cnx = null; try { cnx = Helpers.getNewDbSession(); Helpers.createRoleIfMissing(cnx, "administrator", "all permissions without exception", "*:*"); Helpers.createUserIfMissing(cnx, "root", password, "all powerful user", "administrator"); MetaService.changeUserPassword(cnx, "root", password); cnx.commit(); } catch (Exception ex) { jqmlogger.fatal("Could not reset the root account", ex); } finally { Helpers.closeQuietly(cnx); } }
changeUserPassword(cnx, dto.getId(), dto.getNewPassword()); changeUserPassword(cnx, newId, dto.getNewPassword());
changeUserPassword(cnx, dto.getId(), dto.getNewPassword()); changeUserPassword(cnx, newId, dto.getNewPassword());