class TppRedirectUriBodyValidatorImpl implements BodyValidator {

    @Override
    public MessageError validate(HttpServletRequest request, MessageError messageError) {
        if (isRedirectScaApproach()) {
            String tppRedirectUriHeader = request.getHeader(TPP_REDIRECT_URI);
            Map<String, String> headers = Collections.list(request.getHeaderNames())
                                              .stream()
                                              .collect(Collectors.toMap(String::toLowerCase, request::getHeader));

            if (!headers.containsKey(TPP_REDIRECT_URI)) {
                errorBuildingService.enrichMessageError(messageError, TppMessageInformation.of(FORMAT_ERROR_ABSENT_HEADER, TPP_REDIRECT_URI));
            } else if (tppRedirectUriHeader == null) {
                errorBuildingService.enrichMessageError(messageError, TppMessageInformation.of(FORMAT_ERROR_NULL_HEADER, TPP_REDIRECT_URI));
            } else if (StringUtils.isBlank(tppRedirectUriHeader)) {
                errorBuildingService.enrichMessageError(messageError, TppMessageInformation.of(FORMAT_ERROR_BLANK_HEADER, TPP_REDIRECT_URI));
            }
        }

        return messageError;
    }

}