diff options
3 files changed, 5 insertions, 7 deletions
diff --git a/aai-resources/src/main/java/org/onap/aai/config/aaf/AafAuthorizationFilter.java b/aai-resources/src/main/java/org/onap/aai/config/aaf/AafAuthorizationFilter.java index 653fc51..2162e9b 100644 --- a/aai-resources/src/main/java/org/onap/aai/config/aaf/AafAuthorizationFilter.java +++ b/aai-resources/src/main/java/org/onap/aai/config/aaf/AafAuthorizationFilter.java @@ -32,8 +32,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import static org.onap.aai.config.aaf.ResponseFormatter.errorResponse; - /** * AAF authorization filter */ @@ -60,7 +58,7 @@ public class AafAuthorizationFilter extends OrderedRequestContextFilter { filterChain.doFilter(request, response); } if(!request.isUserInRole(permission)){ - errorResponse(request, response); + response.setStatus(403); }else{ filterChain.doFilter(request,response); } diff --git a/aai-resources/src/main/java/org/onap/aai/config/aaf/AafFilter.java b/aai-resources/src/main/java/org/onap/aai/config/aaf/AafFilter.java index f1aa7c1..08d9475 100644 --- a/aai-resources/src/main/java/org/onap/aai/config/aaf/AafFilter.java +++ b/aai-resources/src/main/java/org/onap/aai/config/aaf/AafFilter.java @@ -57,7 +57,7 @@ public class AafFilter extends OrderedRequestContextFilter { protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException { if(!request.getRequestURI().matches("^.*/util/echo$")){ cadiFilter.doFilter(request, response, filterChain); - if(response.getStatus() >=400 && response.getStatus() < 500){ + if(response.getStatus() == 401 && response.getStatus() == 403){ errorResponse(request, response); } } else { diff --git a/aai-resources/src/main/java/org/onap/aai/config/aaf/ResponseFormatter.java b/aai-resources/src/main/java/org/onap/aai/config/aaf/ResponseFormatter.java index 9e09827..ca09730 100644 --- a/aai-resources/src/main/java/org/onap/aai/config/aaf/ResponseFormatter.java +++ b/aai-resources/src/main/java/org/onap/aai/config/aaf/ResponseFormatter.java @@ -37,9 +37,9 @@ class ResponseFormatter { String accept = request.getHeader(ACCEPT_HEADER) == null ? MediaType.APPLICATION_XML : request.getHeader(ACCEPT_HEADER); AAIException aaie = new AAIException("AAI_3300"); response.setStatus(aaie.getErrorObject().getHTTPResponseCode().getStatusCode()); - response.getWriter().write(ErrorLogHelper.getRESTAPIErrorResponse(Collections.singletonList(MediaType.valueOf(accept)), aaie, new ArrayList<>())); - response.getWriter().flush(); - response.getWriter().close(); + response.resetBuffer(); + response.getOutputStream().print(ErrorLogHelper.getRESTAPIErrorResponse(Collections.singletonList(MediaType.valueOf(accept)), aaie, new ArrayList<>())); + response.flushBuffer(); } } |