Revert "Publish ShiroWebEnvironmentLoaderListener to HTTP whiteboard" 30/101730/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Jul 2022 21:18:07 +0000 (23:18 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Jul 2022 21:34:38 +0000 (23:34 +0200)
This reverts commit a8e9e36a1c516a466ee90e6f58e4e902dd657ce9, as we are
keeping WebServer after all.

Change-Id: Ie1959b403d96a108116e2bf31b1e44c3fe5f4864
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 e88f7cc8f519fa927b021262cda85d9d8c43cb8d..53a7068ba53bcadbb3c1985157e6c90f7e6d617e 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.aaa.shiro.web.env;
 
 import static java.util.Objects.requireNonNull;
 
-import javax.servlet.ServletContextListener;
+import org.apache.shiro.web.env.EnvironmentLoaderListener;
 import org.opendaylight.aaa.shiro.filters.AAAShiroFilter;
 import org.opendaylight.aaa.web.FilterDetails;
 import org.opendaylight.aaa.web.WebContext;
@@ -22,22 +22,22 @@ import org.opendaylight.aaa.web.WebContextSecurer;
  * @author Michael Vorburger.ch
  */
 public class ShiroWebContextSecurer implements WebContextSecurer {
-    private final ServletContextListener shiroEnvironmentLoaderListener;
+    private final EnvironmentLoaderListener environmentLoaderListener;
 
-    public ShiroWebContextSecurer(final ServletContextListener shiroEnvironmentLoaderListener) {
-        this.shiroEnvironmentLoaderListener = requireNonNull(shiroEnvironmentLoaderListener);
+    public ShiroWebContextSecurer(final EnvironmentLoaderListener environmentLoaderListener) {
+        this.environmentLoaderListener = requireNonNull(environmentLoaderListener);
     }
 
     @Override
     public void requireAuthentication(final WebContextBuilder webContextBuilder, final boolean asyncSupported,
             final String... urlPatterns) {
-        webContextBuilder.addListener(shiroEnvironmentLoaderListener)
-
-                // AAA filter in front of these REST web services as well as for moon endpoints
-                .addFilter(FilterDetails.builder()
-                        .filter(new AAAShiroFilter())
-                        .addUrlPatterns(urlPatterns)
-                        .asyncSupported(asyncSupported)
-                        .build());
+        webContextBuilder
+            .addListener(environmentLoaderListener)
+            // AAA filter in front of these REST web services as well as for moon endpoints
+            .addFilter(FilterDetails.builder()
+                .filter(new AAAShiroFilter())
+                .addUrlPatterns(urlPatterns)
+                .asyncSupported(asyncSupported)
+                .build());
     }
 }
index f313abff2be61632bdcf69f6d89948b4701ede47..a966bb6b0d1ec514caabe4b3104483b562ff91d1 100644 (file)
@@ -26,9 +26,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author Thomas Pantelis
  */
-// FIXME: @WebListener and CDI (or whatever) injection?
-// FIXME: @Component with ServletContextListener
-public final class ShiroWebEnvironmentLoaderListener extends EnvironmentLoaderListener {
+public class ShiroWebEnvironmentLoaderListener extends EnvironmentLoaderListener {
     private static final Logger LOG = LoggerFactory.getLogger(ShiroWebEnvironmentLoaderListener.class);
 
     private final ShiroConfiguration shiroConfiguration;
@@ -40,15 +38,10 @@ public final class ShiroWebEnvironmentLoaderListener extends EnvironmentLoaderLi
     private final PasswordHashService passwordHashService;
     private final ServletSupport servletSupport;
 
-    // FIXME: @Inject for CDI, except we have ShiroConfiguration injected
-    // FIXME: @Activate for OSGi @Component
-    // Both of these have problem with how do we inject ShiroConfiguration?
     public ShiroWebEnvironmentLoaderListener(final ShiroConfiguration shiroConfiguration, final DataBroker dataBroker,
-                                             final ICertificateManager certificateManager,
-                                             final AuthenticationService authenticationService,
-                                             final TokenAuthenticators tokenAuthenticators, final TokenStore tokenStore,
-                                             final PasswordHashService passwordHashService,
-                                             final ServletSupport servletSupport) {
+            final ICertificateManager certificateManager, final AuthenticationService authenticationService,
+            final TokenAuthenticators tokenAuthenticators, final TokenStore tokenStore,
+            final PasswordHashService passwordHashService, final ServletSupport servletSupport) {
         this.shiroConfiguration = shiroConfiguration;
         this.dataBroker = dataBroker;
         this.certificateManager = certificateManager;
index e79a652b28c11ada9c33b70393b947dc58ad7c0e..a05ec0723821bab860d8ea7697d2a40f716c57d1 100644 (file)
@@ -52,7 +52,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <argument ref="passwordService"/>
     <argument ref="servletSupport"/>
   </bean>
-  <service ref="shiroWebEnvLoader" interface="javax.servlet.ServletContextListener"/>
 
   <reference id="customFilterAdapterConfig"
       interface="org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration"/>