Package org.apache.coyote.tomcat5

Examples of org.apache.coyote.tomcat5.CoyoteRequest


     */
    private static void addEasHeaders(HttpConnection connection, Request request)
        throws IOException {
        // GLASSFISH Request/Response does not extend HttpRequest/Response so
        // we need to cast to Coyote Request/Response
        CoyoteRequest cRequest = (CoyoteRequest) request;

        // The front-end will add a HTTP header with information required for
        // single signon
        // e.g. x-eas-usercentric-ipcontext:
        // clientip=1.2.3.4,clientport=5000,serverip=5.6.7.8,serverport=9080
        String contextValue = "clientip=" + cRequest.getRemoteAddr() +
            ",clientport=" + cRequest.getRemotePort() + ",serverip=" +
            cRequest.getLocalAddr() + ",serverport=" + cRequest.getLocalPort();

        connection.printLine("x-eas-usercentric-ipcontext: " + contextValue);

        // Send information to backend TrafficProcessor.
        connection.printLine(EAS_HEADER_FRONTEND_IS_SECURE + ": " +
            cRequest.isSecure());
        connection.printLine(EAS_HEADER_FRONTEND_LOCAL_ADDRESS + ": " +
            cRequest.getLocalAddr());
        connection.printLine(EAS_HEADER_FRONTEND_LOCAL_PORT + ": " +
            cRequest.getLocalPort());
    }
