Fixing sonar qube issues 51/27051/2
authorshrikantawachar <shrikant.awachar@amdocs.com>
Wed, 27 Dec 2017 10:16:30 +0000 (15:46 +0530)
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>
Wed, 27 Dec 2017 14:55:54 +0000 (14:55 +0000)
Refactoring the code as per review comments.

Change-Id: I1edd457f8d0989f815cbf3f28fa0a5124a8c4ac7
Issue-ID: SDC-343
Signed-off-by: shrikantawachar <shrikant.awachar@amdocs.com>
openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java

index f54b06d..181f7ad 100644 (file)
@@ -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
   }
 
 }