I am modifying the standard *HandleHTTPRequest* Processor in NiFi to add Oauth2 authentication. The idea is to accept scopes and client_id as part of the processor setup and validate the incoming JWT token against these scopes and client_id.
i am trying to send a JSON Response when the scope or client_id is incorrect as below
String newContent = "{ \"message\" : \"Unauthorized\" }";
container.getResponse().setStatus(HttpServletResponse.SC_UNAUTHORIZED);
container.getResponse().setContentType("application/json");
container.getResponse().getWriter().write(newContent);
return;
the request is hung and times out. Is this because HandleHttpRequest can't send the response back and I have to use HandleHTTPResponse processor to process the response?
The below code sends a HTML Response which I want to change to a proper JSON.
container.getResponse().sendError(HttpServletResponse.SC_UNAUTHORIZED,newContent);