Karaf 4: remove aaa-cli4
[aaa.git] / aaa-shiro / impl / src / main / java / org / opendaylight / aaa / impl / shiro / filters / AAAFilter.java
1 /*
2  * Copyright (c) 2015 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
9 package org.opendaylight.aaa.shiro.filters;
10
11 import org.apache.shiro.web.servlet.ShiroFilter;
12 import org.opendaylight.aaa.shiro.ServiceProxy;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16 /**
17  * The RESTCONF AAA JAX-RS 1.X Web Filter. This class is also responsible for
18  * delivering debug information; to enable these debug statements, please issue
19  * the following in the karaf shell:
20  *
21  * <code>log:set DEBUG org.opendaylight.aaa.shiro.filters.AAAFilter</code>
22  *
23  * @author Ryan Goulding (ryandgoulding@gmail.com)
24  * @see <code>javax.servlet.Filter</code>
25  * @see <code>org.apache.shiro.web.servlet.ShiroFilter</code>
26  */
27 public class AAAFilter extends ShiroFilter {
28
29     private static final Logger LOG = LoggerFactory.getLogger(AAAFilter.class);
30
31     public AAAFilter() {
32         LOG.debug("Creating the AAAFilter");
33     }
34
35     /*
36      * (non-Javadoc)
37      *
38      * Adds context clues that aid in debugging. Also initializes the enable
39      * status to correspond with
40      * <code>ServiceProxy.getInstance.getEnabled()</code>.
41      *
42      * @see org.apache.shiro.web.servlet.ShiroFilter#init()
43      */
44     @Override
45     public void init() throws Exception {
46         super.init();
47         LOG.debug("Initializing the AAAFilter");
48         // sets the filter to the startup value. Because of non-determinism in
49         // bundle loading, this passes an instance of itself along so that if
50         // the
51         // enable status changes, then AAAFilter enable status is changed.
52         setEnabled(ServiceProxy.getInstance().getEnabled(this));
53     }
54
55     /*
56      * (non-Javadoc)
57      *
58      * Adds context clues to aid in debugging whether the filter is enabled.
59      *
60      * @see
61      * org.apache.shiro.web.servlet.OncePerRequestFilter#setEnabled(boolean)
62      */
63     @Override
64     public void setEnabled(final boolean enabled) {
65         super.setEnabled(enabled);
66         LOG.debug("Setting AAAFilter enabled to {}", enabled);
67     }
68 }