Home > GlassFish > Enabling WebDav in GlassFish

Enabling WebDav in GlassFish

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:

_uacct = “UA-3111670-1”;
urchinTracker();

Categories: GlassFish
  1. October 15, 2012 at 9:35 am

    I think the admin of this web page is in fact working hard for his web site, because
    here every stuff is quality based information.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: