Publish ShiroWebEnvironmentLoaderListener to HTTP whiteboard 30/100930/9
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 2 May 2022 20:04:52 +0000 (22:04 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 1 Jun 2022 00:08:09 +0000 (02:08 +0200)
As part of ditching WebSecurer, convert let HTTP Whiteboard understand
this is a listener.

Change-Id: I8840055856a6730197b11471b2e315dc6f83764f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/web/env/ShiroWebContextSecurer.java
aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/web/env/ShiroWebEnvironmentLoaderListener.java
aaa-shiro/impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml

index cb072936a871ba9cea43d23f78302a4ce9b20f57..dd06e9e434371a9f31e9f1e1ef9e4199414c7d4a 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.aaa.shiro.web.env;
 
-import org.apache.shiro.web.env.EnvironmentLoaderListener;
+import static java.util.Objects.requireNonNull;
+
+import javax.servlet.ServletContextListener;
 import org.eclipse.jetty.servlets.CrossOriginFilter;
 import org.opendaylight.aaa.shiro.filters.AAAShiroFilter;
 import org.opendaylight.aaa.web.FilterDetails;
@@ -21,10 +23,10 @@ import org.opendaylight.aaa.web.WebContextSecurer;
  * @author Michael Vorburger.ch
  */
 public class ShiroWebContextSecurer implements WebContextSecurer {
-    private final EnvironmentLoaderListener shiroEnvironmentLoaderListener;
+    private final ServletContextListener shiroEnvironmentLoaderListener;
 
-    public ShiroWebContextSecurer(final EnvironmentLoaderListener shiroEnvironmentLoaderListener) {
-        this.shiroEnvironmentLoaderListener = shiroEnvironmentLoaderListener;
+    public ShiroWebContextSecurer(final ServletContextListener shiroEnvironmentLoaderListener) {
+        this.shiroEnvironmentLoaderListener = requireNonNull(shiroEnvironmentLoaderListener);
     }
 
     @Override
index 4c1fcb616cc2aa445756e24f22283fb7e95d67a1..81a0061d2c3056e3c52dcc5c60cb068fde242a43 100644 (file)
@@ -25,7 +25,9 @@ import org.slf4j.LoggerFactory;
  *
  * @author Thomas Pantelis
  */
-public class ShiroWebEnvironmentLoaderListener extends EnvironmentLoaderListener {
+// FIXME: @WebListener and CDI (or whatever) injection?
+// FIXME: @Component with ServletContextListener
+public final class ShiroWebEnvironmentLoaderListener extends EnvironmentLoaderListener {
     private static final Logger LOG = LoggerFactory.getLogger(ShiroWebEnvironmentLoaderListener.class);
 
     private final ShiroConfiguration shiroConfiguration;
@@ -36,6 +38,8 @@ public class ShiroWebEnvironmentLoaderListener extends EnvironmentLoaderListener
     private final TokenStore tokenStore;
     private final PasswordHashService passwordHashService;
 
+    // FIXME: @Inject for CDI, except we have ShiroConfiguration injected
+    // FIXME: @Activate for OSGi @Component, except we have ShiroConfiguration which needs to come from somewhere
     public ShiroWebEnvironmentLoaderListener(final ShiroConfiguration shiroConfiguration, final DataBroker dataBroker,
                                              final ICertificateManager certificateManager,
                                              final AuthenticationService authenticationService,
index 61a906f69375c153980444633064d7f5d8f1a0f7..806e4f3a228e041b23a89c9cb57f439f2c76ea2a 100644 (file)
@@ -54,6 +54,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     </argument>
     <argument ref="passwordService" />
   </bean>
+  <service ref="shiroWebEnvLoader" interface="javax.servlet.ServletContextListener"/>
 
   <reference id="customFilterAdapterConfig"
       interface="org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration"/>