Publish AAAShiroFilter as a proper Filter service 31/100931/11
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 2 May 2022 20:38:44 +0000 (22:38 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 1 Jun 2022 00:08:09 +0000 (02:08 +0200)
We do not really need WebContextSecurer to address these paths. Also add
@WebFilter annotation so the filter works without web.xml.

Change-Id: Ie4258f2533e6eaa104ae2de0f2866e9ad04a10b2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/filters/AAAShiroFilter.java

index 0045a2ddccdd22dea09828929383c33601e50474..a7da6c21b547987789da44f05654a7cd317a1ac9 100644 (file)
@@ -8,7 +8,15 @@
 
 package org.opendaylight.aaa.shiro.filters;
 
+import javax.servlet.Filter;
+import javax.servlet.annotation.WebFilter;
 import org.apache.shiro.web.servlet.ShiroFilter;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.ServiceScope;
+import org.osgi.service.http.whiteboard.annotations.RequireHttpWhiteboard;
+import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardFilterAsyncSupported;
+import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardFilterName;
+import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardFilterPattern;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -25,11 +33,16 @@ import org.slf4j.LoggerFactory;
  *
  * <code>log:set DEBUG AAAShiroFilter</code>
  *
- * @see <code>javax.servlet.Filter</code>
- * @see <code>org.apache.shiro.web.servlet.ShiroFilter</code>
+ * @see javax.servlet.Filter
+ * @see ShiroFilter
  */
-public class AAAShiroFilter extends ShiroFilter {
-
+@WebFilter(urlPatterns = "/*", filterName = "AAAShiroFilter")
+@HttpWhiteboardFilterAsyncSupported
+@HttpWhiteboardFilterPattern("/*")
+@HttpWhiteboardFilterName("AAAShiroFilter")
+@RequireHttpWhiteboard
+@Component(service = Filter.class, scope = ServiceScope.PROTOTYPE)
+public final class AAAShiroFilter extends ShiroFilter {
     private static final Logger LOG = LoggerFactory.getLogger(AAAShiroFilter.class);
 
     public AAAShiroFilter() {
@@ -41,11 +54,11 @@ public class AAAShiroFilter extends ShiroFilter {
      *
      * Adds context clues that aid in debugging.
      *
-     * @see org.apache.shiro.web.servlet.ShiroFilter#init()
+     * @see ShiroFilter#init()
      */
     @Override
     public void init() throws Exception {
         super.init();
-        LOG.debug("Initializing the AAAShiroFilter");
+        LOG.debug("AAAShiroFilter initialized");
     }
 }