Class ChangeUserPasswordServlet

  • All Implemented Interfaces:
    Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, ChangeUserPassword

    public class ChangeUserPasswordServlet
    extends AbstractAuthorizablePostServlet
    implements ChangeUserPassword

    Changes the password associated with a user. Maps on to nodes of resourceType sling/user like /rep:system/rep:userManager/rep:users/ae/fd/3e/ieb mapped to a resource url /system/userManager/user/ieb. This servlet responds at /system/userManager/user/ieb.changePassword.html

    Methods

    • POST

    Post Parameters

    oldPwd
    The current password for the user (required for non-administrators)
    newPwd
    The new password for the user (required)
    newPwdConfirm
    The confirm new password for the user (required)

    Response

    200
    Success sent with no body
    404
    If the user was not found.
    500
    Failure, including password validation errors. HTML explains the failure.

    Example

    curl -FoldPwd=oldpassword -FnewPwd=newpassword -FnewPwdConfirm=newpassword http://localhost:8080/system/userManager/user/ieb.changePassword.html

    Notes

    See Also:
    Serialized Form
    • Constructor Detail

      • ChangeUserPasswordServlet

        public ChangeUserPasswordServlet()
    • Method Detail

      • handleOperation

        protected void handleOperation​(org.apache.sling.api.SlingHttpServletRequest request,
                                       org.apache.sling.servlets.post.PostResponse response,
                                       List<org.apache.sling.servlets.post.Modification> changes)
                                throws javax.jcr.RepositoryException
        Description copied from class: AbstractPostServlet
        Extending Servlet should implement this operation to do the work
        Specified by:
        handleOperation in class AbstractPostServlet
        Parameters:
        request - the sling http request to process
        response - the response
        changes - the changes to report
        Throws:
        javax.jcr.RepositoryException - in case of exceptions during the operation
      • changePassword

        public org.apache.jackrabbit.api.security.user.User changePassword​(javax.jcr.Session jcrSession,
                                                                           String name,
                                                                           String oldPassword,
                                                                           String newPassword,
                                                                           String newPasswordConfirm,
                                                                           List<org.apache.sling.servlets.post.Modification> changes)
                                                                    throws javax.jcr.RepositoryException
        Description copied from interface: ChangeUserPassword
        Update the password of a user in the repository
        Specified by:
        changePassword in interface ChangeUserPassword
        Parameters:
        jcrSession - the JCR session of the user updating the user
        name - The name of the user to update (required)
        oldPassword - The current password of the user (required for non-admin users)
        newPassword - The password value to apply (required)
        newPasswordConfirm - The password value to apply again (required)
        changes - The list of changes for this operation (optional)
        Returns:
        the user whose password was changed
        Throws:
        javax.jcr.RepositoryException - if password can't be changed for some reason