From 5dffd0bb65ff1053055c2697e7cd198551c261cb Mon Sep 17 00:00:00 2001 From: shrikantawachar Date: Wed, 27 Dec 2017 15:46:30 +0530 Subject: Fixing sonar qube issues Refactoring the code as per review comments. Change-Id: I1edd457f8d0989f815cbf3f28fa0a5124a8c4ac7 Issue-ID: SDC-343 Signed-off-by: shrikantawachar --- .../server/filters/ActionAuthorizationFilter.java | 35 ++++++++-------------- 1 file changed, 13 insertions(+), 22 deletions(-) (limited to 'openecomp-be/api') diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java index f54b06d46a..181f7add88 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java @@ -1,21 +1,17 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2016-2017 European Support Limited + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END========================================================= */ package org.openecomp.server.filters; @@ -32,29 +28,24 @@ import java.io.IOException; public class ActionAuthorizationFilter implements Filter { - private boolean runningOnLocal = true; @Override public void destroy() { - // TODO Auto-generated method stub + //destroy() is not implemented for ActionAuthorizationFilter } @Override - public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, + FilterChain filterChain) throws IOException, ServletException { - if (runningOnLocal) { - HttpServletRequest httpRequest = (HttpServletRequest) arg0; - if (httpRequest.isUserInRole(httpRequest.getMethod().toUpperCase())) { - arg2.doFilter(arg0, arg1); - } else { - setResponseStatus((HttpServletResponse) arg1, HttpServletResponse.SC_FORBIDDEN); - } + HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; + if (httpRequest.isUserInRole(httpRequest.getMethod().toUpperCase())) { + filterChain.doFilter(servletRequest, servletResponse); } else { - //call super doFilter of cadi authorization filter with relavant info as and when available + setResponseStatus((HttpServletResponse) servletResponse, HttpServletResponse.SC_FORBIDDEN); } - } private void setResponseStatus(HttpServletResponse response, int status) { @@ -63,7 +54,7 @@ public class ActionAuthorizationFilter implements Filter { @Override public void init(FilterConfig arg0) throws ServletException { - + //init() is not implemented for ActionAuthorizationFilter } } -- cgit 1.2.3-korg