1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 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
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ============LICENSE_END=========================================================
19 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21 *******************************************************************************/
22 package com.att.nsa.dmaap.util;
24 import java.io.IOException;
26 import javax.servlet.FilterChain;
27 import javax.servlet.ServletException;
28 import javax.servlet.ServletRequest;
29 import javax.servlet.ServletResponse;
30 import javax.servlet.http.HttpServletRequest;
32 import com.att.eelf.configuration.EELFLogger;
33 import com.att.eelf.configuration.EELFManager;
34 import org.springframework.stereotype.Component;
36 import org.onap.aaf.cadi.filter.CadiFilter;
37 //import ajsc.external.plugins.cadi.AjscCadiFilter;
38 import javax.servlet.FilterConfig;
41 * This is a Servlet Filter class
42 * overriding the AjscCadiFilter
45 public class DMaaPAuthFilter extends CadiFilter {
47 //private Logger log = Logger.getLogger(DMaaPAuthFilter.class.toString());
49 private static final EELFLogger log = EELFManager.getInstance().getLogger(DMaaPAuthFilter.class);
51 public DMaaPAuthFilter() throws Exception {
55 /* public void init(FilterConfig filterConfig) throws ServletException {
57 super.init(filterConfig);
58 System.out.println("---------------------------- in init method");
62 * This method will disable Cadi Authentication
63 * if cambria headers are present in the request
64 * else continue with Cadi Authentication
67 public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException,
69 log.info("inside servlet filter Cambria Auth Headers checking before doing other Authentication");
70 HttpServletRequest request = (HttpServletRequest) req;
71 boolean forceAAF = Boolean.valueOf(System.getProperty("forceAAF"));
72 //if (forceAAF || null != request.getHeader("Authorization") ){
73 if (forceAAF || null != request.getHeader("Authorization") ||
74 (null != request.getHeader("AppName") && request.getHeader("AppName").equalsIgnoreCase("invenio") &&
75 null != request.getHeader("cookie"))){
76 super.doFilter(req, res, chain);
79 System.setProperty("CadiAuthN", "authentication-scheme-2");
80 chain.doFilter(req, res);