diff --git a/kernel/kernel-websubclient-api/src/main/java/io/mosip/kernel/websub/api/filter/IntentVerificationFilter.java b/kernel/kernel-websubclient-api/src/main/java/io/mosip/kernel/websub/api/filter/IntentVerificationFilter.java index b60647317b..9dc7bb79ff 100644 --- a/kernel/kernel-websubclient-api/src/main/java/io/mosip/kernel/websub/api/filter/IntentVerificationFilter.java +++ b/kernel/kernel-websubclient-api/src/main/java/io/mosip/kernel/websub/api/filter/IntentVerificationFilter.java @@ -51,46 +51,48 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse throws ServletException, IOException { logger.info("inside doFilterInternal"); logger.info("HttpServletRequest request- "+request); - String topic=matchCallbackURL(request.getRequestURI()); - if (request.getMethod().equals(HttpMethod.GET.name()) && topic!=null) { - String topicReq = request.getParameter(WebSubClientConstants.HUB_TOPIC); - String modeReq = request.getParameter(WebSubClientConstants.HUB_MODE); - String mode = request.getParameter("intentMode"); - if(modeReq.equals("denied")) { - String reason = request.getParameter("hub.reason"); - reason = reason.replaceAll("[\n\r\t]", " - "); - LOGGER.error("intent verification failed : {}",reason); - response.setStatus(HttpServletResponse.SC_NOT_FOUND); - response.getWriter().flush(); - response.getWriter().close(); - } - if (intentVerifier.isIntentVerified(topic, - mode, topicReq, modeReq)) { - response.setStatus(HttpServletResponse.SC_ACCEPTED); - try { - String challange =request.getParameter(WebSubClientConstants.HUB_CHALLENGE); - String encodedChallange = Encode.forHtml(challange); - response.getWriter().write(encodedChallange); + if(!request.getRequestURI().contains("health")) { + String topic = matchCallbackURL(request.getRequestURI()); + if (request.getMethod().equals(HttpMethod.GET.name()) && topic != null) { + String topicReq = request.getParameter(WebSubClientConstants.HUB_TOPIC); + String modeReq = request.getParameter(WebSubClientConstants.HUB_MODE); + String mode = request.getParameter("intentMode"); + if (modeReq.equals("denied")) { + String reason = request.getParameter("hub.reason"); + reason = reason.replaceAll("[\n\r\t]", " - "); + LOGGER.error("intent verification failed : {}", reason); + response.setStatus(HttpServletResponse.SC_NOT_FOUND); + response.getWriter().flush(); + response.getWriter().close(); + } + if (intentVerifier.isIntentVerified(topic, + mode, topicReq, modeReq)) { + response.setStatus(HttpServletResponse.SC_ACCEPTED); + try { + String challange = request.getParameter(WebSubClientConstants.HUB_CHALLENGE); + String encodedChallange = Encode.forHtml(challange); + response.getWriter().write(encodedChallange); + response.getWriter().flush(); + response.getWriter().close(); + } catch (IOException exception) { + LOGGER.error("error received while writing challange back" + exception.getMessage()); + throw new WebSubClientException(WebSubClientErrorCode.IO_ERROR.getErrorCode(), + WebSubClientErrorCode.IO_ERROR.getErrorMessage().concat(exception.getMessage())); + } + + } else { + topicReq = topicReq.replaceAll("[\n\r\t]", " - "); + modeReq = modeReq.replaceAll("[\n\r\t]", " - "); + mode = mode.replaceAll("[\n\r\t]", " - "); + LOGGER.error("intent verification failed: {} {} {} {}", topic, mode, topicReq, modeReq); + response.setStatus(HttpServletResponse.SC_NOT_FOUND); response.getWriter().flush(); response.getWriter().close(); - } catch (IOException exception) { - LOGGER.error("error received while writing challange back"+exception.getMessage()); - throw new WebSubClientException(WebSubClientErrorCode.IO_ERROR.getErrorCode(), - WebSubClientErrorCode.IO_ERROR.getErrorMessage().concat(exception.getMessage())); } } else { - topicReq = topicReq.replaceAll("[\n\r\t]", " - "); - modeReq = modeReq.replaceAll("[\n\r\t]", " - "); - mode = mode.replaceAll("[\n\r\t]", " - "); - LOGGER.error("intent verification failed: {} {} {} {}",topic,mode,topicReq,modeReq); - response.setStatus(HttpServletResponse.SC_NOT_FOUND); - response.getWriter().flush(); - response.getWriter().close(); + filterChain.doFilter(request, response); } - - } else { - filterChain.doFilter(request, response); } }