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.auth.gui;
23 import java.io.IOException;
25 import javax.servlet.Filter;
26 import javax.servlet.FilterChain;
27 import javax.servlet.FilterConfig;
28 import javax.servlet.ServletException;
29 import javax.servlet.ServletRequest;
30 import javax.servlet.ServletResponse;
31 import javax.servlet.http.HttpServletResponse;
33 public class XFrameFilter implements Filter {
34 enum TYPE {none,self};
35 // Note: Content-Security Params need to be worked out for GUI before activating.
36 private final String xframe;//,csp;
38 public XFrameFilter(TYPE type) {
42 // csp="default-src 'self'";
47 // csp="default-src 'none'";
54 public void doFilter(ServletRequest req, ServletResponse resp, FilterChain fc) throws IOException, ServletException {
55 if (resp instanceof HttpServletResponse) {
56 @SuppressWarnings("unused")
57 HttpServletResponse hresp = (HttpServletResponse)resp;
58 ((HttpServletResponse)resp).addHeader("X-Frame-Options", xframe);
59 // ((HttpServletResponse)resp).addHeader("Content-Security-Policy",csp);
61 fc.doFilter(req, resp);
65 public void init(FilterConfig fc) throws ServletException {
69 public void destroy() {