public void updateUser(GeoServerUser user) throws IOException,PasswordPolicyException { preparePassword(user); Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("users.update", con); ps.setString(1,user.getPassword()); ps.setString(2,convertToString(user.isEnabled())); ps.setString(3,user.getUsername()); ps.execute(); ps.close(); ps = getDMLStatement("userprops.deleteForUser",con); ps.setString(1,user.getUsername()); ps.execute(); addUserProperties(user, con); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }
public void addUser(GeoServerUser user) throws IOException, PasswordPolicyException { preparePassword(user); Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = getDMLStatement("users.insert", con); ps.setString(1,user.getUsername()); if (user.getPassword() != null) { ps.setString(2,user.getPassword()); } else { ps.setNull(2, Types.VARCHAR); } ps.setString(3,convertToString(user.isEnabled())); ps.execute(); addUserProperties(user, con); } catch (SQLException ex) { throw new IOException(ex); } finally { closeFinally(con, ps, null); } setModified(true); }