Class AbstractWebdavServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.apache.jackrabbit.webdav.server.AbstractWebdavServlet
-
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
,DavConstants
- Direct Known Subclasses:
JCRWebdavServerServlet
,SimpleWebdavServlet
public abstract class AbstractWebdavServlet extends javax.servlet.http.HttpServlet implements DavConstants
AbstractWebdavServlet
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_AUTHENTICATE_HEADER
Default value for the 'WWW-Authenticate' header, that is set, if request results in a401 (Unauthorized)
error.static String
INIT_PARAM_AUTHENTICATE_HEADER
Name of the optional init parameter that defines the value of the 'WWW-Authenticate' header.static String
INIT_PARAM_CREATE_ABSOLUTE_URI
Name of the 'createAbsoluteURI' init parameter that defines whether hrefs should be created with a absolute URI or as absolute Path (ContextPath).static String
INIT_PARAM_CSRF_PROTECTION
Name of the parameter that specifies the configuration of the CSRF protection.static String
INIT_PARAM_MISSING_AUTH_MAPPING
the 'missing-auth-mapping' init parameter-
Fields inherited from interface org.apache.jackrabbit.webdav.DavConstants
creationDateFormat, DEPTH_0, DEPTH_1, DEPTH_INFINITY, DEPTH_INFINITY_S, HEADER_AUTHORIZATION, HEADER_CONTENT_LANGUAGE, HEADER_CONTENT_LENGTH, HEADER_CONTENT_TYPE, HEADER_DAV, HEADER_DEPTH, HEADER_DESTINATION, HEADER_ETAG, HEADER_IF, HEADER_LAST_MODIFIED, HEADER_LOCK_TOKEN, HEADER_OVERWRITE, HEADER_TIMEOUT, INFINITE_TIMEOUT, modificationDateFormat, NAMESPACE, OPAQUE_LOCK_TOKEN_PREFIX, PROPERTY_CREATIONDATE, PROPERTY_DISPLAYNAME, PROPERTY_GETCONTENTLANGUAGE, PROPERTY_GETCONTENTLENGTH, PROPERTY_GETCONTENTTYPE, PROPERTY_GETETAG, PROPERTY_GETLASTMODIFIED, PROPERTY_LOCKDISCOVERY, PROPERTY_RESOURCETYPE, PROPERTY_SOURCE, PROPERTY_SUPPORTEDLOCK, PROPFIND_ALL_PROP, PROPFIND_ALL_PROP_INCLUDE, PROPFIND_BY_PROPERTY, PROPFIND_PROPERTY_NAMES, TIMEOUT_INFINITE, UNDEFINED_TIME, UNDEFINED_TIMEOUT, XML_ACTIVELOCK, XML_ALLPROP, XML_COLLECTION, XML_DEPTH, XML_DST, XML_EXCLUSIVE, XML_HREF, XML_INCLUDE, XML_KEEPALIVE, XML_LINK, XML_LOCKENTRY, XML_LOCKINFO, XML_LOCKROOT, XML_LOCKSCOPE, XML_LOCKTOKEN, XML_LOCKTYPE, XML_MULTISTATUS, XML_OMIT, XML_OWNER, XML_PROP, XML_PROPERTYBEHAVIOR, XML_PROPERTYUPDATE, XML_PROPFIND, XML_PROPNAME, XML_PROPSTAT, XML_REMOVE, XML_RESPONSE, XML_RESPONSEDESCRIPTION, XML_SET, XML_SHARED, XML_SOURCE, XML_STATUS, XML_TIMEOUT, XML_WRITE
-
-
Constructor Summary
Constructors Constructor Description AbstractWebdavServlet()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
doAcl(WebdavRequest request, WebdavResponse response, DavResource resource)
The ACL methodprotected void
doBaselineControl(WebdavRequest request, WebdavResponse response, DavResource resource)
The BASELINECONTROL methodprotected void
doBind(WebdavRequest request, WebdavResponse response, DavResource resource)
The BIND methodprotected void
doCheckin(WebdavRequest request, WebdavResponse response, DavResource resource)
The CHECKIN methodprotected void
doCheckout(WebdavRequest request, WebdavResponse response, DavResource resource)
The CHECKOUT methodprotected void
doCopy(WebdavRequest request, WebdavResponse response, DavResource resource)
The COPY methodprotected void
doDelete(WebdavRequest request, WebdavResponse response, DavResource resource)
The DELETE methodprotected void
doGet(WebdavRequest request, WebdavResponse response, DavResource resource)
The GET methodprotected void
doHead(WebdavRequest request, WebdavResponse response, DavResource resource)
The HEAD methodprotected void
doLabel(WebdavRequest request, WebdavResponse response, DavResource resource)
The LABEL methodprotected void
doLock(WebdavRequest request, WebdavResponse response, DavResource resource)
The LOCK methodprotected void
doMerge(WebdavRequest request, WebdavResponse response, DavResource resource)
The MERGE methodprotected void
doMkActivity(WebdavRequest request, WebdavResponse response, DavResource resource)
The MKACTIVITY methodprotected void
doMkCol(WebdavRequest request, WebdavResponse response, DavResource resource)
The MKCOL methodprotected void
doMkWorkspace(WebdavRequest request, WebdavResponse response, DavResource resource)
The MKWORKSPACE methodprotected void
doMove(WebdavRequest request, WebdavResponse response, DavResource resource)
The MOVE methodprotected void
doOptions(WebdavRequest request, WebdavResponse response, DavResource resource)
The OPTION methodprotected void
doOrderPatch(WebdavRequest request, WebdavResponse response, DavResource resource)
The ORDERPATCH methodprotected void
doPoll(WebdavRequest request, WebdavResponse response, DavResource resource)
The POLL methodprotected void
doPost(WebdavRequest request, WebdavResponse response, DavResource resource)
The POST method.protected void
doPropFind(WebdavRequest request, WebdavResponse response, DavResource resource)
The PROPFIND methodprotected void
doPropPatch(WebdavRequest request, WebdavResponse response, DavResource resource)
The PROPPATCH methodprotected void
doPut(WebdavRequest request, WebdavResponse response, DavResource resource)
The PUT methodprotected void
doRebind(WebdavRequest request, WebdavResponse response, DavResource resource)
The REBIND methodprotected void
doReport(WebdavRequest request, WebdavResponse response, DavResource resource)
The REPORT methodprotected void
doSearch(WebdavRequest request, WebdavResponse response, DavResource resource)
The SEARCH methodprotected void
doSubscribe(WebdavRequest request, WebdavResponse response, DavResource resource)
The SUBSCRIBE methodprotected void
doUnbind(WebdavRequest request, WebdavResponse response, DavResource resource)
The UNBIND methodprotected void
doUncheckout(WebdavRequest request, WebdavResponse response, DavResource resource)
The UNCHECKOUT methodprotected void
doUnlock(WebdavRequest request, WebdavResponse response, DavResource resource)
The UNLOCK methodprotected void
doUnsubscribe(WebdavRequest request, WebdavResponse response, DavResource resource)
The UNSUBSCRIBE methodprotected void
doUpdate(WebdavRequest request, WebdavResponse response, DavResource resource)
The UPDATE methodprotected void
doVersionControl(WebdavRequest request, WebdavResponse response, DavResource resource)
The VERSION-CONTROL methodprotected boolean
execute(WebdavRequest request, WebdavResponse response, int method, DavResource resource)
Executes the respective method in the given webdav contextString
getAuthenticateHeaderValue()
Returns the value of the 'WWW-Authenticate' header, that is returned in case of 401 error: the value is retrireved from the corresponding init param or defaults toDEFAULT_AUTHENTICATE_HEADER
.static List<String>
getContentCodings(javax.servlet.http.HttpServletRequest request)
Obtain the (ordered!) list of content codings that have been used in the requestabstract DavSessionProvider
getDavSessionProvider()
Returns theDavSessionProvider
.protected InputContext
getInputContext(DavServletRequest request, InputStream in)
Return a newInputContext
used for adding resource membersabstract DavLocatorFactory
getLocatorFactory()
Returns theDavLocatorFactory
.protected OutputContext
getOutputContext(DavServletResponse response, OutputStream out)
Return a newOutputContext
used for spooling resource properties and the resource contentabstract DavResourceFactory
getResourceFactory()
Returns theDavResourceFactory
.protected static String
getSingletonField(javax.servlet.http.HttpServletRequest request, String fieldName)
Get field value of a singleton fieldvoid
init()
protected boolean
isCreateAbsoluteURI()
Returns if a absolute URI should be created for hrefs.protected abstract boolean
isPreconditionValid(WebdavRequest request, DavResource resource)
Checks if the precondition for this request and resource is valid.protected void
sendUnauthorized(WebdavRequest request, WebdavResponse response, DavException error)
Sets the "WWW-Authenticate" header and writes the appropriate error to the given webdav response.protected void
service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Service the given request.abstract void
setDavSessionProvider(DavSessionProvider davSessionProvider)
Returns theDavSessionProvider
.abstract void
setLocatorFactory(DavLocatorFactory locatorFactory)
Sets theDavLocatorFactory
.abstract void
setResourceFactory(DavResourceFactory resourceFactory)
Sets theDavResourceFactory
.protected int
validateDestination(DavResource destResource, WebdavRequest request, boolean checkHeader)
Validate the given destination resource and return the proper status code: Any return value greater/equal thanHttpServletResponse.SC_NO_CONTENT
indicates an error.-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
-
-
-
-
Field Detail
-
INIT_PARAM_MISSING_AUTH_MAPPING
public static final String INIT_PARAM_MISSING_AUTH_MAPPING
the 'missing-auth-mapping' init parameter- See Also:
- Constant Field Values
-
INIT_PARAM_AUTHENTICATE_HEADER
public static final String INIT_PARAM_AUTHENTICATE_HEADER
Name of the optional init parameter that defines the value of the 'WWW-Authenticate' header.If the parameter is omitted the default value
"Basic Realm=Jackrabbit Webdav Server"
is used.
-
DEFAULT_AUTHENTICATE_HEADER
public static final String DEFAULT_AUTHENTICATE_HEADER
Default value for the 'WWW-Authenticate' header, that is set, if request results in a401 (Unauthorized)
error.
-
INIT_PARAM_CSRF_PROTECTION
public static final String INIT_PARAM_CSRF_PROTECTION
Name of the parameter that specifies the configuration of the CSRF protection. May contain a comma-separated list of allowed referrer hosts. If the parameter is omitted or left empty the behaviour is to only allow requests which have an empty referrer or a referrer host equal to the server host. If the parameter is set to 'disabled' no referrer checks will be performed at all.- See Also:
- Constant Field Values
-
INIT_PARAM_CREATE_ABSOLUTE_URI
public static final String INIT_PARAM_CREATE_ABSOLUTE_URI
Name of the 'createAbsoluteURI' init parameter that defines whether hrefs should be created with a absolute URI or as absolute Path (ContextPath). The value should be 'true' or 'false'. The default value if not set is true.- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init() throws javax.servlet.ServletException
- Overrides:
init
in classjavax.servlet.GenericServlet
- Throws:
javax.servlet.ServletException
-
isPreconditionValid
protected abstract boolean isPreconditionValid(WebdavRequest request, DavResource resource)
Checks if the precondition for this request and resource is valid.- Parameters:
request
-resource
-- Returns:
-
getDavSessionProvider
public abstract DavSessionProvider getDavSessionProvider()
Returns theDavSessionProvider
.- Returns:
- the session provider
-
setDavSessionProvider
public abstract void setDavSessionProvider(DavSessionProvider davSessionProvider)
Returns theDavSessionProvider
.- Parameters:
davSessionProvider
-
-
getLocatorFactory
public abstract DavLocatorFactory getLocatorFactory()
Returns theDavLocatorFactory
.- Returns:
- the locator factory
-
setLocatorFactory
public abstract void setLocatorFactory(DavLocatorFactory locatorFactory)
Sets theDavLocatorFactory
.- Parameters:
locatorFactory
-
-
getResourceFactory
public abstract DavResourceFactory getResourceFactory()
Returns theDavResourceFactory
.- Returns:
- the resource factory
-
setResourceFactory
public abstract void setResourceFactory(DavResourceFactory resourceFactory)
Sets theDavResourceFactory
.- Parameters:
resourceFactory
-
-
getAuthenticateHeaderValue
public String getAuthenticateHeaderValue()
Returns the value of the 'WWW-Authenticate' header, that is returned in case of 401 error: the value is retrireved from the corresponding init param or defaults toDEFAULT_AUTHENTICATE_HEADER
.- Returns:
- corresponding init parameter or
DEFAULT_AUTHENTICATE_HEADER
. - See Also:
INIT_PARAM_AUTHENTICATE_HEADER
-
isCreateAbsoluteURI
protected boolean isCreateAbsoluteURI()
Returns if a absolute URI should be created for hrefs.- Returns:
- absolute URI hrefs
-
service
protected void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
Service the given request.- Overrides:
service
in classjavax.servlet.http.HttpServlet
- Parameters:
request
-response
-- Throws:
javax.servlet.ServletException
IOException
-
sendUnauthorized
protected void sendUnauthorized(WebdavRequest request, WebdavResponse response, DavException error) throws IOException
Sets the "WWW-Authenticate" header and writes the appropriate error to the given webdav response.- Parameters:
request
- The webdav request.response
- The webdav response.error
- The DavException that leads to the unauthorized response.- Throws:
IOException
-
execute
protected boolean execute(WebdavRequest request, WebdavResponse response, int method, DavResource resource) throws javax.servlet.ServletException, IOException, DavException
Executes the respective method in the given webdav context- Parameters:
request
-response
-method
-resource
-- Throws:
javax.servlet.ServletException
IOException
DavException
-
doOptions
protected void doOptions(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The OPTION method- Parameters:
request
-response
-resource
-- Throws:
IOException
DavException
-
doHead
protected void doHead(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException
The HEAD method- Parameters:
request
-response
-resource
-- Throws:
IOException
-
doGet
protected void doGet(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The GET method- Parameters:
request
-response
-resource
-- Throws:
IOException
DavException
-
doPropFind
protected void doPropFind(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The PROPFIND method- Parameters:
request
-response
-resource
-- Throws:
IOException
DavException
-
doPropPatch
protected void doPropPatch(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The PROPPATCH method- Parameters:
request
-response
-resource
-- Throws:
IOException
DavException
-
doPost
protected void doPost(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The POST method. Delegate to PUT- Parameters:
request
-response
-resource
-- Throws:
IOException
DavException
-
doPut
protected void doPut(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The PUT method- Parameters:
request
-response
-resource
-- Throws:
IOException
DavException
-
doMkCol
protected void doMkCol(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The MKCOL method- Parameters:
request
-response
-resource
-- Throws:
IOException
DavException
-
doDelete
protected void doDelete(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The DELETE method- Parameters:
request
-response
-resource
-- Throws:
IOException
DavException
-
doCopy
protected void doCopy(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The COPY method- Parameters:
request
-response
-resource
-- Throws:
IOException
DavException
-
doMove
protected void doMove(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The MOVE method- Parameters:
request
-response
-resource
-- Throws:
IOException
DavException
-
doBind
protected void doBind(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The BIND method- Parameters:
request
-response
-resource
- the collection resource to which a new member will be added- Throws:
IOException
DavException
-
doRebind
protected void doRebind(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The REBIND method- Parameters:
request
-response
-resource
- the collection resource to which a new member will be added- Throws:
IOException
DavException
-
doUnbind
protected void doUnbind(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The UNBIND method- Parameters:
request
-response
-resource
- the collection resource from which a member will be removed- Throws:
IOException
DavException
-
validateDestination
protected int validateDestination(DavResource destResource, WebdavRequest request, boolean checkHeader) throws DavException
Validate the given destination resource and return the proper status code: Any return value greater/equal thanHttpServletResponse.SC_NO_CONTENT
indicates an error.- Parameters:
destResource
- destination resource to be validated.request
-checkHeader
- flag indicating if the destination header must be present.- Returns:
- status code indicating whether the destination is valid.
- Throws:
DavException
-
doLock
protected void doLock(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The LOCK method- Parameters:
request
-response
-resource
-- Throws:
IOException
DavException
-
doUnlock
protected void doUnlock(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException
The UNLOCK method- Parameters:
request
-response
-resource
-- Throws:
DavException
-
doOrderPatch
protected void doOrderPatch(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The ORDERPATCH method- Parameters:
request
-response
-resource
-- Throws:
IOException
DavException
-
doSubscribe
protected void doSubscribe(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The SUBSCRIBE method- Parameters:
request
-response
-resource
-- Throws:
IOException
DavException
-
doUnsubscribe
protected void doUnsubscribe(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The UNSUBSCRIBE method- Parameters:
request
-response
-resource
-- Throws:
IOException
DavException
-
doPoll
protected void doPoll(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException
The POLL method- Parameters:
request
-response
-resource
-- Throws:
IOException
DavException
-
doVersionControl
protected void doVersionControl(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException
The VERSION-CONTROL method- Parameters:
request
-response
-resource
-- Throws:
DavException
IOException
-
doLabel
protected void doLabel(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException
The LABEL method- Parameters:
request
-response
-resource
-- Throws:
DavException
IOException
-
doReport
protected void doReport(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException
The REPORT method- Parameters:
request
-response
-resource
-- Throws:
DavException
IOException
-
doCheckin
protected void doCheckin(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException
The CHECKIN method- Parameters:
request
-response
-resource
-- Throws:
DavException
IOException
-
doCheckout
protected void doCheckout(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException
The CHECKOUT method- Parameters:
request
-response
-resource
-- Throws:
DavException
IOException
-
doUncheckout
protected void doUncheckout(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException
The UNCHECKOUT method- Parameters:
request
-response
-resource
-- Throws:
DavException
IOException
-
doMerge
protected void doMerge(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException
The MERGE method- Parameters:
request
-response
-resource
-- Throws:
DavException
IOException
-
doUpdate
protected void doUpdate(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException
The UPDATE method- Parameters:
request
-response
-resource
-- Throws:
DavException
IOException
-
doMkWorkspace
protected void doMkWorkspace(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException
The MKWORKSPACE method- Parameters:
request
-response
-resource
-- Throws:
DavException
IOException
-
doMkActivity
protected void doMkActivity(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException
The MKACTIVITY method- Parameters:
request
-response
-resource
-- Throws:
DavException
IOException
-
doBaselineControl
protected void doBaselineControl(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException
The BASELINECONTROL method- Parameters:
request
-response
-resource
-- Throws:
DavException
IOException
-
doSearch
protected void doSearch(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException
The SEARCH method- Parameters:
request
-response
-resource
-- Throws:
DavException
IOException
-
doAcl
protected void doAcl(WebdavRequest request, WebdavResponse response, DavResource resource) throws DavException, IOException
The ACL method- Parameters:
request
-response
-resource
-- Throws:
DavException
IOException
-
getInputContext
protected InputContext getInputContext(DavServletRequest request, InputStream in)
Return a newInputContext
used for adding resource members- Parameters:
request
-in
-- Returns:
- See Also:
spoolResource(WebdavRequest, WebdavResponse, DavResource, boolean)
-
getOutputContext
protected OutputContext getOutputContext(DavServletResponse response, OutputStream out)
Return a newOutputContext
used for spooling resource properties and the resource content- Parameters:
response
-out
-- Returns:
- See Also:
doPut(WebdavRequest, WebdavResponse, DavResource)
,doMkCol(WebdavRequest, WebdavResponse, DavResource)
-
getContentCodings
public static List<String> getContentCodings(javax.servlet.http.HttpServletRequest request)
Obtain the (ordered!) list of content codings that have been used in the request
-
getSingletonField
protected static String getSingletonField(javax.servlet.http.HttpServletRequest request, String fieldName)
Get field value of a singleton field- Parameters:
request
- HTTP requestfieldName
- field name- Returns:
- the field value (when there is indeed a single field line) or
null
when field not present - Throws:
IllegalArgumentException
- when multiple field lines present
-
-