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 org.onap.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 org.onap.dmaap.dmf.mr.utils.Utils;
33 import com.att.eelf.configuration.EELFLogger;
34 import com.att.eelf.configuration.EELFManager;
35 import org.springframework.stereotype.Component;
37 import org.onap.aaf.cadi.filter.CadiFilter;
38 //import ajsc.external.plugins.cadi.AjscCadiFilter;
39 import javax.servlet.FilterConfig;
42 * This is a Servlet Filter class
43 * overriding the AjscCadiFilter
46 public class DMaaPAuthFilter extends CadiFilter {
48 //private Logger log = Logger.getLogger(DMaaPAuthFilter.class.toString());
50 private static final EELFLogger log = EELFManager.getInstance().getLogger(DMaaPAuthFilter.class);
52 public DMaaPAuthFilter() throws Exception {
56 /* public void init(FilterConfig filterConfig) throws ServletException {
58 super.init(filterConfig);
59 System.out.println("---------------------------- in init method");
63 * This method will disable Cadi Authentication
64 * if cambria headers are present in the request
65 * else continue with Cadi Authentication
68 public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException,
70 log.info("inside servlet filter Cambria Auth Headers checking before doing other Authentication");
71 HttpServletRequest request = (HttpServletRequest) req;
72 boolean forceAAF = Boolean.valueOf(System.getProperty("forceAAF"));
74 //if (forceAAF || null != request.getHeader("Authorization") ){
75 if (Utils.isCadiEnabled()&&(forceAAF || null != request.getHeader("Authorization") ||
76 (null != request.getHeader("AppName") && request.getHeader("AppName").equalsIgnoreCase("invenio") &&
77 null != request.getHeader("cookie")))){
78 super.doFilter(req, res, chain);
81 System.setProperty("CadiAuthN", "authentication-scheme-2");
82 chain.doFilter(req, res);