From fdcd3fbc474a73a2131221bb572437e8612b246a Mon Sep 17 00:00:00 2001 From: Steve Hu Date: Sat, 26 Nov 2022 21:46:34 -0500 Subject: [PATCH] fixes #254 update the starts and ends to debug level (#255) --- .../networknt/openapi/AccessControlHandler.java | 10 +++++----- .../java/com/networknt/openapi/OpenApiHandler.java | 14 +++++++------- .../com/networknt/openapi/JwtVerifyHandler.java | 14 +++++++------- .../com/networknt/openapi/ValidatorHandler.java | 10 +++++----- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/access-control/src/main/java/com/networknt/openapi/AccessControlHandler.java b/access-control/src/main/java/com/networknt/openapi/AccessControlHandler.java index 7b30e09a..c00cbd25 100644 --- a/access-control/src/main/java/com/networknt/openapi/AccessControlHandler.java +++ b/access-control/src/main/java/com/networknt/openapi/AccessControlHandler.java @@ -69,12 +69,12 @@ public AccessControlHandler() { @Override @SuppressWarnings("unchecked") public void handleRequest(final HttpServerExchange exchange) throws Exception { - if (logger.isDebugEnabled()) logger.trace("AccessControlHandler.handleRequest starts."); + if (logger.isDebugEnabled()) logger.debug("AccessControlHandler.handleRequest starts."); String reqPath = exchange.getRequestPath(); // if request path is in the skipPathPrefixes in the config, call the next handler directly to skip the security check. if (config.getSkipPathPrefixes() != null && config.getSkipPathPrefixes().stream().anyMatch(s -> reqPath.startsWith(s))) { if(logger.isTraceEnabled()) logger.trace("Skip request path base on skipPathPrefixes for " + reqPath); - if (logger.isDebugEnabled()) logger.trace("AccessControlHandler.handleRequest ends with path skipped."); + if (logger.isDebugEnabled()) logger.debug("AccessControlHandler.handleRequest ends with path skipped."); Handler.next(exchange, next); return; } @@ -93,7 +93,7 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception { if (RuleLoaderStartupHook.endpointRules == null) { logger.error("RuleLoaderStartupHook endpointRules is null"); setExchangeStatus(exchange, STARTUP_HOOK_NOT_LOADED, "RuleLoaderStartupHook"); - if (logger.isDebugEnabled()) logger.trace("AccessControlHandler.handleRequest ends with an error."); + if (logger.isDebugEnabled()) logger.debug("AccessControlHandler.handleRequest ends with an error."); return; } @@ -104,10 +104,10 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception { if (requestRules == null) { if (config.defaultDeny) { logger.error("Access control rule is missing and default deny is true for endpoint " + endpoint); - if (logger.isDebugEnabled()) logger.trace("AccessControlHandler.handleRequest ends with an error."); + if (logger.isDebugEnabled()) logger.debug("AccessControlHandler.handleRequest ends with an error."); setExchangeStatus(exchange, ACCESS_CONTROL_MISSING, endpoint); } else { - if (logger.isDebugEnabled()) logger.trace("AccessControlHandler.handleRequest ends."); + if (logger.isDebugEnabled()) logger.debug("AccessControlHandler.handleRequest ends."); next(exchange); } } else { diff --git a/openapi-meta/src/main/java/com/networknt/openapi/OpenApiHandler.java b/openapi-meta/src/main/java/com/networknt/openapi/OpenApiHandler.java index a5926c3d..cb292395 100644 --- a/openapi-meta/src/main/java/com/networknt/openapi/OpenApiHandler.java +++ b/openapi-meta/src/main/java/com/networknt/openapi/OpenApiHandler.java @@ -136,7 +136,7 @@ public OpenApiHandler() { } @Override public void handleRequest(final HttpServerExchange exchange) throws Exception { - if (logger.isDebugEnabled()) logger.trace("OpenApiHandler.handleRequest starts."); + if (logger.isDebugEnabled()) logger.debug("OpenApiHandler.handleRequest starts."); if(config.isMultipleSpec()) { String p = exchange.getRequestPath(); boolean found = false; @@ -149,7 +149,7 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception { final Optional maybeApiPath = h.findMatchingApiPath(requestPath); if (!maybeApiPath.isPresent()) { setExchangeStatus(exchange, STATUS_INVALID_REQUEST_PATH, requestPath.normalised()); - if (logger.isDebugEnabled()) logger.trace("OpenApiHandler.handleRequest ends with an error."); + if (logger.isDebugEnabled()) logger.debug("OpenApiHandler.handleRequest ends with an error."); return; } @@ -161,7 +161,7 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception { if (operation == null) { setExchangeStatus(exchange, STATUS_METHOD_NOT_ALLOWED, httpMethod, openApiPathString.normalised()); - if (logger.isDebugEnabled()) logger.trace("OpenApiHandler.handleRequest ends with an error."); + if (logger.isDebugEnabled()) logger.debug("OpenApiHandler.handleRequest ends with an error."); return; } @@ -186,7 +186,7 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception { } if(!found) { setExchangeStatus(exchange, STATUS_INVALID_REQUEST_PATH, p); - if (logger.isDebugEnabled()) logger.trace("OpenApiHandler.handleRequest ends with an error."); + if (logger.isDebugEnabled()) logger.debug("OpenApiHandler.handleRequest ends with an error."); return; } } else { @@ -194,7 +194,7 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception { final Optional maybeApiPath = helper.findMatchingApiPath(requestPath); if (!maybeApiPath.isPresent()) { setExchangeStatus(exchange, STATUS_INVALID_REQUEST_PATH, requestPath.normalised()); - if (logger.isDebugEnabled()) logger.trace("OpenApiHandler.handleRequest ends with an error."); + if (logger.isDebugEnabled()) logger.debug("OpenApiHandler.handleRequest ends with an error."); return; } @@ -206,7 +206,7 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception { if (operation == null) { setExchangeStatus(exchange, STATUS_METHOD_NOT_ALLOWED, httpMethod, openApiPathString.normalised()); - if (logger.isDebugEnabled()) logger.trace("OpenApiHandler.handleRequest ends with an error."); + if (logger.isDebugEnabled()) logger.debug("OpenApiHandler.handleRequest ends with an error."); return; } @@ -227,7 +227,7 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception { auditInfo.put(Constants.OPENAPI_OPERATION_STRING, openApiOperation); exchange.putAttachment(AttachmentConstants.AUDIT_INFO, auditInfo); } - if (logger.isDebugEnabled()) logger.trace("OpenApiHandler.handleRequest ends."); + if (logger.isDebugEnabled()) logger.debug("OpenApiHandler.handleRequest ends."); Handler.next(exchange, next); } diff --git a/openapi-security/src/main/java/com/networknt/openapi/JwtVerifyHandler.java b/openapi-security/src/main/java/com/networknt/openapi/JwtVerifyHandler.java index a95f48cf..bd715656 100644 --- a/openapi-security/src/main/java/com/networknt/openapi/JwtVerifyHandler.java +++ b/openapi-security/src/main/java/com/networknt/openapi/JwtVerifyHandler.java @@ -86,13 +86,13 @@ public JwtVerifyHandler() { @Override @SuppressWarnings("unchecked") public void handleRequest(final HttpServerExchange exchange) throws Exception { - if (logger.isDebugEnabled()) logger.trace("JwtVerifyHandler.handleRequest starts."); + if (logger.isDebugEnabled()) logger.debug("JwtVerifyHandler.handleRequest starts."); String reqPath = exchange.getRequestPath(); // if request path is in the skipPathPrefixes in the config, call the next handler directly to skip the security check. if (config.getSkipPathPrefixes() != null && config.getSkipPathPrefixes().stream().anyMatch(s -> reqPath.startsWith(s))) { if(logger.isTraceEnabled()) logger.trace("Skip request path base on skipPathPrefixes for " + reqPath); Handler.next(exchange, next); - if (logger.isDebugEnabled()) logger.trace("JwtVerifyHandler.handleRequest ends."); + if (logger.isDebugEnabled()) logger.debug("JwtVerifyHandler.handleRequest ends."); return; } Map auditInfo = null; @@ -144,7 +144,7 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception { if (!config.isEnableH2c() && this.checkForH2CRequest(headerMap)) { setExchangeStatus(exchange, STATUS_METHOD_NOT_ALLOWED); - if (logger.isDebugEnabled()) logger.trace("JwtVerifyHandler.handleRequest ends with an error."); + if (logger.isDebugEnabled()) logger.debug("JwtVerifyHandler.handleRequest ends with an error."); return; } @@ -178,20 +178,20 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception { } if (logger.isTraceEnabled()) logger.trace("complete JWT verification for request path = " + exchange.getRequestURI()); - if (logger.isDebugEnabled()) logger.trace("JwtVerifyHandler.handleRequest ends."); + if (logger.isDebugEnabled()) logger.debug("JwtVerifyHandler.handleRequest ends."); Handler.next(exchange, next); } catch (InvalidJwtException e) { // only log it and unauthorized is returned. logger.error("InvalidJwtException: ", e); - if (logger.isDebugEnabled()) logger.trace("JwtVerifyHandler.handleRequest ends with an error."); + if (logger.isDebugEnabled()) logger.debug("JwtVerifyHandler.handleRequest ends with an error."); setExchangeStatus(exchange, STATUS_INVALID_AUTH_TOKEN); } catch (ExpiredTokenException e) { logger.error("ExpiredTokenException", e); - if (logger.isDebugEnabled()) logger.trace("JwtVerifyHandler.handleRequest ends with an error."); + if (logger.isDebugEnabled()) logger.debug("JwtVerifyHandler.handleRequest ends with an error."); setExchangeStatus(exchange, STATUS_AUTH_TOKEN_EXPIRED); } } else { - if (logger.isDebugEnabled()) logger.trace("JwtVerifyHandler.handleRequest ends with an error."); + if (logger.isDebugEnabled()) logger.debug("JwtVerifyHandler.handleRequest ends with an error."); setExchangeStatus(exchange, STATUS_MISSING_AUTH_TOKEN); } } diff --git a/openapi-validator/src/main/java/com/networknt/openapi/ValidatorHandler.java b/openapi-validator/src/main/java/com/networknt/openapi/ValidatorHandler.java index c2769a29..ae25977b 100644 --- a/openapi-validator/src/main/java/com/networknt/openapi/ValidatorHandler.java +++ b/openapi-validator/src/main/java/com/networknt/openapi/ValidatorHandler.java @@ -86,11 +86,11 @@ public ValidatorHandler() { @Override public void handleRequest(final HttpServerExchange exchange) throws Exception { - if (logger.isDebugEnabled()) logger.trace("ValidatorHandler.handleRequest starts."); + if (logger.isDebugEnabled()) logger.debug("ValidatorHandler.handleRequest starts."); String reqPath = exchange.getRequestPath(); // if request path is in the skipPathPrefixes in the config, call the next handler directly to skip the validation. if (config.getSkipPathPrefixes() != null && config.getSkipPathPrefixes().stream().anyMatch(s -> reqPath.startsWith(s))) { - if (logger.isDebugEnabled()) logger.trace("ValidatorHandler.handleRequest ends with skipped path " + reqPath); + if (logger.isDebugEnabled()) logger.debug("ValidatorHandler.handleRequest ends with skipped path " + reqPath); Handler.next(exchange, next); return; } @@ -102,14 +102,14 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception { openApiOperation = (OpenApiOperation)auditInfo.get(Constants.OPENAPI_OPERATION_STRING); } if(openApiOperation == null) { - if (logger.isDebugEnabled()) logger.trace("ValidatorHandler.handleRequest ends with an error."); + if (logger.isDebugEnabled()) logger.debug("ValidatorHandler.handleRequest ends with an error."); setExchangeStatus(exchange, STATUS_MISSING_OPENAPI_OPERATION); return; } RequestValidator reqV = getRequestValidator(exchange.getRequestPath()); Status status = reqV.validateRequest(requestPath, exchange, openApiOperation); if(status != null) { - if (logger.isDebugEnabled()) logger.trace("ValidatorHandler.handleRequest ends with an error."); + if (logger.isDebugEnabled()) logger.debug("ValidatorHandler.handleRequest ends with an error."); setExchangeStatus(exchange, status); if(config.logError) { logger.error("There is an Validation Error:"); @@ -120,7 +120,7 @@ public void handleRequest(final HttpServerExchange exchange) throws Exception { if(config.validateResponse) { validateResponse(exchange, openApiOperation); } - if (logger.isDebugEnabled()) logger.trace("ValidatorHandler.handleRequest ends."); + if (logger.isDebugEnabled()) logger.debug("ValidatorHandler.handleRequest ends."); Handler.next(exchange, next); }