WebDAV VFS gate
This project implement WebDAV gateway for accessing to different file systems. The file systems access level is based on the Apache Commons VFS library. WebDAV protocol layer is based on Apache Jackrabbit library.
Supported features
- Available file systems of Apache Commons VFS (smb,ftp,sftp,http,webdav,zip,jar and other).
- WebDAV compatible with Windows Explorer, GVFS and davfs2.
- Server implemented as library (jar) and web application (war).
- Application ready for use in web containers, such as Tomcat, Jetty, JBoss and similar.
- Configuring file system from servlet initialization parameters and java properties.
- Audit log of file operations.
Initialization parameters
rootpath
- connection string for file system (see more example). Parameter must be specified.login
- connection login for file system, optional parameter.password
- connection password for file system, optional parameter.domain
- connection domain for file system, optional parameter.listings-directory
- boolean parameter, enables showing directory content as html page, by default istrue
.include-context-path
- boolean parameter, enables containing context path in resource path, by default istrue
.files-cache
- class full name of Apache VFS cache implementation, by default isorg.apache.commons.vfs2.cache.SoftRefFilesCache
.cache-strategy
- name of Apache VFS cache strategy, may take values:manual
,onresolve
oroncall
. By default isoncall
.builder
- class full name of Apache VFS file system config builder, specific to each file system, ex.: for FTP isorg.apache.commons.vfs2.provider.ftps.FtpsFileSystemConfigBuilder
.builder.<method_name>
- string parameter determine method name for invoke in instance of file system config builder. To call setters needs convert method name to property name, ex.: methodsetControlEncoding
must be converted tocontrolEncoding
. Value of parameter may be string, integer or boolean (see example in web.xml).logger-name
- name for servlet logger, by default iscom.github.alanger.webdav.VfsWebDavServlet
.audit-methods
- a comma-separated list of http methods for file operations audit logs, optional parameter.createAbsoluteURI
- boolean parameter, enables using an absolute URI instead of a relative, by default isfalse
.csrf-protection
- configuration of the CSRF protection, may contain a comma-separated list of allowed referrer hosts. By default isdisabled
.
Usage
Deploy webdav-vfs-gate-.war to servlets container (Tomcat, Jetty, JBoss or similar). Add servlet declarations to web.xml
(see documentation of servlet container).
Example for local file system:
<servlet>
<servlet-name>root</servlet-name>
<servlet-class>com.github.alanger.webdav.VfsWebDavServlet</servlet-class>
<init-param>
<param-name>rootpath</param-name>
<param-value>/path/to/filesystem/folder</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>root</servlet-name>
<url-pattern>/root/*</url-pattern>
</servlet-mapping>
Example for SMB file system with login and password in connection string:
<servlet>
<servlet-name>smb</servlet-name>
<servlet-class>com.github.alanger.webdav.VfsWebDavServlet</servlet-class>
<init-param>
<param-name>rootpath</param-name>
<param-value>smb://DOMAIN\mylogin:mypassword@hostname:445/path</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>smb</servlet-name>
<url-pattern>/smb/*</url-pattern>
</servlet-mapping>
Example for SMB file system with login and password in initialize parameters:
<servlet>
<servlet-name>smb</servlet-name>
<servlet-class>com.github.alanger.webdav.VfsWebDavServlet</servlet-class>
<init-param>
<param-name>rootpath</param-name>
<param-value>smb://hostname:445/path</param-value>
</init-param>
<init-param>
<param-name>domain</param-name>
<param-value>DOMAIN</param-value>
</init-param>
<init-param>
<param-name>login</param-name>
<param-value>mylogin</param-value>
</init-param>
<init-param>
<param-name>password</param-name>
<param-value>mypassword</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>smb</servlet-name>
<url-pattern>/smb/*</url-pattern>
</servlet-mapping>
Example for SMB file system with connection string from system properties:
-Dsmb.connection.string="smb://DOMAIN\mylogin:mypassword@hostname:445/path"
<servlet>
<servlet-name>smb</servlet-name>
<servlet-class>com.github.alanger.webdav.VfsWebDavServlet</servlet-class>
<init-param>
<param-name>rootpath</param-name>
<param-value>${smb.connection.string}</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>smb</servlet-name>
<url-pattern>/smb/*</url-pattern>
</servlet-mapping>
Example for file system with audit log of file operations:
-Dlogback.configurationFile=/path/to/config/logback.xml
<!-- In logback.xml -->
<logger name="com.github.alanger.webdav.my_audit_logger" level="INFO" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
<servlet>
<servlet-name>audit</servlet-name>
<servlet-class>com.github.alanger.webdav.VfsWebDavServlet</servlet-class>
<init-param>
<param-name>rootpath</param-name>
<param-value>/path/to/filesystem/folder</param-value>
</init-param>
<init-param>
<param-name>logger-name</param-name>
<param-value>com.github.alanger.webdav.my_audit_logger</param-value>
</init-param>
<init-param>
<param-name>audit-methods</param-name>
<param-value>GET,MKCOL,DELETE,COPY,MOVE,PUT,PROPPATH</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>audit</servlet-name>
<url-pattern>/audit/*</url-pattern>
</servlet-mapping>
Example for MIME types configuration (see content-types.properties file):
-Dcontent.types.user.table=/path/to/config/content-types.properties
More examples
Servlet configurations see in web.xml file.
File systems see in Apache Commons VFS documentation.
Logger configuration see in Logback documentation.
Getting the library using Maven
Add this dependency to your pom.xml
to reference the library:
<dependency>
<groupId>com.github.a-langer</groupId>
<artifactId>webdav-vfs-gate</artifactId>
<version>1.0.0</version>
<classifier>classes</classifier>
</dependency>
Related repositories
- tomcat-cache-realm - Cache to authentication realm in Tomcat.
- hazelcast-tomcat-sessionmanager - Hazelcast Tomcat Session Manager.
- tomcat-vault - Vault for Apache Tomcat.