use of io.milton.servlet.ServletRequest in project dcache by dCache.
the class MiltonHandler method handle.
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
try (CDC ignored = CDC.reset(_myAddress)) {
Transfer.initSession(false, false);
ServletContext context = ContextHandler.getCurrentContext();
if ("USERINFO".equals(request.getMethod())) {
response.sendError(501);
} else {
Subject subject = Subject.getSubject(AccessController.getContext());
ServletRequest req = new DcacheServletRequest(request, context);
ServletResponse resp = new DcacheServletResponse(response);
/* Although we don't rely on the authorization tag
* ourselves, Milton uses it to detect that the request
* was preauthenticated.
*/
req.setAuthorization(new Auth(Subjects.getUserName(subject), subject));
baseRequest.setHandled(true);
_httpManager.process(req, resp);
}
if (!request.isAsyncStarted()) {
response.getOutputStream().flush();
response.flushBuffer();
}
}
}
Aggregations