Enabling WebDav in GlassFish
Posted by jfarcand on March 20, 2006 at 12:06 PM | Comments (4)
It is very easy to enable WebDav in GlassFish, but you can't enable it the way you usualy do it using Tomcat. The reason is when you define, in defaul-web.xml, the WebDav servlet, you can't protect it because GlassFish lack of support for a default-sun-web.xml, where you usualy define your security constraints mapping. You certainly don't want to enable WebDav without protecting the functionality with a security constraint, because if not protected, then everybody will be able to make modification to your content.
First, enable the WebDav Servlet in your web-xml:
<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:
<servlet-mapping>
<servlet-name>webdav</servlet-name>
<url-pattern>/webdav/*</url-pattern>
</servlet-mapping>
You are now ready to use any WebDav client by doing connecting to:
http://host:port/<>/webdav/file
As an example, I did using Office 2003:
File > Open > http://192.168.0.101:8080/glassfish-webday/webdav/index.html
and changed the index.html page. Next step is to protect the WebDav support because everybody can now make modifications to your content:
<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>
and then define, in your sun-web.xml:
<security-role-mapping>
<role-name>Admin</role-name>
<group-name>Admin</group-name>
</security-role-mapping>
Next, create you user and password.
asadmin create-file-user --user admin --host localhost --port 4848 --terse=true --groups Admin --authrealmname default admin
You are now ready to use WebDav with GlassFish
technorati: grizzly webdav glassfish
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
this is great, as a glassfish newbie, can you (kindly) elaborate on all the steps needed to get webdav support enabled on Glassfish? I'm running Sun App Server PE 9 and I don't quite understand the steps on how to deploy the WebDAV support to the server. Much appreciated in advance.
Posted by: jakemono on January 30, 2007 at 07:11 AM
-
ah, never mind, I figured it out...
Posted by: jakemono on January 31, 2007 at 01:20 PM
-
Hi jakemono...happy to lean it worked. Let me know if you face any issue with the WebDav implementation.
Posted by: jfarcand on February 07, 2007 at 01:12 PM
-
Does webdavservelet already come as part of glassfish? Do I simply make up a WAR file with these descriptors in it and no implmenetation classes? Or is there something I need to package up?
Posted by: pmurray_bigpond on November 03, 2007 at 05:31 PM
|