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;
* @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());
}
}
*
* @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;
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;
<argument ref="passwordService"/>
<argument ref="servletSupport"/>
</bean>
- <service ref="shiroWebEnvLoader" interface="javax.servlet.ServletContextListener"/>
<reference id="customFilterAdapterConfig"
interface="org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration"/>