use of javax.servlet.ServletResponse in project undertow by undertow-io.
the class FilterHandler method handleRequest.
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
ServletRequest request = servletRequestContext.getServletRequest();
ServletResponse response = servletRequestContext.getServletResponse();
DispatcherType dispatcher = servletRequestContext.getDispatcherType();
Boolean supported = asyncSupported.get(dispatcher);
if (supported != null && !supported) {
servletRequestContext.setAsyncSupported(false);
}
final List<ManagedFilter> filters = this.filters.get(dispatcher);
if (filters == null) {
next.handleRequest(exchange);
} else {
final FilterChainImpl filterChain = new FilterChainImpl(exchange, filters, next, allowNonStandardWrappers);
filterChain.doFilter(request, response);
}
}
use of javax.servlet.ServletResponse in project undertow by undertow-io.
the class ServletFormAuthenticationMechanism method servePage.
@Override
protected Integer servePage(final HttpServerExchange exchange, final String location) {
final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
ServletRequest req = servletRequestContext.getServletRequest();
ServletResponse resp = servletRequestContext.getServletResponse();
RequestDispatcher disp = req.getRequestDispatcher(location);
//make sure the login page is never cached
exchange.getResponseHeaders().add(Headers.CACHE_CONTROL, "no-cache, no-store, must-revalidate");
exchange.getResponseHeaders().add(Headers.PRAGMA, "no-cache");
exchange.getResponseHeaders().add(Headers.EXPIRES, "0");
final FormResponseWrapper respWrapper = exchange.getStatusCode() != OK && resp instanceof HttpServletResponse ? new FormResponseWrapper((HttpServletResponse) resp) : null;
try {
disp.forward(req, respWrapper != null ? respWrapper : resp);
} catch (ServletException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
return respWrapper != null ? respWrapper.getStatus() : null;
}
use of javax.servlet.ServletResponse in project gerrit by GerritCodeReview.
the class HttpPluginServlet method service.
@Override
public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
List<String> parts = Lists.newArrayList(Splitter.on('/').limit(3).omitEmptyStrings().split(Strings.nullToEmpty(RequestUtil.getEncodedPathInfo(req))));
if (isApiCall(req, parts)) {
managerApi.service(req, res);
return;
}
String name = parts.get(0);
final PluginHolder holder = plugins.get(name);
if (holder == null) {
CacheHeaders.setNotCacheable(res);
res.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
HttpServletRequest wr = wrapper.create(req, name);
FilterChain chain = new FilterChain() {
@Override
public void doFilter(ServletRequest req, ServletResponse res) throws IOException {
onDefault(holder, (HttpServletRequest) req, (HttpServletResponse) res);
}
};
if (holder.filter != null) {
holder.filter.doFilter(wr, res, chain);
} else {
chain.doFilter(wr, res);
}
}
use of javax.servlet.ServletResponse in project gerrit by GerritCodeReview.
the class ProjectBasicAuthFilter method doFilter.
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
Response rsp = new Response((HttpServletResponse) response);
if (verify(req, rsp)) {
chain.doFilter(req, rsp);
}
}
use of javax.servlet.ServletResponse in project gerrit by GerritCodeReview.
the class ProjectOAuthFilter method doFilter.
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
Response rsp = new Response((HttpServletResponse) response);
if (verify(req, rsp)) {
chain.doFilter(req, rsp);
}
}
Aggregations