Change a user's password remotely

2006-04-15T10:02:53
ID ATLASSIAN:JRACLOUD-9921
Type atlassian
Reporter asgeirn
Modified 2017-04-02T09:39:48

Description

{panel:bgColor=#e7f4fa} NOTE: This suggestion is for JIRA Cloud. Using JIRA Server? [See the corresponding suggestion|http://jira.atlassian.com/browse/JRASERVER-9921]. {panel}

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

Suggested API and implementation as follows:

{code}void changePassword(User admin, String username, String password) throws RemoteException, RemoteValidationException, RemotePermissionException;{code}

{code} 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);
    }

} {code}

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