Clarify WebContext.contextParams()
[aaa.git] / aaa-shiro / impl / src / main / java / org / opendaylight / aaa / shiro / web / env / ShiroWebEnvironmentLoaderListener.java
1 /*
2  * Copyright (c) 2018 Inocybe Technologies and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.aaa.shiro.web.env;
9
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.tokenauthrealm.auth.TokenAuthenticators;
18 import org.opendaylight.aaa.web.servlet.ServletSupport;
19 import org.opendaylight.mdsal.binding.api.DataBroker;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.aaa.app.config.rev170619.ShiroConfiguration;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 /**
25  * Initializes shiro components for a web environment.
26  *
27  * @author Thomas Pantelis
28  */
29 public class ShiroWebEnvironmentLoaderListener extends EnvironmentLoaderListener {
30     private static final Logger LOG = LoggerFactory.getLogger(ShiroWebEnvironmentLoaderListener.class);
31
32     private final ShiroConfiguration shiroConfiguration;
33     private final DataBroker dataBroker;
34     private final ICertificateManager certificateManager;
35     private final AuthenticationService authenticationService;
36     private final TokenAuthenticators tokenAuthenticators;
37     private final TokenStore tokenStore;
38     private final PasswordHashService passwordHashService;
39     private final ServletSupport servletSupport;
40
41     public ShiroWebEnvironmentLoaderListener(final ShiroConfiguration shiroConfiguration, final DataBroker dataBroker,
42             final ICertificateManager certificateManager, final AuthenticationService authenticationService,
43             final TokenAuthenticators tokenAuthenticators, final TokenStore tokenStore,
44             final PasswordHashService passwordHashService, final ServletSupport servletSupport) {
45         this.shiroConfiguration = shiroConfiguration;
46         this.dataBroker = dataBroker;
47         this.certificateManager = certificateManager;
48         this.authenticationService = authenticationService;
49         this.tokenAuthenticators = tokenAuthenticators;
50         this.tokenStore = tokenStore;
51         this.passwordHashService = passwordHashService;
52         this.servletSupport = servletSupport;
53         LOG.debug("ShiroWebEnvironmentLoaderListenerImpl created");
54     }
55
56     @Override
57     protected WebEnvironment determineWebEnvironment(final ServletContext servletContext) {
58         return new AAAIniWebEnvironment(shiroConfiguration, dataBroker, certificateManager, authenticationService,
59             tokenAuthenticators, tokenStore, passwordHashService, servletSupport);
60     }
61 }