diff options
author | 2019-09-20 15:48:14 +0000 | |
---|---|---|
committer | 2019-09-20 16:14:14 +0000 | |
commit | b313283ddae4d435d6a96b4dd1e33f74c22ca2ad (patch) | |
tree | 1543ef906d95fe405716ea6fb2e4b5b59ef70ab5 /reference/logging-filter/logging-filter-base/src/main/java | |
parent | 94e4eb867e0194f6fe99f472eb60c41044df63f2 (diff) |
PayloadLoggingClientFilter bugfix
log response body in PayloadLoggingClientFilter
Issue-ID: LOG-1146
Signed-off-by: Smokowski, Kevin (ks6305) <kevin.smokowski@att.com>
Change-Id: I17a96f40577ba709d7f623209cdd19143dc8f1ec
Diffstat (limited to 'reference/logging-filter/logging-filter-base/src/main/java')
3 files changed, 9 insertions, 6 deletions
diff --git a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractServletFilter.java b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractServletFilter.java index bf165f9..28495c8 100644 --- a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractServletFilter.java +++ b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractServletFilter.java @@ -26,7 +26,6 @@ import javax.servlet.http.HttpServletResponse; import javax.ws.rs.core.HttpHeaders; public abstract class AbstractServletFilter { - protected static final String REDACTED = "***REDACTED***"; protected String getSecureRequestHeaders(HttpServletRequest httpRequest) { StringBuilder sb = new StringBuilder(); @@ -36,7 +35,7 @@ public abstract class AbstractServletFilter { sb.append(header); sb.append(":"); if (header.equalsIgnoreCase(HttpHeaders.AUTHORIZATION)) { - sb.append(REDACTED); + sb.append(Constants.REDACTED); } else { sb.append(httpRequest.getHeader(header)); } diff --git a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/Constants.java b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/Constants.java index 1549be1..be28f0b 100644 --- a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/Constants.java +++ b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/Constants.java @@ -21,6 +21,7 @@ package org.onap.logging.filter.base; public class Constants { + protected static final String REDACTED = "***REDACTED***"; public static final class DefaultValues { public static final String UNKNOWN = "UNKNOWN"; diff --git a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/PayloadLoggingClientFilter.java b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/PayloadLoggingClientFilter.java index 3777719..88c95aa 100644 --- a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/PayloadLoggingClientFilter.java +++ b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/PayloadLoggingClientFilter.java @@ -92,6 +92,8 @@ public class PayloadLoggingClientFilter implements ClientRequestFilter, ClientRe for (String header : headers.keySet()) { if (!header.equals(HttpHeaders.AUTHORIZATION)) { printHeaders.add(header, headers.getFirst(header)); + } else { + printHeaders.add(header, Constants.REDACTED);; } } return printHeaders.toString(); @@ -99,13 +101,14 @@ public class PayloadLoggingClientFilter implements ClientRequestFilter, ClientRe @Override public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException { - final StringBuilder sb = new StringBuilder(); - if (responseContext.hasEntity()) { - responseContext.setEntityStream(logInboundEntity(sb, responseContext.getEntityStream(), DEFAULT_CHARSET)); - } String method = formatMethod(requestContext); logger.debug("Response from method:{} performed on uri:{} has http status code:{} and response headers:{}", method, requestContext.getUri(), responseContext.getStatus(), responseContext.getHeaders().toString()); + if (responseContext.hasEntity()) { + final StringBuilder sb = new StringBuilder(); + responseContext.setEntityStream(logInboundEntity(sb, responseContext.getEntityStream(), DEFAULT_CHARSET)); + logger.debug(sb.toString()); + } } @Override |