49b895b64d1ff99e94e3df1be84c05a4ed024346
[aaa.git] / aaa-shiro / impl / src / main / java / org / opendaylight / aaa / shiro / filters / AAAShiroFilter.java
1 /*
2  * Copyright (c) 2016 - 2017 Brocade Communications Systems, Inc. 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.filters;
9
10 import javax.servlet.Filter;
11 import javax.servlet.annotation.WebFilter;
12 import org.apache.shiro.web.servlet.ShiroFilter;
13 import org.osgi.service.component.annotations.Component;
14 import org.osgi.service.component.annotations.ServiceScope;
15 import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardFilterAsyncSupported;
16 import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardFilterName;
17 import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardFilterPattern;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 /**
22  * The default AAA JAX-RS 1.X Web Filter.  Unlike AAAFilter, which is aimed towards
23  * supporting RESTCONF and its existing API mechanisms, AAAShiroFilter is a generic
24  * <code>ShiroFilter</code> for use with any other ODL Servlets.  The main difference
25  * is that <code>AAAFilter</code> was designed to support the existing noauth
26  * mechanism, while this filter cannot be disabled.
27  *
28  * <p>
29  * This class is also responsible for delivering debug information; to enable these
30  * debug statements, please issue the following in the karaf shell:
31  *
32  * <code>log:set DEBUG AAAShiroFilter</code>
33  *
34  * @see Filter
35  * @see ShiroFilter
36  */
37 @WebFilter(urlPatterns = "/*", filterName = "AAAShiroFilter")
38 @HttpWhiteboardFilterAsyncSupported
39 @HttpWhiteboardFilterPattern("/*")
40 @HttpWhiteboardFilterName("AAAShiroFilter")
41 @Component(service = Filter.class, scope = ServiceScope.PROTOTYPE)
42 public final class AAAShiroFilter extends ShiroFilter {
43     private static final Logger LOG = LoggerFactory.getLogger(AAAShiroFilter.class);
44
45     public AAAShiroFilter() {
46         LOG.debug("Creating the AAAShiroFilter");
47     }
48
49     /*
50      * (non-Javadoc)
51      *
52      * Adds context clues that aid in debugging.
53      *
54      * @see ShiroFilter#init()
55      */
56     @Override
57     public void init() throws Exception {
58         super.init();
59         LOG.debug("AAAShiroFilter initialized");
60     }
61 }