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 10:14:17 UTC
[sling-org-apache-sling-security] 04/11: SLING-5942 : Use http
whiteboard for filter registration
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.security-1.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-security.git
commit 9d6aac028bddf72ca9ae9ee7202bc11e5e69ffda
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Aug 2 12:19:00 2016 +0000
SLING-5942 : Use http whiteboard for filter registration
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/security@1754896 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 25 +++++++++++++++-------
.../apache/sling/security/impl/ReferrerFilter.java | 16 +++++++++-----
2 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/pom.xml b/pom.xml
index b05b3bd..feb0a7d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,6 +65,9 @@
<Private-Package>
org.apache.sling.security.impl
</Private-Package>
+ <Require-Capability>
+ osgi.implementation;filter:="(&(osgi.implementation=osgi.http)(version=1.0))"
+ </Require-Capability>
</instructions>
</configuration>
</plugin>
@@ -73,6 +76,20 @@
<dependencies>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.http.whiteboard</artifactId>
+ <version>1.0.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
<version>2.1.0</version>
@@ -85,14 +102,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.core</artifactId>
- </dependency>
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
diff --git a/src/main/java/org/apache/sling/security/impl/ReferrerFilter.java b/src/main/java/org/apache/sling/security/impl/ReferrerFilter.java
index 39870b4..063c2ac 100644
--- a/src/main/java/org/apache/sling/security/impl/ReferrerFilter.java
+++ b/src/main/java/org/apache/sling/security/impl/ReferrerFilter.java
@@ -48,6 +48,7 @@ import javax.servlet.http.HttpServletResponse;
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.PropertyUnbounded;
import org.apache.felix.scr.annotations.Service;
@@ -55,12 +56,17 @@ import org.apache.sling.commons.osgi.PropertiesUtil;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(metatype=true, description="%referrer.description",
label="%referrer.name")
-@Property(name="pattern", value="/.*", propertyPrivate=true)
+@Properties({
+ @Property(name=HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, value="/", propertyPrivate=true),
+ @Property(name=HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT,
+ value="(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=org.apache.sling)", propertyPrivate=true)
+})
@Service(value=Filter.class)
public class ReferrerFilter implements Filter {
@@ -123,7 +129,7 @@ public class ReferrerFilter implements Filter {
/** Methods to be filtered. */
private String[] filterMethods;
- private ServiceRegistration configPrinterRegistration;
+ private ServiceRegistration<Object> configPrinterRegistration;
/**
* Create a default list of referrers
@@ -201,7 +207,7 @@ public class ReferrerFilter implements Filter {
final Pattern pattern = Pattern.compile(regexp);
patterns.add(pattern);
} catch (final Exception e) {
- logger.warn("Unable to create Pattern from {} : {}", new String[]{regexp, e.getMessage()});
+ logger.warn("Unable to create Pattern from {} : {}", new Object[]{regexp, e.getMessage()});
}
}
return patterns.toArray(new Pattern[patterns.size()]);
@@ -241,7 +247,7 @@ public class ReferrerFilter implements Filter {
this.configPrinterRegistration.unregister();
}
- private ServiceRegistration registerConfigPrinter(BundleContext bundleContext) {
+ private ServiceRegistration<Object> registerConfigPrinter(BundleContext bundleContext) {
final ConfigurationPrinter cfgPrinter = new ConfigurationPrinter();
final Dictionary<String, String> serviceProps = new Hashtable<String, String>();
serviceProps.put(Constants.SERVICE_DESCRIPTION,
@@ -251,7 +257,7 @@ public class ReferrerFilter implements Filter {
serviceProps.put("felix.webconsole.title", "Sling Referrer Filter");
serviceProps.put("felix.webconsole.configprinter.modes", "always");
- return bundleContext.registerService(Object.class.getName(),
+ return bundleContext.registerService(Object.class,
cfgPrinter, serviceProps);
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.