Class ChangeUserPasswordServlet
java.lang.Object
jakarta.servlet.GenericServlet
org.apache.sling.api.servlets.SlingJakartaSafeMethodsServlet
org.apache.sling.api.servlets.SlingJakartaAllMethodsServlet
org.apache.sling.jackrabbit.usermanager.impl.post.AbstractPostServlet
org.apache.sling.jackrabbit.usermanager.impl.post.AbstractAuthorizablePostServlet
org.apache.sling.jackrabbit.usermanager.impl.post.ChangeUserPasswordServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable,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:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class org.apache.sling.jackrabbit.usermanager.impl.post.AbstractAuthorizablePostServlet
principalNameFilter, principalNameGenerators, PROP_DATE_FORMAT, RP_NODE_NAME_HINT_VALUE_FROM, RP_NODE_NAME_VALUE_FROM, systemUserManagerPaths -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidActivates this component.protected voidbindPostResponseCreator(org.apache.sling.servlets.post.JakartaPostResponseCreator creator, Map<String, Object> properties) Overridden since the @Reference annotation is not inherited from the super methodorg.apache.jackrabbit.api.security.user.UserchangePassword(javax.jcr.Session jcrSession, String name, String oldPassword, String newPassword, String newPasswordConfirm, List<org.apache.sling.servlets.post.Modification> changes) Update the password of a user in the repositoryprotected voidprotected voidhandleOperation(org.apache.sling.api.SlingJakartaHttpServletRequest request, org.apache.sling.servlets.post.JakartaPostResponse response, List<org.apache.sling.servlets.post.Modification> changes) Extending Servlet should implement this operation to do the workprotected voidunbindPostResponseCreator(org.apache.sling.servlets.post.JakartaPostResponseCreator creator, Map<String, Object> properties) Unbind a post response creatorMethods inherited from class org.apache.sling.jackrabbit.usermanager.impl.post.AbstractAuthorizablePostServlet
bindPrincipalNameFilter, bindPrincipalNameGenerator, bindSystemUserManagerPaths, collectContentMap, concatPath, convertToRequestParameterArray, convertToString, convertToStringArray, getOrGeneratePrincipalName, hasItemPathPrefix, processCreate, processDeletes, requireItemPathPrefix, unbindPrincipalNameFilter, unbindPrincipalNameGenerator, writeContentMethods inherited from class org.apache.sling.jackrabbit.usermanager.impl.post.AbstractPostServlet
doPost, externalizePath, getItemPath, getRanking, getRedirectUrl, isSetStatusMethods inherited from class org.apache.sling.api.servlets.SlingJakartaAllMethodsServlet
doDelete, doPut, getAllowedRequestMethods, isMethodValid, mayServiceMethods inherited from class org.apache.sling.api.servlets.SlingJakartaSafeMethodsServlet
doGeneric, doGet, doHead, doOptions, doTrace, getServletInfo, handleMethodNotImplemented, service, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log
-
Constructor Details
-
ChangeUserPasswordServlet
public ChangeUserPasswordServlet()
-
-
Method Details
-
activate
Activates this component.- Overrides:
activatein classAbstractAuthorizablePostServlet- Parameters:
props- The component properties
-
deactivate
protected void deactivate()- Overrides:
deactivatein classAbstractAuthorizablePostServlet
-
bindPostResponseCreator
protected void bindPostResponseCreator(org.apache.sling.servlets.post.JakartaPostResponseCreator creator, Map<String, Object> properties) Overridden since the @Reference annotation is not inherited from the super method -
unbindPostResponseCreator
protected void unbindPostResponseCreator(org.apache.sling.servlets.post.JakartaPostResponseCreator creator, Map<String, Object> properties) Description copied from class:AbstractPostServletUnbind a post response creator- Overrides:
unbindPostResponseCreatorin classAbstractPostServlet
-
handleOperation
protected void handleOperation(org.apache.sling.api.SlingJakartaHttpServletRequest request, org.apache.sling.servlets.post.JakartaPostResponse response, List<org.apache.sling.servlets.post.Modification> changes) throws javax.jcr.RepositoryException Description copied from class:AbstractPostServletExtending Servlet should implement this operation to do the work- Specified by:
handleOperationin classAbstractPostServlet- Parameters:
request- the sling http request to processresponse- the responsechanges- 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:ChangeUserPasswordUpdate the password of a user in the repository- Specified by:
changePasswordin interfaceChangeUserPassword- Parameters:
jcrSession- the JCR session of the user updating the username- 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
-