Bump shiro to 1.7.1
[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.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;
22
23 /**
24  * Initializes shiro components for a web environment.
25  *
26  * @author Thomas Pantelis
27  */
28 public class ShiroWebEnvironmentLoaderListener extends EnvironmentLoaderListener {
29     private static final Logger LOG = LoggerFactory.getLogger(ShiroWebEnvironmentLoaderListener.class);
30
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;
38
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");
52     }
53
54     @Override
55     protected WebEnvironment determineWebEnvironment(final ServletContext servletContext) {
56         return new AAAIniWebEnvironment(shiroConfiguration, dataBroker, certificateManager, authenticationService,
57             tokenAuthenticators, tokenStore, passwordHashService);
58     }
59 }