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;
33 import org.onap.aaf.cadi.util.Holder;
36 * Add various Filters by CADI Property not in the official Chain
38 * @author Instrumental(Jonathan)
41 public class SideChain {
42 private List<Filter> sideChain;
45 sideChain = new ArrayList<Filter>();
48 public void add(Filter f) {
52 public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)throws IOException, ServletException {
53 final Holder<Boolean> hbool = new Holder<Boolean>(Boolean.TRUE);
54 FilterChain truth = new FilterChain() {
56 public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
57 hbool.set(Boolean.TRUE);
59 public String toString() {
60 return hbool.get().toString();
63 for(Filter f : sideChain) {
64 hbool.set(Boolean.FALSE);
65 f.doFilter(request, response, truth);
71 chain.doFilter(request, response);