Change a user's password remotely

XMLWordPrintable

      NOTE: This suggestion is for JIRA Server. Using JIRA Cloud? See the corresponding suggestion.

      I would like to be able to change a user's password remotely.

      Suggested API and implementation as follows:

      void changePassword(User admin, String username, String password)
      throws RemoteException, RemoteValidationException, RemotePermissionException;
      public void changePassword(User admin, String username, String password)
        throws RemoteException, RemoteValidationException, RemotePermissionException {
              if (!permissionManager.hasPermission(Permissions.ADMINISTER, admin))
              {
                  throw new RemotePermissionException("You do not have permission to administer a user.");
              }
              if (username == null || "".equals(username))
              {
                  throw new RemoteValidationException("username needs a value");
              }
              if (password == null || "".equals(password))
              {
                  throw new RemoteValidationException("password needs a value");
              }
              // IS THIS NECESSARY?  Copied from deleteUser()
              if (applicationProperties.getOption(APKeys.JIRA_OPTION_USER_EXTERNALMGT))
              {
                  throw new RemotePermissionException("Cannot change password, as external user management is enabled.");
              }
      
              User user = null;
              try
              {
                  user = userManager.getUser(username);
              }
              catch (EntityNotFoundException e)
              {
                  throw new RemoteValidationException("Unable to find user  " + username);
              }
      		
              try {
                  UserUtils.changePassword(user, password);
              } catch (ImmutableException e) {
                  throw new RemoteException("Unable to change password for " + user + ": " + e.getMessage(), e);
              }
      }
      

      I get deprecation warnings on UserUtils, but userManager does not expose the changePassword method.

              Assignee:
              Unassigned
              Reporter:
              Asgeir Storesund Nilsen
              Votes:
              11 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: