To enable WebDav in the Enterprise Server, you edit the web.xml and sun-web.xml files as follows.
First, enable the WebDav servlet in your web.xml file:
<servlet>
<servlet-name>webdav</servlet-name>
<servlet-class>org.apache.catalina.servlets.WebdavServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>readonly</param-name>
<param-value>false</param-value>
</init-param>
</servlet>
Then define the servlet mapping associated with your WebDav servlet in your web.xml file:
<servlet-mapping> <servlet-name>webdav</servlet-name> <url-pattern>/webdav/*</url-pattern> </servlet-mapping>
To protect the WebDav servlet so other users can't modify it, add a security constraint in your web.xml file:
<security-constraint>
<web-resource-collection>
<web-resource-name>Login Resources</web-resource-name>
<url-pattern>/webdav/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>Admin</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>default</realm-name>
</login-config>
<security-role>
<role-name>Admin</role-name>
</security-role>
</security-constraint>
Then define a security role mapping in your sun-web.xml file:
<security-role-mapping> <role-name>Admin</role-name> <group-name>Admin</group-name> </security-role-mapping>
If you are using the file realm, create a user and password. For example:
asadmin create-file-user --user admin --host localhost --port 4848 --terse=true --groups Admin --authrealmname default admin |
You can now use any WebDav client by connecting to the WebDav servlet URL, which has this format:
http://host:port/context-root/webdav/file |
For example:
http://localhost:80/glassfish-webdav/webdav/index.html |
You can add the WebDav servlet to your default-web.xml file to enable it for all applications, but you can't set up a security role mapping to protect it.