Spring Boot WebDAV Server Example with File System Back-end, Java

This sample provides a WebDAV server running on the Spring Boot framework. The WebDAV requests are processed in a dedicated context, while the rest of the website processes regular HTTP requests, serving web pages. Documents are being published from the file system with locks and custom attributed being stored in Alternating Data Streams (in case of NTFS) or in Extended Attributes (in case of Linux and macOS). 


  • Java 1.8.
  • NTFS, Ext4, Ext3 or any other file system which supports extended file attributes. You can find a complete list of file systems that support extended attributes here. To enable extended file attributes on Linux change fstab to look like: 
    /dev/sda1  /               ext4    errors=remount-ro,user_xattr   0       1

Running the sample

  1. Set license. Download your license file here. To set the license, edit the 'webdav.license' section in \springboot\src\main\resources\application.properties and specify the path to the license.lic file.
    The IT Hit Java WebDAV Server Library is fully functional and does not have any limitations. However, the trial period is limited to 1 month. After the trial period expires the Java WebDAV Server will stop working.
  2. Configure the storage folder. By default, this sample publishes documents from the springboot\src\main\resources\Storage folder. For the sake of configuration simplicity, documents are extracted from project resources during the first run. You can publish documents from any other folder specifying a path in the 'webdav.rootFolder' section in application.properties:
  3. Configure the application server. Here we will configure WebDAV server to run on the website root (http://server.com/DAV/). Setting is located in the 'webdav.rootContext' section in the \springboot\src\main\resources\application.properties.
    Note: While you can configure the WebDAV server to run on site non-root (for instance on http://server.com/DAV/) some WebDAV clients (such as some old versions or Mini-redirector, Microsoft Web Folders and MS Office 2007 and earlier) will fail to connect to non-root server. They submit configuration requests to server root and if they do not get the response they will not be able to connect. See also Making Microsoft Office to Work with WebDAV Server and Opening Microsoft Office Documents and Other Types of Files for Editing From a Web Page.
    This springboot sample supports those configuration requests and works properly on non-root context.
  4. Running the springboot sample. To start the sample, change directory to springboot and execute
    mvnw spring-boot:run

    If everything was set up properly you should see a sample page on the http://server.com/DAV/with a list of sample files and folders. Now connect to the server with any WebDAV client.

    If anything goes wrong please consult log usually located at springboot/log/engine.log.


This sample supports Anonymous access as well as MS-OFBA authentication against Azure ADBy default, this sample does not authenticate users and allows full anonymous access.

To enable the MS-OFBA, uncomment MS-OFBA settings block in the application.properties file of the sample.

## This is Azure security configuration section. 
## If you want to use Azure login - uncomment configurations bellow. 
# Specifies your Active Directory ID:
# Specifies your App Registration's Application ID:
# Specifies your App Registration's secret key:

To get these properties you must register new (or use existing) application under your Azure Active Directory. To register the new Azure AD application follow these steps:

  1. Navigate to Azure Active Directory -> App Registrations. Select New Registration.

    New application registration in Azure AD

  2. Enter the app name. You MUST also enter the Redirect URI. Confirm registration.

    Specify the Redirect URI.

  3. Open the newly created app registration.

    Copy the Application (client) ID and Directory (tenant) ID into settings.

    Copy the Application (client) ID and Directory (tenant) ID fields and paste them into client-id and tenant-id settings in the application.properties file.

  4. Navigate to Certificates & secrets. Select New client secret. Enter the secret name and confirm the client secret creation.

    Create new client secret

    Copy the newly created secret value and past it into client-secret setting in the application.properties file.

    Copy the newly created secret value and past it into client-secret setting.


After getting all data put it in properties file and run the sample. You will get Azure login screen on attemp to access WebDAV page. 

The Project Classes

On the diagram below you can see the classes in the WebDAV SpringBoot sample:

Class diagram of the sample Java WebDAV Server running on Spring Boot

To adapt the sample to your needs, you will modify these classes to read and write data from and into your storage. You can find more about this in Creating a Class 1 WebDAV Server and Creating Class 2 WebDAV Server article as well as in the class reference documentation.


See Also:


Next Article:

Spring Boot WebDAV Server Example with Oracle Back-end, Java