diff --git a/main/core/src/main/java/org/cryptomator/webdav/WebDavServer.java b/main/core/src/main/java/org/cryptomator/webdav/WebDavServer.java index d70daf00a..cabfb0b38 100644 --- a/main/core/src/main/java/org/cryptomator/webdav/WebDavServer.java +++ b/main/core/src/main/java/org/cryptomator/webdav/WebDavServer.java @@ -54,6 +54,11 @@ public final class WebDavServer { localConnector = new ServerConnector(server); localConnector.setHost(LOCALHOST); servletCollection = new ContextHandlerCollection(); + + final ServletContextHandler servletContext = new ServletContextHandler(servletCollection, "/", ServletContextHandler.NO_SESSIONS); + final ServletHolder servlet = new ServletHolder(WindowsSucksServlet.class); + servletContext.addServlet(servlet, "/"); + server.setConnectors(new Connector[] {localConnector}); server.setHandler(servletCollection); } @@ -82,15 +87,16 @@ public final class WebDavServer { /** * @param workDir Path of encrypted folder. * @param cryptor A fully initialized cryptor instance ready to en- or decrypt streams. - * @param name The name of the folder. Must be non-empty and only contain any of _ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 + * @param name The name of the folder. Must be non-empty and only contain any of + * _ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 * @return servlet */ public ServletLifeCycleAdapter createServlet(final Path workDir, final boolean checkFileIntegrity, final Cryptor cryptor, String name) { try { - if(StringUtils.isEmpty(name)) { + if (StringUtils.isEmpty(name)) { throw new IllegalArgumentException("name empty"); } - if(!StringUtils.containsOnly(name, "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")) { + if (!StringUtils.containsOnly(name, "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")) { throw new IllegalArgumentException("name contains illegal characters: " + name); } final URI uri = new URI(null, null, localConnector.getHost(), localConnector.getLocalPort(), "/" + UUID.randomUUID().toString() + "/" + name, null, null); diff --git a/main/core/src/main/java/org/cryptomator/webdav/WindowsSucksServlet.java b/main/core/src/main/java/org/cryptomator/webdav/WindowsSucksServlet.java new file mode 100644 index 000000000..06d9e2497 --- /dev/null +++ b/main/core/src/main/java/org/cryptomator/webdav/WindowsSucksServlet.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2014 Sebastian Stenzel + * This file is licensed under the terms of the MIT license. + * See the LICENSE.txt file for more info. + * + * Contributors: + * Sebastian Stenzel - initial API and implementation + ******************************************************************************/ +package org.cryptomator.webdav; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Windows mount attempts will fail, if not all requests on parent paths of a WebDAV resource get served. This servlet will respond to any + * request with status code 200, if the requested resource doesn't match a different servlet. + */ +public class WindowsSucksServlet extends HttpServlet { + + private static final long serialVersionUID = -515280795196074354L; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + resp.setStatus(HttpServletResponse.SC_OK); + } + +} \ No newline at end of file