View Full Code Here


     */
    private static void sendInternalError(Request request, Response response,
        HttpHost host) throws IOException {
        // GLASSFISH Request/Response does not extend HttpRequest/Response so
        // we need to cast to Coyote Request/Response
        CoyoteRequest cRequest = (CoyoteRequest) request;
        CoyoteResponse cResponse = (CoyoteResponse) response;

        // If the reponse is still not committed...
        if (!cResponse.isCommitted()) {
            // Failed to proxy this request, inform client.
            if (log.isLoggable(Level.FINE)) {
                log.log(Level.FINE,
                    "The attempt to proxy '" + cRequest.getRequestURL() +
                    "' to '" + host + "' failed. " +
                    "Responding with 500 Internal Server Error.");
            }

            cResponse.sendError(CoyoteResponse.SC_INTERNAL_SERVER_ERROR);
View Full Code Here

                                HttpServletRequest request,
                                HttpServletResponse response)
    {
        // Need real request object not facade
       
        CoyoteRequest req = getUnwrappedCoyoteRequest(request);
        if (req == null) {
            return Boolean.valueOf(false);
        }
       
        // Try to login - this will set up security context on success
        LoginContextDriver.login(user, password, realm);

        // Create a WebPrincipal for tomcat and store in current request
        // This will allow programmatic authorization later in this request
        // to work as expected.

        SecurityContext secCtx = SecurityContext.getCurrent();
        assert (secCtx != null); // since login succeeded above

        WebPrincipal principal = new WebPrincipal(user, password, secCtx);
        req.setUserPrincipal(principal);
        req.setAuthType(WEBAUTH_PROGRAMMATIC);

        if(logger.isLoggable(Level.FINE)){
            logger.log(Level.FINE, "Programmatic login set principal in http request to: "+
                      user);
        }
View Full Code Here

    /**
     * Return the unwrapped <code>CoyoteRequest</code> object.
     */
    private static CoyoteRequest getUnwrappedCoyoteRequest(HttpServletRequest request){       
        CoyoteRequest req = null;
        ServletRequest servletRequest = request;
        try{

            ServletRequest prevRequest = null;
            while (servletRequest != prevRequest
View Full Code Here

    public static Boolean logout(HttpServletRequest request,
                                 HttpServletResponse response) throws Exception
    {
        // Need real request object not facade
       
        CoyoteRequest req = getUnwrappedCoyoteRequest(request);
        if (req == null) {
            return Boolean.valueOf(false);
        }
       
        // Logout - clears out security context

        LoginContextDriver.logout();
        // Remove principal and auth type from request

        req.setUserPrincipal(null);
        req.setAuthType(null);
        if(logger.isLoggable(Level.FINE)){
            logger.log(Level.FINE, "Programmatic logout removed principal from request.");
        }

        // Remove from session if possible.
View Full Code Here

        // Get the FilterChain Here
        ApplicationFilterFactory factory = ApplicationFilterFactory.getInstance();
        ApplicationFilterChain filterChain = factory.createFilterChain(request,
                                                                wrapper,servlet);

        CoyoteRequestFacade requestFacade = state.wrapRequest.getRequestFacade();

        // Call the service() method for the allocated servlet instance
        try {
            String jspFile = wrapper.getJspFile();
            if (jspFile != null) {
                request.setAttribute(Globals.JSP_FILE_ATTR, jspFile);
            }
            support.fireInstanceEvent(InstanceEvent.BEFORE_DISPATCH_EVENT,
                                      servlet, request, response);
            // for includes/forwards
            /* IASRI 4665318
            if ((servlet != null) && (filterChain != null)) {
            */
            // START IASRI 4665318
            if (servlet != null) {
            // END IASRI 4665318
                // START OF S1AS 4703023
                requestFacade.incrementDispatchDepth();
                if (requestFacade.isMaxDispatchDepthReached()) {
                    throw new ServletException(sm.getString(
                        "applicationDispatcher.maxDispatchDepthReached",
                        new Object[] { Integer.valueOf(
                            CoyoteRequest.getMaxDispatchDepth())}));
                }
                // END OF S1AS 4703023
                /* IASRI 4665318
                filterChain.doFilter(request, response);
                */
                // START IASRI 4665318
                if (filterChain != null)
                    filterChain.doFilter(request, response);
                else {
                    ApplicationFilterChain.servletService(request, response,
                                                          servlet, support);
                }
                // END IASRI 4665318
            }
            // Servlet Service Method is called by the FilterChain
            support.fireInstanceEvent(InstanceEvent.AFTER_DISPATCH_EVENT,
                                      servlet, request, response);
        } catch (ClientAbortException e) {
            support.fireInstanceEvent(InstanceEvent.AFTER_DISPATCH_EVENT,
                                      servlet, request, response);
            ioException = e;
        } catch (IOException e) {
            support.fireInstanceEvent(InstanceEvent.AFTER_DISPATCH_EVENT,
                                      servlet, request, response);
            log(sm.getString("applicationDispatcher.serviceException",
                             wrapper.getName()), e);
            ioException = e;
        } catch (UnavailableException e) {
            support.fireInstanceEvent(InstanceEvent.AFTER_DISPATCH_EVENT,
                                      servlet, request, response);
            log(sm.getString("applicationDispatcher.serviceException",
                             wrapper.getName()), e);
            servletException = e;
            wrapper.unavailable(e);
        } catch (ServletException e) {
            support.fireInstanceEvent(InstanceEvent.AFTER_DISPATCH_EVENT,
                                      servlet, request, response);
            Throwable rootCause = StandardWrapper.getRootCause(e);
            if (!(rootCause instanceof ClientAbortException)) {
                log(sm.getString("applicationDispatcher.serviceException",
                    wrapper.getName()), rootCause);
            }
            servletException = e;
        } catch (RuntimeException e) {
            support.fireInstanceEvent(InstanceEvent.AFTER_DISPATCH_EVENT,
                                      servlet, request, response);
            log(sm.getString("applicationDispatcher.serviceException",
                             wrapper.getName()), e);
            runtimeException = e;
        // START OF S1AS 4703023
        } finally {
            requestFacade.decrementDispatchDepth();
        // END OF S1AS 4703023
        }

        // Release the filter chain (if any) for this request
        try {
View Full Code Here

        if (smc!= null) {
            Iterator iter = smc.getPropertyNames();
            if ( iter == null) {
                return;
            }
             CoyoteRequestFacade httpReq =
                  (CoyoteRequestFacade) smc.getProperty(HTTP_REQUEST);
             String clientHost = null;
             if (httpReq != null) {
                 clientHost = httpReq.getRemoteAddr();
                  trace.setClientHost(clientHost);
            }
        }
    }
View Full Code Here

            // the StandardEngineValve
            return;
        }
       
        super.setContext(ctx);
        CoyoteResponse response = (CoyoteResponse) getResponse();
        // Assert response!=null
        if (response != null) {
            String[] cacheControls = ((PwcWebModule) ctx).getCacheControls();
            for (int i=0; cacheControls!=null && i<cacheControls.length; i++) {
                response.addHeader("Cache-Control", cacheControls[i]);
            }
        }

        sunWebXmlChecked = false;
    }
View Full Code Here

     */
    private static void proxyResponse(HttpConnection connection,
        Response response) throws IOException {
        // GLASSFISH Request/Response does not extend HttpRequest/Response so
        // we need to cast to Coyote Request/Response
        CoyoteResponse cResponse = (CoyoteResponse) response;

        boolean chunked = false;
        boolean forcedClose = false;
        int contentLength = -1;

        try {
            // Transfer the status code and message to the response.
            int code = setStatusCode(connection, response);

            if (code == CoyoteResponse.SC_CONTINUE) {
                cResponse.sendAcknowledgement();

                return;
            }

            // Parse headers
            MimeHeaders headers = cResponse.getCoyoteResponse().getMimeHeaders();

            while (true) {
                // Read a header line.
                String header = connection.readLine();

View Full Code Here

     */
    private static int setStatusCode(HttpConnection connection,
        Response response) throws IOException {
        // GLASSFISH Request/Response does not extend HttpRequest/Response so
        // we need to cast to Coyote Request/Response
        CoyoteResponse cResponse = (CoyoteResponse) response;

        String statusLine = readStatusLine(connection);

        try {
            Matcher matcher = statusLinePattern.matcher(statusLine);

            if (matcher.matches()) {
                int code = Integer.parseInt(matcher.group(1));
                String message = matcher.group(2);

                // Set the response code in the response to return.
                cResponse.getResponse().setStatus(code);
                cResponse.getCoyoteResponse().setMessage(message);

                return code;
            }
        } catch (NumberFormatException e) {
            // Fall through.
View Full Code Here

TOP

Related Classes of org.apache.coyote.tomcat5.CoyoteRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.