2 * Copyright (c) 2018 Inocybe Technologies and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.aaa.shiro.web.env;
10 import javax.servlet.ServletContext;
11 import org.apache.shiro.web.env.EnvironmentLoaderListener;
12 import org.apache.shiro.web.env.WebEnvironment;
13 import org.opendaylight.aaa.api.AuthenticationService;
14 import org.opendaylight.aaa.api.TokenStore;
15 import org.opendaylight.aaa.api.password.service.PasswordHashService;
16 import org.opendaylight.aaa.cert.api.ICertificateManager;
17 import org.opendaylight.aaa.shiro.tokenauthrealm.auth.TokenAuthenticators;
18 import org.opendaylight.mdsal.binding.api.DataBroker;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.aaa.app.config.rev170619.ShiroConfiguration;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * Initializes shiro components for a web environment.
26 * @author Thomas Pantelis
28 public class ShiroWebEnvironmentLoaderListener extends EnvironmentLoaderListener {
29 private static final Logger LOG = LoggerFactory.getLogger(ShiroWebEnvironmentLoaderListener.class);
31 private final ShiroConfiguration shiroConfiguration;
32 private final DataBroker dataBroker;
33 private final ICertificateManager certificateManager;
34 private final AuthenticationService authenticationService;
35 private final TokenAuthenticators tokenAuthenticators;
36 private final TokenStore tokenStore;
37 private final PasswordHashService passwordHashService;
39 public ShiroWebEnvironmentLoaderListener(final ShiroConfiguration shiroConfiguration, final DataBroker dataBroker,
40 final ICertificateManager certificateManager,
41 final AuthenticationService authenticationService,
42 final TokenAuthenticators tokenAuthenticators, final TokenStore tokenStore,
43 final PasswordHashService passwordHashService) {
44 this.shiroConfiguration = shiroConfiguration;
45 this.dataBroker = dataBroker;
46 this.certificateManager = certificateManager;
47 this.authenticationService = authenticationService;
48 this.tokenAuthenticators = tokenAuthenticators;
49 this.tokenStore = tokenStore;
50 this.passwordHashService = passwordHashService;
51 LOG.debug("ShiroWebEnvironmentLoaderListenerImpl created");
55 protected WebEnvironment determineWebEnvironment(final ServletContext servletContext) {
56 return new AAAIniWebEnvironment(shiroConfiguration, dataBroker, certificateManager, authenticationService,
57 tokenAuthenticators, tokenStore, passwordHashService);