2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 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
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.openecomp.server.filters;
23 import java.io.IOException;
24 import javax.servlet.Filter;
25 import javax.servlet.FilterChain;
26 import javax.servlet.FilterConfig;
27 import javax.servlet.ServletException;
28 import javax.servlet.ServletRequest;
29 import javax.servlet.ServletResponse;
30 import javax.servlet.http.HttpServletRequest;
31 import javax.servlet.http.HttpServletResponse;
33 public class ActionAuthorizationFilter implements Filter {
35 private boolean runningOnLocal = true;
38 public void destroy() {
39 // TODO Auto-generated method stub
44 public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2)
45 throws IOException, ServletException {
48 HttpServletRequest httpRequest = (HttpServletRequest) arg0;
49 if (httpRequest.isUserInRole(httpRequest.getMethod().toUpperCase())) {
50 arg2.doFilter(arg0, arg1);
52 setResponseStatus((HttpServletResponse) arg1, HttpServletResponse.SC_FORBIDDEN);
55 //call super doFilter of cadi authorization filter with relavant info as and when available
60 private void setResponseStatus(HttpServletResponse response, int status) {
61 response.setStatus(status);
65 public void init(FilterConfig arg0) throws ServletException {