Class CreateUserServlet

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

    public class CreateUserServlet
    extends AbstractAuthorizablePostServlet
    implements CreateUser

    Sling Post Servlet implementation for creating a user in the jackrabbit UserManager.

    Rest Service Description

    Creates a new user. Maps on to nodes of resourceType sling/users like /rep:system/rep:userManager/rep:users mapped to a resource url /system/userManager/user. This servlet responds at /system/userManager/user.create.html

    Methods

    • POST

    Post Parameters

    :name
    The name of the new user (required)
    :pwd
    The password of the new user (required)
    :pwdConfirm
    The password of the new user (required)
    *
    Any additional parameters become properties of the user node (optional)

    Response

    200
    Success, a redirect is sent to the users resource locator. The redirect comes with HTML describing the status.
    500
    Failure, including user already exists. HTML explains the failure.

    Example

    curl -F:name=ieb -Fpwd=password -FpwdConfirm=password -Fproperty1=value1 http://localhost:8080/system/userManager/user.create.html
    See Also:
    Serialized Form
    • Constructor Detail

      • CreateUserServlet

        public CreateUserServlet()
    • 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
      • createUser

        public org.apache.jackrabbit.api.security.user.User createUser​(javax.jcr.Session jcrSession,
                                                                       String name,
                                                                       String password,
                                                                       String passwordConfirm,
                                                                       Map<String,​?> properties,
                                                                       List<org.apache.sling.servlets.post.Modification> changes)
                                                                throws javax.jcr.RepositoryException
        Description copied from interface: CreateUser
        Create a new user for the repository
        Specified by:
        createUser in interface CreateUser
        Parameters:
        jcrSession - the JCR session of the user creating the user
        name - The name of the new user (required)
        password - The password of the new user (required)
        passwordConfirm - The password of the new user again (required)
        properties - Extra properties to update on the user. The entry values should be either a String or String[] (optional)
        changes - The list of changes for this operation (optional)
        Returns:
        the user that was created
        Throws:
        javax.jcr.RepositoryException - if user can't be created