当前位置: 首页>>代码示例>>Java>>正文


Java ServletRequestContext.getServletResponse方法代码示例

本文整理汇总了Java中io.undertow.servlet.handlers.ServletRequestContext.getServletResponse方法的典型用法代码示例。如果您正苦于以下问题:Java ServletRequestContext.getServletResponse方法的具体用法?Java ServletRequestContext.getServletResponse怎么用?Java ServletRequestContext.getServletResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.undertow.servlet.handlers.ServletRequestContext的用法示例。


在下文中一共展示了ServletRequestContext.getServletResponse方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleRequest

import io.undertow.servlet.handlers.ServletRequestContext; //导入方法依赖的package包/类
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
    final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
    ServletRequest request = servletRequestContext.getServletRequest();
    if (request.getDispatcherType() == DispatcherType.REQUEST) {
        List<SingleConstraintMatch> constraints = servletRequestContext.getRequiredConstrains();
        SecurityContext sc = exchange.getSecurityContext();
        if (!authorizationManager.canAccessResource(constraints, sc.getAuthenticatedAccount(), servletRequestContext.getCurrentServlet().getManagedServlet().getServletInfo(), servletRequestContext.getOriginalRequest(), servletRequestContext.getDeployment())) {

            HttpServletResponse response = (HttpServletResponse) servletRequestContext.getServletResponse();
            response.sendError(StatusCodes.FORBIDDEN);
            return;
        }
    }
    next.handleRequest(exchange);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:ServletSecurityRoleHandler.java

示例2: handleRedirectBack

import io.undertow.servlet.handlers.ServletRequestContext; //导入方法依赖的package包/类
@Override
protected void handleRedirectBack(final HttpServerExchange exchange) {
    final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
    HttpServletResponse resp = (HttpServletResponse) servletRequestContext.getServletResponse();
    HttpSessionImpl httpSession = servletRequestContext.getCurrentServletContext().getSession(exchange, false);
    if (httpSession != null) {
        Session session;
        if (System.getSecurityManager() == null) {
            session = httpSession.getSession();
        } else {
            session = AccessController.doPrivileged(new HttpSessionImpl.UnwrapSessionAction(httpSession));
        }
        String path = (String) session.getAttribute(SESSION_KEY);
        if (path != null) {
            try {
                resp.sendRedirect(path);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:ServletFormAuthenticationMechanism.java

示例3: serveLoginPage

import io.undertow.servlet.handlers.ServletRequestContext; //导入方法依赖的package包/类
/**
    * Forward to the login page with a specific error message. Avoids a redirect. Based on the
    * ServletFormAuthenticationMechanism method. The location should be relative to the current
    * context and start with "/" e.g. /login.jsp
    * 
    * @throws IOException
    * @throws ServletException
    */
   protected Integer serveLoginPage(final HttpServerExchange exchange, final String location) throws ServletException,
    IOException {

ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
HttpServletRequest request = (HttpServletRequest) context.getServletRequest();
HttpServletResponse response = (HttpServletResponse) context.getServletResponse();

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");

request.getRequestDispatcher(location).forward(request, response);
return null;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:SsoHandler.java

示例4: startAsync

import io.undertow.servlet.handlers.ServletRequestContext; //导入方法依赖的package包/类
@Override
public AsyncContext startAsync() throws IllegalStateException {
    if (!isAsyncSupported()) {
        throw UndertowServletMessages.MESSAGES.startAsyncNotAllowed();
    } else if (asyncStarted) {
        throw UndertowServletMessages.MESSAGES.asyncAlreadyStarted();
    }
    asyncStarted = true;
    final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
    return asyncContext = new AsyncContextImpl(exchange, servletRequestContext.getServletRequest(), servletRequestContext.getServletResponse(), servletRequestContext, false, asyncContext);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:HttpServletRequestImpl.java

示例5: handleRequest

import io.undertow.servlet.handlers.ServletRequestContext; //导入方法依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
    final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
    final AuthorizationManager authorizationManager = servletRequestContext.getDeployment().getDeploymentInfo().getAuthorizationManager();

    TransportGuaranteeType connectionGuarantee = servletRequestContext.getOriginalRequest().isSecure() ? TransportGuaranteeType.CONFIDENTIAL : TransportGuaranteeType.NONE;
    TransportGuaranteeType transportGuarantee = authorizationManager.transportGuarantee(connectionGuarantee,
            servletRequestContext.getTransportGuarenteeType(), servletRequestContext.getOriginalRequest());
    servletRequestContext.setTransportGuarenteeType(transportGuarantee);

    if (TransportGuaranteeType.REJECTED == transportGuarantee) {
        HttpServletResponse response = (HttpServletResponse) servletRequestContext.getServletResponse();
        response.sendError(StatusCodes.FORBIDDEN);
        return;
    }
    super.handleRequest(exchange);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:ServletConfidentialityConstraintHandler.java

示例6: extractHttpServletResponse

import io.undertow.servlet.handlers.ServletRequestContext; //导入方法依赖的package包/类
/**
 * Extracts the HTTP servlet response from the HTTP server exchange.
 *
 * @param exchange the HTTP server exchange.
 * @return the HTTP servlet response.
 */
private static HttpServletResponse extractHttpServletResponse(HttpServerExchange exchange) {
    ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
    return (HttpServletResponse) context.getServletResponse();
}
 
开发者ID:akihyro,项目名称:logback-access-spring-boot-starter,代码行数:11,代码来源:UndertowLogbackAccessEvent.java


注:本文中的io.undertow.servlet.handlers.ServletRequestContext.getServletResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。