You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:47:29 UTC
[sling-org-apache-sling-jcr-davex] 25/44: SLING-2274 Never require
authentication from the DavEx servlet but support any credentials coming
along
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.davex-1.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-davex.git
commit 8846875a05a7ef8e5d861c4c0852d56be04df976
Author: Felix Meschberger <fm...@apache.org>
AuthorDate: Wed Nov 9 09:02:58 2011 +0000
SLING-2274 Never require authentication from the DavEx servlet but support any credentials coming along
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/davex@1199665 13f79535-47bb-0310-9956-ffa450edef68
---
.../jcr/davex/impl/servlets/SlingDavExServlet.java | 36 ++++++++++++++++++++--
1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java b/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java
index 8e925bb..44664c0 100644
--- a/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java
+++ b/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java
@@ -19,6 +19,7 @@ package org.apache.sling.jcr.davex.impl.servlets;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Map;
+
import javax.jcr.Credentials;
import javax.jcr.LoginException;
import javax.jcr.Repository;
@@ -40,6 +41,9 @@ import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.auth.core.AuthenticationSupport;
import org.apache.sling.commons.osgi.OsgiUtil;
import org.apache.sling.settings.SlingSettingsService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
import org.osgi.service.http.HttpService;
import org.slf4j.LoggerFactory;
@@ -50,8 +54,8 @@ import org.slf4j.LoggerFactory;
*/
@SuppressWarnings("serial")
@Component(metatype = true, label = "%dav.name", description = "%dav.description")
-@Properties({ @Property(name = "service.description", value = "Sling JcrRemoting Servlet"),
- @Property(name = "service.vendor", value = "The Apache Software Foundation") })
+@Properties({ @Property(name = Constants.SERVICE_DESCRIPTION, value = "Sling JcrRemoting Servlet"),
+ @Property(name = Constants.SERVICE_VENDOR, value = "The Apache Software Foundation") })
public class SlingDavExServlet extends JcrRemotingServlet {
/**
@@ -66,6 +70,12 @@ public class SlingDavExServlet extends JcrRemotingServlet {
@Property(value=DEFAULT_ALIAS)
private static final String PROP_ALIAS = "alias";
+ /**
+ * The name of the service property of the registered dummy service to cause
+ * the path to the DavEx servlet to not be subject to forced authentication.
+ */
+ private static final String PAR_AUTH_REQ = "sling.auth.requirements";
+
@Reference
private Repository repository;
@@ -86,8 +96,16 @@ public class SlingDavExServlet extends JcrRemotingServlet {
*/
private String servletAlias;
+ /**
+ * The dummy service registration to convey to the Sling Authenticator
+ * that everything under the alias must not be forcibly authenticated.
+ * This will be <code>null</code> if the DavEx servlet registration
+ * fails.
+ */
+ private ServiceRegistration dummyService;
+
@Activate
- protected void activate(final Map<String, ?> config) {
+ protected void activate(final BundleContext bundleContext, final Map<String, ?> config) {
final AuthHttpContext context = new AuthHttpContext();
context.setAuthenticationSupport(authSupport);
@@ -110,6 +128,13 @@ public class SlingDavExServlet extends JcrRemotingServlet {
try {
this.httpService.registerServlet(alias, this, initProps, context);
this.servletAlias = alias;
+
+ java.util.Properties dummyServiceProperties = new java.util.Properties();
+ dummyServiceProperties.put(Constants.SERVICE_VENDOR, config.get(Constants.SERVICE_VENDOR));
+ dummyServiceProperties.put(Constants.SERVICE_DESCRIPTION,
+ "Helper for " + config.get(Constants.SERVICE_DESCRIPTION));
+ dummyServiceProperties.put(PAR_AUTH_REQ, "-" + alias);
+ this.dummyService = bundleContext.registerService("java.lang.Object", new Object(), dummyServiceProperties);
} catch (Exception e) {
LoggerFactory.getLogger(getClass()).error("activate: Failed registering DavEx Servlet at " + alias, e);
}
@@ -117,6 +142,11 @@ public class SlingDavExServlet extends JcrRemotingServlet {
@Deactivate
protected void deactivate() {
+ if (this.dummyService != null) {
+ this.dummyService.unregister();
+ this.dummyService = null;
+ }
+
if (this.servletAlias != null) {
this.httpService.unregister(servletAlias);
this.servletAlias = null;
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.