From 70f0b5c0eaf2f0680fea6fcc659f8ed4d7afac24 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 4 Jul 2022 23:18:07 +0200 Subject: [PATCH] Revert "Publish ShiroWebEnvironmentLoaderListener to HTTP whiteboard" This reverts commit a8e9e36a1c516a466ee90e6f58e4e902dd657ce9, as we are keeping WebServer after all. Change-Id: Ie1959b403d96a108116e2bf31b1e44c3fe5f4864 Signed-off-by: Robert Varga --- .../shiro/web/env/ShiroWebContextSecurer.java | 24 +++++++++---------- .../ShiroWebEnvironmentLoaderListener.java | 15 ++++-------- .../OSGI-INF/blueprint/impl-blueprint.xml | 1 - 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/web/env/ShiroWebContextSecurer.java b/aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/web/env/ShiroWebContextSecurer.java index e88f7cc8f..53a7068ba 100644 --- a/aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/web/env/ShiroWebContextSecurer.java +++ b/aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/web/env/ShiroWebContextSecurer.java @@ -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()); } } diff --git a/aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/web/env/ShiroWebEnvironmentLoaderListener.java b/aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/web/env/ShiroWebEnvironmentLoaderListener.java index f313abff2..a966bb6b0 100644 --- a/aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/web/env/ShiroWebEnvironmentLoaderListener.java +++ b/aaa-shiro/impl/src/main/java/org/opendaylight/aaa/shiro/web/env/ShiroWebEnvironmentLoaderListener.java @@ -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; diff --git a/aaa-shiro/impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml b/aaa-shiro/impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml index e79a652b2..a05ec0723 100644 --- a/aaa-shiro/impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml +++ b/aaa-shiro/impl/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml @@ -52,7 +52,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html - -- 2.36.6