2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
21 package org.onap.aaf.cadi.filter;
23 import java.io.IOException;
24 import java.util.ArrayList;
25 import java.util.List;
27 import javax.servlet.Filter;
28 import javax.servlet.FilterChain;
29 import javax.servlet.ServletException;
30 import javax.servlet.ServletRequest;
31 import javax.servlet.ServletResponse;
32 import javax.xml.ws.Holder;
35 * Add various Filters by CADI Property not in the official Chain
37 * @author Instrumental(Jonathan)
40 public class SideChain {
41 private List<Filter> sideChain;
44 sideChain = new ArrayList<Filter>();
47 public void add(Filter f) {
51 public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)throws IOException, ServletException {
52 final Holder<Boolean> hbool = new Holder<Boolean>(Boolean.TRUE);
53 FilterChain truth = new FilterChain() {
55 public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
56 hbool.value=Boolean.TRUE;
58 public String toString() {
59 return hbool.value.toString();
62 for(Filter f : sideChain) {
63 hbool.value=Boolean.FALSE;
64 f.doFilter(request, response, truth);
70 chain.doFilter(request, response);