Class CreateUserServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- org.apache.sling.api.servlets.SlingSafeMethodsServlet
-
- org.apache.sling.api.servlets.SlingAllMethodsServlet
-
- org.apache.sling.jackrabbit.usermanager.impl.post.AbstractPostServlet
-
- org.apache.sling.jackrabbit.usermanager.impl.post.AbstractAuthorizablePostServlet
-
- org.apache.sling.jackrabbit.usermanager.impl.post.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/userslike/rep:system/rep:userManager/rep:usersmapped to a resource url/system/userManager/user. This servlet responds at/system/userManager/user.create.htmlMethods
- POST
Post Parameters
- one of these
-
- :name - The value is the exact name to use
- :name@ValueFrom - The value is the name of another submitted parameter whose value is the exact name to use
- :nameHint - The value is filtered, trimmed and made unique
- :nameHint@ValueFrom - The value is the name of another submitted parameter whose value is filtered, trimmed and made unique
- otherwise - Try the value of any server-side configured "principalNameHints" parameter to treat as a hint that is filtered, trimmed and made unique
- :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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCreateUserServlet.Config
-
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 Constructor Description CreateUserServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidactivate(CreateUserServlet.Config config, Map<String,Object> props)protected voidbindPostResponseCreator(org.apache.sling.servlets.post.PostResponseCreator creator, Map<String,Object> properties)Overridden since the @Reference annotation is not inherited from the super methodprotected voidbindPrincipalNameFilter(PrincipalNameFilter filter)Bind a new principal name filterprotected voidbindPrincipalNameGenerator(PrincipalNameGenerator generator, Map<String,Object> properties)Bind a new principal name generatorprotected voidbindSystemUserManagerPaths(SystemUserManagerPaths sump)org.apache.jackrabbit.api.security.user.UsercreateUser(javax.jcr.Session jcrSession, String name, String password, String passwordConfirm, Map<String,?> properties, List<org.apache.sling.servlets.post.Modification> changes)Create a new user for the repositoryprotected voiddeactivate()protected voidhandleOperation(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.servlets.post.PostResponse 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.PostResponseCreator creator, Map<String,Object> properties)Unbind a post response creatorprotected voidunbindPrincipalNameFilter(PrincipalNameFilter filter)protected voidunbindPrincipalNameGenerator(PrincipalNameGenerator generator)-
Methods inherited from class org.apache.sling.jackrabbit.usermanager.impl.post.AbstractAuthorizablePostServlet
activate, collectContent, collectContentMap, convertToRequestParameterArray, convertToString, convertToStringArray, getOrGeneratePrincipalName, hasItemPathPrefix, processCreate, processDeletes, requireItemPathPrefix, writeContent
-
Methods inherited from class org.apache.sling.jackrabbit.usermanager.impl.post.AbstractPostServlet
createHtmlResponse, doPost, externalizePath, getItemPath, getRanking, getRedirectUrl, getRedirectUrl, handleOperation, isSetStatus
-
Methods inherited from class org.apache.sling.api.servlets.SlingAllMethodsServlet
doDelete, doPut, getAllowedRequestMethods, isMethodValid, mayService
-
Methods inherited from class org.apache.sling.api.servlets.SlingSafeMethodsServlet
doGeneric, doGet, doHead, doOptions, doTrace, getServletInfo, handleMethodNotImplemented, service, service
-
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.sling.jackrabbit.usermanager.CreateUser
createUser
-
-
-
-
Method Detail
-
activate
protected void activate(CreateUserServlet.Config config, Map<String,Object> props)
-
deactivate
protected void deactivate()
- Overrides:
deactivatein classAbstractAuthorizablePostServlet
-
bindPrincipalNameGenerator
protected void bindPrincipalNameGenerator(PrincipalNameGenerator generator, Map<String,Object> properties)
Description copied from class:AbstractAuthorizablePostServletBind a new principal name generator- Overrides:
bindPrincipalNameGeneratorin classAbstractAuthorizablePostServlet
-
unbindPrincipalNameGenerator
protected void unbindPrincipalNameGenerator(PrincipalNameGenerator generator)
- Overrides:
unbindPrincipalNameGeneratorin classAbstractAuthorizablePostServlet
-
bindPrincipalNameFilter
protected void bindPrincipalNameFilter(PrincipalNameFilter filter)
Description copied from class:AbstractAuthorizablePostServletBind a new principal name filter- Overrides:
bindPrincipalNameFilterin classAbstractAuthorizablePostServlet
-
unbindPrincipalNameFilter
protected void unbindPrincipalNameFilter(PrincipalNameFilter filter)
- Overrides:
unbindPrincipalNameFilterin classAbstractAuthorizablePostServlet
-
bindSystemUserManagerPaths
protected void bindSystemUserManagerPaths(SystemUserManagerPaths sump)
- Overrides:
bindSystemUserManagerPathsin classAbstractAuthorizablePostServlet
-
bindPostResponseCreator
protected void bindPostResponseCreator(org.apache.sling.servlets.post.PostResponseCreator 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.PostResponseCreator 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.SlingHttpServletRequest request, org.apache.sling.servlets.post.PostResponse response, List<org.apache.sling.servlets.post.Modification> changes) throws javax.jcr.RepositoryExceptionDescription 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
-
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.RepositoryExceptionDescription copied from interface:CreateUserCreate a new user for the repository- Specified by:
createUserin interfaceCreateUser- Parameters:
jcrSession- the JCR session of the user creating the username- The name of the new user. If null or empty, the name is calculated from the supplied properties (per SLING-10902).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
-
-