/** * Only allow the request through if successfully authenticated or if authentication is not required. * * @see io.undertow.server.HttpHandler#handleRequest(io.undertow.server.HttpServerExchange) */ @Override public void handleRequest(final HttpServerExchange exchange) throws Exception { if(exchange.isInIoThread()) { exchange.dispatch(this); return; } SecurityContext context = exchange.getSecurityContext(); if (context.authenticate()) { if(!exchange.isComplete()) { next.handleRequest(exchange); } } else { exchange.endExchange(); } }
/** * Only allow the request through if successfully authenticated or if authentication is not required. * * @see io.undertow.server.HttpHandler#handleRequest(io.undertow.server.HttpServerExchange) */ @Override public void handleRequest(final HttpServerExchange exchange) throws Exception { SecurityContext context = exchange.getSecurityContext(); if (context.authenticate()) { if(!exchange.isComplete()) { next.handleRequest(exchange); } } else { exchange.endExchange(); } } }
/** * Only allow the request through if successfully authenticated or if authentication is not required. * * @throws java.lang.Exception * @see io.undertow.server.HttpHandler#handleRequest(io.undertow.server.HttpServerExchange) */ @Override public void handleRequest(HttpServerExchange exchange, RequestContext context) throws Exception { if(exchange.isInIoThread()) { exchange.dispatch(this); return; } SecurityContext rcontext = exchange.getSecurityContext(); if (rcontext.authenticate()) { if(!exchange.isComplete()) { next(exchange, context); } } else { exchange.endExchange(); } }
/** * Only allow the request through if successfully authenticated or if authentication is not required. * * @see io.undertow.server.HttpHandler#handleRequest(io.undertow.server.HttpServerExchange) */ @Override public void handleRequest(final HttpServerExchange exchange) throws Exception { if(exchange.isInIoThread()) { exchange.dispatch(this); return; } SecurityContext context = exchange.getSecurityContext(); if (context.authenticate()) { if(!exchange.isComplete()) { next.handleRequest(exchange); } } else { exchange.endExchange(); } }
@Override public boolean authenticate(final HttpServletResponse response) throws IOException, ServletException { if (response.isCommitted()) { throw UndertowServletMessages.MESSAGES.responseAlreadyCommited(); } SecurityContext sc = exchange.getSecurityContext(); sc.setAuthenticationRequired(); // TODO: this will set the status code and headers without going through any potential // wrappers, is this a problem? if (sc.authenticate()) { if (sc.isAuthenticated()) { return true; } else { throw UndertowServletMessages.MESSAGES.authenticationFailed(); } } else { if(!exchange.isResponseStarted() && exchange.getStatusCode() == 200) { throw UndertowServletMessages.MESSAGES.authenticationFailed(); } else { return false; } } }
/** * Only allow the request through if successfully authenticated or if authentication is not required. * * @see io.undertow.server.HttpHandler#handleRequest(io.undertow.server.HttpServerExchange) */ @Override public void handleRequest(final HttpServerExchange exchange) throws Exception { if(exchange.isInIoThread()) { exchange.dispatch(this); return; } SecurityContext context = exchange.getSecurityContext(); if (context.authenticate()) { if(!exchange.isComplete()) { next.handleRequest(exchange); } } else { exchange.endExchange(); } }
/** * Only allow the request through if successfully authenticated or if authentication is not required. * * @see io.undertow.server.HttpHandler#handleRequest(io.undertow.server.HttpServerExchange) */ @Override public void handleRequest(final HttpServerExchange exchange) throws Exception { if(exchange.isInIoThread()) { exchange.dispatch(this); return; } SecurityContext context = exchange.getSecurityContext(); if (context.authenticate()) { if(!exchange.isComplete()) { next.handleRequest(exchange); } } else { if(exchange.getStatusCode() >= StatusCodes.BAD_REQUEST && !exchange.isComplete()) { ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); src.getOriginalResponse().sendError(exchange.getStatusCode()); } else { exchange.endExchange(); } } }