Add support to RESTCONF to dynamically specify Filters 56/36456/1
authorRyan Goulding <ryandgoulding@gmail.com>
Tue, 15 Mar 2016 14:17:36 +0000 (10:17 -0400)
committerRyan Goulding <ryandgoulding@gmail.com>
Fri, 18 Mar 2016 19:27:51 +0000 (15:27 -0400)
This change builds of work that the AAA team took on to help add dynamicism to
RESTCONF.  The javax.servlet-api specifies a means to define chains of Filter(s)
in front of a web Servlet.  However, configuration of filters is not supported, and
there is no easy existing mechanism to add Filters to a prebuilt ODL
distribution.  The issue involves the fact that Jersey Servlets define Filter
chains within web.xml, which is static and included inside of the odl-restconf
bundle.  This makes it very hard (if not impossible due to lack of
DynamicImport-Package declarations in restconf's pom) to alter the web.xml file
after compilation.

AAA added a filter called CustomFilterAdapter, which recreates the javax
filter chain-of-responsibility pattern.  The dynamic filter chain functionality
has very little to no overhead if left unused, but could be used to add
Filter implementations that allow for enhanced logging of HTTP/S requests/
replies, as well as other various functions.  This aids in debugging real
world deployments, as well as enables enhanced Accounting and Auditing
of the controller.

This functionality has been raised as vital by members of the AG.

Change-Id: Ib81ebdd0ab7de72d75cbbc90124656a3666cacba
Signed-off-by: Ryan Goulding <ryandgoulding@gmail.com>
restconf/sal-rest-connector/pom.xml
restconf/sal-rest-connector/src/main/resources/WEB-INF/web.xml

index 31b614766f58f187499ccaf7c674de1205a2181b..aee9c961ebf4082e3d24dfbb9936410d4c1ffac2 100644 (file)
               org.opendaylight.aaa.shiro.filters,
               org.opendaylight.aaa.shiro.realm,
               org.opendaylight.aaa.shiro.web.env,
+              org.opendaylight.aaa.filterchain.filters,
               org.apache.shiro.web.env
             </Import-Package>
             <Embed-Dependency>stax-utils</Embed-Dependency>
index 493572952598594c7cb32d0e80b3cab03c8ad461..6b801d7321307adc5cf70ea2f62c662933dc17a4 100644 (file)
         <url-pattern>/*</url-pattern>
     </filter-mapping>
 
+    <filter>
+        <filter-name>DynamicFilterChain</filter-name>
+        <filter-class>org.opendaylight.aaa.filterchain.filters.CustomFilterAdapter</filter-class>
+    </filter>
+
+    <filter-mapping>
+        <filter-name>DynamicFilterChain</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+
+
     <servlet-mapping>
         <servlet-name>JAXRSRestconf</servlet-name>
         <url-pattern>/*</url-pattern>