Class RequestValidationInterceptor

  • All Implemented Interfaces:
    org.springframework.web.servlet.AsyncHandlerInterceptor, org.springframework.web.servlet.HandlerInterceptor

    @Component
    public class RequestValidationInterceptor
    extends org.springframework.web.servlet.handler.HandlerInterceptorAdapter
    This interceptor is used for headers, query and path parameters and body validation of incoming HTTP requests. The main purposes: collect the list of human-readable errors in case of using wrong headers, parameters or JSON fields (ex, IBAN has wrong format, some mandatory header is missing etc). Each error in the incoming request (validated in accordance with the PSD2 documentation) results in one text message in the response.

    Please note, this interceptor can only return the response with the HTTP code 400 (FORMAT ERROR).

    No business validation is present here, as business validation requires some specific options to process (ex, SCA approach, bank-profile configuration). It is implemented in the controllers and services layers.

    • Constructor Detail

      • RequestValidationInterceptor

        public RequestValidationInterceptor()
    • Method Detail

      • preHandle

        public boolean preHandle​(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response,
                                 Object handler)
                          throws IOException
        Specified by:
        preHandle in interface org.springframework.web.servlet.HandlerInterceptor
        Overrides:
        preHandle in class org.springframework.web.servlet.handler.HandlerInterceptorAdapter
        Throws:
        IOException