com.github.a-langer:webdav-vfs-gate

WebDAV gateway for accessing to different file systems

License

License

GroupId

GroupId

com.github.a-langer
ArtifactId

ArtifactId

webdav-vfs-gate
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

war
Description

Description

com.github.a-langer:webdav-vfs-gate
WebDAV gateway for accessing to different file systems
Project URL

Project URL

https://github.com/a-langer/webdav-vfs-gate
Source Code Management

Source Code Management

https://github.com/a-langer/webdav-vfs-gate

Download webdav-vfs-gate

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.a-langer/webdav-vfs-gate/ -->
<dependency>
    <groupId>com.github.a-langer</groupId>
    <artifactId>webdav-vfs-gate</artifactId>
    <version>1.0.0</version>
    <type>war</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.a-langer/webdav-vfs-gate/
implementation 'com.github.a-langer:webdav-vfs-gate:1.0.0'
// https://jarcasting.com/artifacts/com.github.a-langer/webdav-vfs-gate/
implementation ("com.github.a-langer:webdav-vfs-gate:1.0.0")
'com.github.a-langer:webdav-vfs-gate:war:1.0.0'
<dependency org="com.github.a-langer" name="webdav-vfs-gate" rev="1.0.0">
  <artifact name="webdav-vfs-gate" type="war" />
</dependency>
@Grapes(
@Grab(group='com.github.a-langer', module='webdav-vfs-gate', version='1.0.0')
)
libraryDependencies += "com.github.a-langer" % "webdav-vfs-gate" % "1.0.0"
[com.github.a-langer/webdav-vfs-gate "1.0.0"]

Dependencies

compile (9)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.2.3
org.apache.commons : commons-vfs2 jar 2.6.0
org.apache.jackrabbit : jackrabbit-webdav jar 2.21.0
org.apache.commons : commons-vfs2-jackrabbit2 jar 2.6.0
org.apache.httpcomponents : httpclient jar 4.5.11
commons-net : commons-net jar 3.6
com.jcraft : jsch jar 0.1.55
com.github.vbauer » commons-vfs2-cifs jar 1.2.0
org.codelibs : jcifs jar 1.3.18.3

provided (1)

Group / Artifact Type Version
javax.servlet : javax.servlet-api jar 3.1.0

test (5)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-engine jar 5.6.2
org.junit.vintage : junit-vintage-engine jar 5.6.2
org.mockito : mockito-core jar 3.3.3
org.springframework : spring-test jar 5.2.6.RELEASE
org.springframework : spring-web jar 5.2.6.RELEASE

Project Modules

There are no modules declared in this project.

Build Status license Maven JitPack Maven Central

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 is true.
  • include-context-path - boolean parameter, enables containing context path in resource path, by default is true.
  • files-cache - class full name of Apache VFS cache implementation, by default is org.apache.commons.vfs2.cache.SoftRefFilesCache.
  • cache-strategy - name of Apache VFS cache strategy, may take values: manual, onresolve or oncall. By default is oncall.
  • builder - class full name of Apache VFS file system config builder, specific to each file system, ex.: for FTP is org.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.: method setControlEncoding must be converted to controlEncoding. Value of parameter may be string, integer or boolean (see example in web.xml).
  • logger-name - name for servlet logger, by default is com.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 is false.
  • csrf-protection - configuration of the CSRF protection, may contain a comma-separated list of allowed referrer hosts. By default is disabled.

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

Versions

Version
1.0.0