Index: jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/DavexServletService.java =================================================================== --- jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/DavexServletService.java (revision 0) +++ jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/DavexServletService.java (revision 0) @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.jackrabbit.server.remoting.davex; + +import java.util.Hashtable; +import java.util.Map; + +import javax.jcr.Repository; + +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Properties; +import org.apache.felix.scr.annotations.Property; +import org.apache.felix.scr.annotations.Reference; +import org.apache.jackrabbit.webdav.server.AbstractWebdavServlet; +import org.apache.jackrabbit.webdav.util.CSRFUtil; +import org.osgi.service.http.HttpService; +import org.slf4j.LoggerFactory; + +@Component(metatype = true, label = "%dav.name", description = "%dav.description") +@Properties({ + @Property(name = "service.description", value = "Apache Jackrabbit JcrRemoting Servlet"), + @Property(name = JcrRemotingServlet.INIT_PARAM_AUTHENTICATE_HEADER, value = AbstractWebdavServlet.DEFAULT_AUTHENTICATE_HEADER), + @Property(name = JcrRemotingServlet.INIT_PARAM_CSRF_PROTECTION, value = CSRFUtil.DISABLED), + @Property(name = JcrRemotingServlet.INIT_PARAM_MISSING_AUTH_MAPPING, value = "") }) +public class DavexServletService extends JcrRemotingServlet { + + /** Serial version UID */ + private static final long serialVersionUID = -8588285209666835376L; + + private static final String DEFAULT_ALIAS = "/server"; + + @Property(value = DEFAULT_ALIAS) + private static final String PARAM_ALIAS = "alias"; + + @Reference + private Repository repository; + + @Reference + private HttpService httpService; + + private String alias; + + @Override + protected Repository getRepository() { + return repository; + } + + @SuppressWarnings("unused") + @Activate + private void activate(Map config) { + String alias; + Object aliasPar = config.get(PARAM_ALIAS); + if (aliasPar == null) { + alias = DEFAULT_ALIAS; + } else { + alias = aliasPar.toString(); + if (alias.length() == 0) { + alias = DEFAULT_ALIAS; + } + } + + Hashtable initparams = new Hashtable(config); + initparams.remove(PARAM_ALIAS); + + try { + this.httpService.registerServlet(alias, this, initparams, null); + this.alias = alias; + } catch (Exception e) { + LoggerFactory.getLogger(getClass()).error("activate: Failed registering DavEx Servlet at " + alias, e); + } + } + + @SuppressWarnings("unused") + @Deactivate + private void deactivate() { + if (this.alias != null) { + this.httpService.unregister(alias); + this.alias = null; + } + } + +} Index: jackrabbit-jcr-server/src/main/resources/OSGI-INF/metatype/metatype.properties =================================================================== --- jackrabbit-jcr-server/src/main/resources/OSGI-INF/metatype/metatype.properties (revision 0) +++ jackrabbit-jcr-server/src/main/resources/OSGI-INF/metatype/metatype.properties (revision 0) @@ -0,0 +1,58 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + + +# +# This file contains localization strings for configuration labels and +# descriptions as used in the metatype.xml descriptor generated by the +# the SCR plugin + +dav.name = Apache Jackrabbit DavEx Servlet +dav.description = The DavEx Servlet allows direct access to the \ + complete Repository. + +alias.name = Root Path +alias.description = The root path at which the DavEx Servlet is \ + accessible. The default value is "/server". + +missing-auth-mapping.name = Missing Credentials Handling +missing-auth-mapping.description = Defines how a missing authorization \ + header should be handled. If this property is missing, a 401 response \ + is generated. This is suiteable for clients (eg. webdav clients) for \ + which sending a proper authorization header is not possible if the \ + server never sent a 401. If this property is present with an empty \ + value, null-credentials are returned, thus forcing an null login \ + on the repository. If this propert is present with the value \ + 'guestcredentials' java.jcr.GuestCredentials are used to login to the \ + repository. If this property has a 'user:password' value, the \ + respective simple credentials are generated. + +authenticate-header.name = Realm> +authenticate-header.description = Defines the value of the \ + 'WWW-Authenticate' header. Default is 'Basic realm="Jackrabbit Webdav Server"'. + +csrf-protection.name = CSRF Protection +csrf-protection.description = Configuration of referrer based CSRF \ + protection. If config is not configured or empty string the default \ + behaviour is to allow only requests with an empty referrer header or a \ + referrer host equal to the server host. A comma separated list of \ + additional allowed referrer hosts which are valid in addition to default \ + behaviour (see above). The value "disabled" may be used to disable the \ + referrer checking altogether. The default is "disabled" assuming that \ + a site-wide CSRF protection filter is installed. Index: jackrabbit-jcr-server/pom.xml =================================================================== --- jackrabbit-jcr-server/pom.xml (revision 1064620) +++ jackrabbit-jcr-server/pom.xml (working copy) @@ -32,6 +32,7 @@ jackrabbit-jcr-server Jackrabbit JCR Server WebDAV server implementations for JCR + bundle @@ -45,6 +46,41 @@ -Xmx128m -enableassertions + + org.apache.felix + maven-scr-plugin + 1.7.2 + + + generate-scr-scrdescriptor + + scr + + + + The Apache Software Foundation + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + + !* + + + org.apache.jackrabbit.server.*, + org.apache.jackrabbit.webdav.jcr.*, + org.apache.jackrabbit.webdav.simple + + + + @@ -120,7 +156,22 @@ commons-fileupload commons-fileupload + + + org.osgi + org.osgi.compendium + 4.0.0 + provided + + + org.apache.felix + org.apache.felix.scr.annotations + 1.6.0 + provided + + + junit junit test Index: jackrabbit-webdav/pom.xml =================================================================== --- jackrabbit-webdav/pom.xml (revision 1199817) +++ jackrabbit-webdav/pom.xml (working copy) @@ -32,6 +32,7 @@ jackrabbit-webdav Jackrabbit WebDAV Library Generic WebDAV Library + bundle @@ -45,6 +46,11 @@ -Xmx128m -enableassertions + + org.apache.felix + maven-bundle-plugin + true +