Search in sources :

Example 1 with ServletRequest

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();
        }
    }
}
Also used : ServletRequest(io.milton.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletResponse(io.milton.servlet.ServletResponse) HttpServletResponse(javax.servlet.http.HttpServletResponse) CDC(dmg.cells.nucleus.CDC) Auth(io.milton.http.Auth) ServletContext(javax.servlet.ServletContext) Subject(javax.security.auth.Subject)

Aggregations

CDC (dmg.cells.nucleus.CDC)1 Auth (io.milton.http.Auth)1 ServletRequest (io.milton.servlet.ServletRequest)1 ServletResponse (io.milton.servlet.ServletResponse)1 Subject (javax.security.auth.Subject)1 ServletContext (javax.servlet.ServletContext)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1