List of usage examples for javax.servlet.http HttpServletRequest getRequestedSessionId
public String getRequestedSessionId();
From source file:eu.eidas.node.AbstractNodeServlet.java
/** * Sets HTTPOnly Header on the session to prevent cookies from being accessed through * client-side script.//from w w w. ja va 2s . c o m * * @param renewSession indicates that the session cookie will be renewed */ protected final void setHTTPOnlyHeaderToSession(final boolean renewSession, HttpServletRequest request, HttpServletResponse response) { if (request != null && request.getSession(false) != null) { // Renewing the session if necessary String currentSession = null; String messageLog = null; if (renewSession) { currentSession = sessionIdRegenerationInWebApp(request); messageLog = "http session Renewed : {}"; } else { currentSession = request.getSession().getId(); messageLog = "http session obtained from request : {}"; } MDC.put(LoggingMarkerMDC.MDC_SESSIONID, currentSession); getLogger().info(LoggingMarkerMDC.SECURITY_SUCCESS, messageLog, currentSession); // changing session cookie to http only cookie if (request.getCookies() != null && request.isRequestedSessionIdFromCookie()) { //Session Id requested by the client, obtained from the cookie final String requestedSessionId = request.getRequestedSessionId(); for (Cookie cookie : request.getCookies()) { getLogger().debug("Treating cookie [domain][path][name][value] : [{}][{}][{}][{}]", cookie.getName(), cookie.getPath(), cookie.getName(), cookie.getValue()); if (currentSession.equals(requestedSessionId)) { // Removes old version boolean isSecure = request.isSecure(); getLogger().debug("Cookie==session : Remove and replacing with HttpOnly {}", cookie.toString()); getLogger().debug("Is using SSL?", isSecure); //TODO: when migrating to servlet 3, use the cookie interface calls below instead of writing the http header // //NOSONAR cookie.setMaxAge(0); //NOSONAR cookie.setPath(getServletContext().getContextPath()); //NOSONAR cookie.setDomain(request.getServerName()); //NOSONAR cookie.setSecure(isSecure); //NOSONAR cookie.setHttpOnly(true); //NOSONAR response.addCookie(cookie); // Create new one httpOnly StringBuilder httpOnlyCookie = new StringBuilder(cookie.getName()) .append(EIDASValues.EQUAL.toString()).append(cookie.getValue()) .append(EIDASValues.SEMICOLON.toString()).append(" ") .append(EIDASValues.DOMAIN.toString()).append(EIDASValues.EQUAL.toString()) .append(request.getServerName()).append(EIDASValues.SEMICOLON.toString()) .append(" ").append(EIDASValues.PATH.toString()) .append(EIDASValues.EQUAL.toString()).append(getServletContext().getContextPath()) .append(EIDASValues.SEMICOLON.toString()).append(" ") .append(EIDASValues.HTTP_ONLY.toString()).append(EIDASValues.SEMICOLON.toString()) .append(isSecure ? EIDASValues.SECURE.toString() : ""); response.setHeader(EIDASValues.SETCOOKIE.toString(), httpOnlyCookie.toString()); } } } //cookie _csrf // request.setAttribute("_csrf_header", "X-CSRF-TOKEN"); // UUID idOne = UUID.randomUUID(); // LOG.info("generate csrf id="+idOne); // request.setAttribute("_csrf", idOne); response.setHeader("_csrf_header", "X-CSRF-TOKEN"); UUID idOne = UUID.randomUUID(); UUID idTwo = UUID.randomUUID(); getLogger().info("generate csrf id1=" + idOne + " id2=" + idTwo); Cookie gato = new Cookie("_csrf", idOne.toString()); response.addCookie(gato); response.setHeader("X-CSRF-TOKEN", idTwo.toString()); } else { getLogger().warn(LoggingMarkerMDC.SECURITY_FAILURE, "Request or Session is null !"); } }
From source file:net.lightbody.bmp.proxy.jetty.jetty.servlet.AbstractSessionManager.java
private String newSessionId(HttpServletRequest request, long created) { synchronized (__allSessions) { // A requested session ID can only be used if it is in the global map of // ID but not in this contexts map. Ie it is an ID in use by another context // in this server and thus we are doing a cross context dispatch. if (_crossContextSessionIDs) { String requested_id = (String) request.getAttribute(__NEW_SESSION_ID); if (requested_id == null) requested_id = request.getRequestedSessionId(); if (requested_id != null && requested_id != null && __allSessions.containsKey(requested_id) && !_sessions.containsKey(requested_id)) return requested_id; }/*w ww . java 2s. com*/ // pick a new unique ID! String id = null; while (id == null || id.length() == 0 || __allSessions.containsKey(id)) { long r = _weakRandom ? (hashCode() ^ Runtime.getRuntime().freeMemory() ^ _random.nextInt() ^ (((long) request.hashCode()) << 32)) : _random.nextLong(); r ^= created; if (request != null && request.getRemoteAddr() != null) r ^= request.getRemoteAddr().hashCode(); if (r < 0) r = -r; id = Long.toString(r, 36); String worker = (String) request.getAttribute("net.lightbody.bmp.proxy.jetty.http.ajp.JVMRoute"); if (worker != null) id += "." + worker; else if (_workerName != null) id += "." + _workerName; } return id; } }
From source file:de.itsvs.cwtrpc.security.RpcLogoutFilter.java
@Override protected void process(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { final Authentication authentication; boolean ok = false; authentication = SecurityContextHolder.getContext().getAuthentication(); if (!CwtRpcUtils.isRpcSessionInvalidationPolicySet(request)) { CwtRpcUtils.saveRpcSessionInvalidationPolicy(request, createRpcSessionInvalidationPolicy(request, response, authentication)); } else {// w ww .j a v a2 s .c o m log.debug("RPC session invalidation policy " + "has already been applied."); } try { if (authentication != null) { if (log.isDebugEnabled()) { log.debug("Logging out user '" + authentication.getName() + "'"); } chain.doFilter(request, response); if (getLogoutHandlers() != null) { for (LogoutHandler handler : getLogoutHandlers()) { handler.logout(request, response, authentication); } } } else { if ((request.getRequestedSessionId() == null) || request.isRequestedSessionIdValid()) { log.debug("Request does not belong to " + "an authenticated session"); getLogoutFailureHandler().onLogoutFailure(request, response, new CwtRpcException("Request does not belong to " + "an authenticated session.")); return; } log.debug("Request does not include a valid " + "authentication. It seems to be a result of a " + "session timeout. Sending success response."); } /* * If session has not been invalidated up to now, this is the last * possibility to invalidate the session. The logout success hander * may send the response to the client. The session should be * invalidated before sending the response. */ if (isInvalidateSession()) { invalidateSession(request); } getLogoutSuccessHandler().onLogoutSuccess(request, response, authentication); ok = true; } finally { if (!ok && isInvalidateSession()) { invalidateSession(request); } } }
From source file:edu.vt.middleware.servlet.filter.RequestDumperFilter.java
/** {@inheritDoc} */ @SuppressWarnings(value = "unchecked") public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { if (this.config == null) { return;// w w w . j a v a 2 s .com } // Just pass through to next filter if we're not at TRACE level if (!logger.isTraceEnabled()) { chain.doFilter(request, response); return; } // Create a variable to hold the (possibly different) request // passed to downstream filters ServletRequest downstreamRequest = request; // Render the generic servlet request properties final StringWriter sw = new StringWriter(); final PrintWriter writer = new PrintWriter(sw); writer.println("Dumping request..."); writer.println("-----------------------------------------------------"); writer.println("REQUEST received " + Calendar.getInstance().getTime()); writer.println(" characterEncoding=" + request.getCharacterEncoding()); writer.println(" contentLength=" + request.getContentLength()); writer.println(" contentType=" + request.getContentType()); writer.println(" locale=" + request.getLocale()); writer.print(" locales="); final Enumeration<Locale> locales = request.getLocales(); for (int i = 0; locales.hasMoreElements(); i++) { if (i > 0) { writer.print(", "); } writer.print(locales.nextElement()); } writer.println(); final Enumeration<String> paramNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { final String name = paramNames.nextElement(); writer.print(" parameter=" + name + "="); final String[] values = request.getParameterValues(name); for (int i = 0; i < values.length; i++) { if (i > 0) { writer.print(", "); } writer.print(values[i]); } writer.println(); } writer.println(" protocol=" + request.getProtocol()); writer.println(" remoteAddr=" + request.getRemoteAddr()); writer.println(" remoteHost=" + request.getRemoteHost()); writer.println(" scheme=" + request.getScheme()); writer.println(" serverName=" + request.getServerName()); writer.println(" serverPort=" + request.getServerPort()); writer.println(" isSecure=" + request.isSecure()); // Render the HTTP servlet request properties if (request instanceof HttpServletRequest) { final HttpServletRequest hrequest = (HttpServletRequest) request; writer.println(" contextPath=" + hrequest.getContextPath()); Cookie[] cookies = hrequest.getCookies(); if (cookies == null) { cookies = new Cookie[0]; } for (int i = 0; i < cookies.length; i++) { writer.println(" cookie=" + cookies[i].getName() + "=" + cookies[i].getValue()); } final Enumeration<String> headerNames = hrequest.getHeaderNames(); while (headerNames.hasMoreElements()) { final String name = headerNames.nextElement(); final String value = hrequest.getHeader(name); writer.println(" header=" + name + "=" + value); } writer.println(" method=" + hrequest.getMethod()); writer.println(" pathInfo=" + hrequest.getPathInfo()); writer.println(" queryString=" + hrequest.getQueryString()); writer.println(" remoteUser=" + hrequest.getRemoteUser()); writer.println("requestedSessionId=" + hrequest.getRequestedSessionId()); writer.println(" requestURI=" + hrequest.getRequestURI()); writer.println(" servletPath=" + hrequest.getServletPath()); // Create a wrapped request that contains the request body // and that we will pass to downstream filters final ByteArrayRequestWrapper wrappedRequest = new ByteArrayRequestWrapper(hrequest); downstreamRequest = wrappedRequest; writer.println(wrappedRequest.getRequestBodyAsString()); } writer.println("-----------------------------------------------------"); // Log the resulting string writer.flush(); logger.trace(sw.getBuffer().toString()); // Pass control on to the next filter chain.doFilter(downstreamRequest, response); }
From source file:se.vgregion.portal.requestlogger.RequestLoggerController.java
private Map<String, String> getRequestInfo(PortletRequest request) { Map<String, String> requestResult = new TreeMap<String, String>(); HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(request); requestResult.put("RemoteUser", httpRequest.getRemoteUser()); requestResult.put("P3P.USER_LOGIN_ID", getRemoteUserId(request)); requestResult.put("RemoteAddr", httpRequest.getRemoteAddr()); requestResult.put("RemoteHost", httpRequest.getRemoteHost()); requestResult.put("RemotePort", String.valueOf(httpRequest.getRemotePort())); requestResult.put("AuthType", httpRequest.getAuthType()); requestResult.put("CharacterEncoding", httpRequest.getCharacterEncoding()); requestResult.put("ContentLength", String.valueOf(httpRequest.getContentLength())); requestResult.put("ContentType", httpRequest.getContentType()); requestResult.put("ContextPath", httpRequest.getContextPath()); requestResult.put("LocalAddr", httpRequest.getLocalAddr()); requestResult.put("Locale", httpRequest.getLocale().toString()); requestResult.put("LocalName", httpRequest.getLocalName()); requestResult.put("LocalPort", String.valueOf(httpRequest.getLocalPort())); requestResult.put("Method", httpRequest.getMethod()); requestResult.put("PathInfo", httpRequest.getPathInfo()); requestResult.put("PathTranslated", httpRequest.getPathTranslated()); requestResult.put("Protocol", httpRequest.getProtocol()); requestResult.put("QueryString", httpRequest.getQueryString()); requestResult.put("RequestedSessionId", httpRequest.getRequestedSessionId()); requestResult.put("RequestURI", httpRequest.getRequestURI()); requestResult.put("Scheme", httpRequest.getScheme()); requestResult.put("ServerName", httpRequest.getServerName()); requestResult.put("ServerPort", String.valueOf(httpRequest.getServerPort())); requestResult.put("ServletPath", httpRequest.getServletPath()); return requestResult; }
From source file:com.funambol.transport.http.server.Sync4jServlet.java
/** * Processes the request//from w w w . ja v a 2 s . co m * @param httpRequest the request * @param httpResponse the response * @throws javax.servlet.ServletException if an error occurs * @throws java.io.IOException if an error occurs */ @Override public void doPost(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) throws ServletException, IOException { if (log.isInfoEnabled()) { log.info("Handling incoming request"); } String requestURL = getRequestURL(httpRequest); String sessionId = getSessionId(httpRequest); String requestedSessionId = httpRequest.getRequestedSessionId(); if (log.isInfoEnabled()) { log.info("Request URL: " + requestURL); log.info("Requested sessionId: " + requestedSessionId); } if (log.isTraceEnabled()) { showHeaders(httpRequest); } httpResponse.setHeader(HEADER_X_FUNAMBOL_DS_SERVER, getServerHeader()); if (httpRequest.getSession().isNew()) { httpRequest.getSession().setMaxInactiveInterval(sessionTimeout); if (requestedSessionId != null && !requestedSessionId.equals("")) { if (!sessionId.equalsIgnoreCase(requestedSessionId)) { // // The client requires a session that maybe is already expired... // returing a 408 // if (log.isInfoEnabled()) { log.info("Session '" + requestedSessionId + "' not found"); } httpResponse.setStatus(HttpServletResponse.SC_REQUEST_TIMEOUT); return; } } } long requestTime = System.currentTimeMillis(); // // Setting the header 'Set-Cookie' in order to avoid the session tracking // using cookies. // // The web container adds a cookie JSESSIONID in order to // track the session, and to do that, it adds (transparently) in the response // header: // Set-Cookie: JSESSIONID=xxxxxxxxxx // In order not to use the cookie, the header "Set-Cookie" is set to an empty value // In this way, the session tracking is based on the jsessionid parameter // specified in the url (url rewriting). // The cookie is dangerous because a client could use: // http://xxxxxx:yyy/funambol/ds // but with a jsessionid specified as cookie. In this way, the server // search a previous session with the same id. And if a previous session // was interrupted and not expired, the server reuses this one and this // can cause an exception because the client sends the msg 1 and maybe // the previous session was in the mapping state. // // Unfortunatelly on Nokia S60 3Ed feature pack 1, the JAM is not able to // handle the response from the server if it contains an empty header Set-Cookie. // This means that to make the JAM working, we must avoid: // httpResponse.setHeader("Set-Cookie", ""); // and add a dummy cookie. // In order to do this in a generic way, we avoid empty Set-Cookie if in // the request is specified x-funambol-force-cookies header with value // 1 or yes or true // String x_funambol_force_cookies = httpRequest.getHeader(HEADER_X_FUNAMBOL_FORCE_COOKIES); if (!getBooleanValue(x_funambol_force_cookies)) { httpResponse.setHeader("Set-Cookie", ""); } else { // // Setting a dummy cookie // Cookie cookie = new Cookie("funambol-dummy-cookie", ""); httpResponse.addCookie(cookie); } final String contentType = httpRequest.getContentType().split(";")[0]; final String contentEncoding = (String) httpRequest.getHeader(HEADER_CONTENT_ENCODING); final String sizeThreshold = (String) httpRequest.getHeader(HEADER_SIZE_THRESHOLD); String acceptEncoding = (String) httpRequest.getHeader(HEADER_ACCEPT_ENCODING); if (!enableCompression) { // // In this way it's like the client doesn't support any encoding // if (acceptEncoding != null && acceptEncoding.length() != 0) { if (log.isTraceEnabled()) { log.trace("Forcing no compression (enable-compression is set to false)"); } acceptEncoding = null; } } Map params = getRequestParameters(httpRequest); Map headers = getRequestHeaders(httpRequest); byte[] requestData = null; try { requestData = getRequestContent(httpRequest, contentEncoding, requestTime, sessionId); if (requestData == null || requestData.length == 0) { handleError(httpRequest, httpResponse, "Received empty content. Returning a BAD REQUEST code to the client.", null); return; } } catch (Exception e) { handleError(httpRequest, httpResponse, "Error reading the request", e); return; } // // If the session id is not specified in the URL, a new remote object // will be created. Otherwise the session id specifies which remote // object shall handles the request. // SyncHolder holder = null; try { holder = createHolder(httpRequest.getSession()); } catch (Exception e) { handleError(httpRequest, httpResponse, "Error creating SyncBean", e); return; } String remoteAddress = httpRequest.getRemoteAddr(); // // We put the remote address in the header map so that we can pass it to // the adapted. // headers.put(HEADER_X_FUNAMBOL_CLIENT_REMOTE_ADDRESS, remoteAddress); SyncResponse resp = null; try { if (com.funambol.framework.core.Constants.MIMETYPE_SYNCMLDS_WBXML.equals(contentType)) { resp = holder.processWBXMLMessage(requestURL, requestData, params, headers); } else if (com.funambol.framework.core.Constants.MIMETYPE_SYNCMLDS_XML.equals(contentType)) { resp = holder.processXMLMessage(requestURL, requestData, params, headers); } else { throw new ProtocolException("Mime type " + contentType + " not supported or unknown"); } } catch (Exception e) { log.error("Error processing the request", e); Throwable cause = e.getCause(); if ((cause != null) && ((cause instanceof ProtocolException) || (cause instanceof Sync4jException))) { handleError(httpRequest, httpResponse, "Protocol error", cause); return; } else { throw new ServletException(e); } } httpResponse.setContentType(contentType); setResponseContent(httpResponse, acceptEncoding, sizeThreshold, resp, requestTime, sessionId); if (log.isInfoEnabled()) { log.info("Request processed."); } // // If the message completed the SyncML communication, the session // must be closed and discarded. // if (resp.isCompleted()) { httpRequest.setAttribute(ATTRIBUTE_LAST_REQUEST, "true"); closeSession(httpRequest.getSession()); } }
From source file:it.eng.spago.dispatching.httpchannel.AdapterHTTP.java
/** * Sets the http request data.//from w w w .j av a2s.c o m * * @param request the request * @param requestContainer the request container */ private void setHttpRequestData(HttpServletRequest request, RequestContainer requestContainer) { requestContainer.setAttribute(HTTP_REQUEST_AUTH_TYPE, request.getAuthType()); requestContainer.setAttribute(HTTP_REQUEST_CHARACTER_ENCODING, request.getCharacterEncoding()); requestContainer.setAttribute(HTTP_REQUEST_CONTENT_LENGTH, String.valueOf(request.getContentLength())); requestContainer.setAttribute(HTTP_REQUEST_CONTENT_TYPE, request.getContentType()); requestContainer.setAttribute(HTTP_REQUEST_CONTEXT_PATH, request.getContextPath()); requestContainer.setAttribute(HTTP_REQUEST_METHOD, request.getMethod()); requestContainer.setAttribute(HTTP_REQUEST_PATH_INFO, request.getPathInfo()); requestContainer.setAttribute(HTTP_REQUEST_PATH_TRANSLATED, request.getPathTranslated()); requestContainer.setAttribute(HTTP_REQUEST_PROTOCOL, request.getProtocol()); requestContainer.setAttribute(HTTP_REQUEST_QUERY_STRING, request.getQueryString()); requestContainer.setAttribute(HTTP_REQUEST_REMOTE_ADDR, request.getRemoteAddr()); requestContainer.setAttribute(HTTP_REQUEST_REMOTE_HOST, request.getRemoteHost()); requestContainer.setAttribute(HTTP_REQUEST_REMOTE_USER, request.getRemoteUser()); requestContainer.setAttribute(HTTP_REQUEST_REQUESTED_SESSION_ID, request.getRequestedSessionId()); requestContainer.setAttribute(HTTP_REQUEST_REQUEST_URI, request.getRequestURI()); requestContainer.setAttribute(HTTP_REQUEST_SCHEME, request.getScheme()); requestContainer.setAttribute(HTTP_REQUEST_SERVER_NAME, request.getServerName()); requestContainer.setAttribute(HTTP_REQUEST_SERVER_PORT, String.valueOf(request.getServerPort())); requestContainer.setAttribute(HTTP_REQUEST_SERVLET_PATH, request.getServletPath()); if (request.getUserPrincipal() != null) requestContainer.setAttribute(HTTP_REQUEST_USER_PRINCIPAL, request.getUserPrincipal()); requestContainer.setAttribute(HTTP_REQUEST_REQUESTED_SESSION_ID_FROM_COOKIE, String.valueOf(request.isRequestedSessionIdFromCookie())); requestContainer.setAttribute(HTTP_REQUEST_REQUESTED_SESSION_ID_FROM_URL, String.valueOf(request.isRequestedSessionIdFromURL())); requestContainer.setAttribute(HTTP_REQUEST_REQUESTED_SESSION_ID_VALID, String.valueOf(request.isRequestedSessionIdValid())); requestContainer.setAttribute(HTTP_REQUEST_SECURE, String.valueOf(request.isSecure())); Enumeration headerNames = request.getHeaderNames(); while (headerNames.hasMoreElements()) { String headerName = (String) headerNames.nextElement(); String headerValue = request.getHeader(headerName); requestContainer.setAttribute(headerName, headerValue); } // while (headerNames.hasMoreElements()) requestContainer.setAttribute(HTTP_SESSION_ID, request.getSession().getId()); requestContainer.setAttribute(Constants.HTTP_IS_XML_REQUEST, "FALSE"); }
From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractAuthenticationController.java
@RequestMapping(value = { "/{userParam}/loggedout", "{userParam}/j_spring_security_logout" }) public String loggedout(@PathVariable String userParam, ModelMap map, HttpSession session, HttpServletResponse response, HttpServletRequest request) { logger.debug("###Entering in loggedout(response) method"); String showSuffixControl = "false"; String suffixControlType = "textbox"; List<String> suffixList = null; if (config.getValue(Names.com_citrix_cpbm_username_duplicate_allowed).equals("true")) { showSuffixControl = "true"; if (config.getValue(Names.com_citrix_cpbm_login_screen_tenant_suffix_dropdown_enabled).equals("true")) { suffixControlType = "dropdown"; suffixList = tenantService.getSuffixList(); }/*from w ww . j a va 2s.c om*/ } map.addAttribute("showSuffixControl", showSuffixControl); map.addAttribute("suffixControlType", suffixControlType); map.addAttribute("suffixList", suffixList); if (config.getBooleanValue(Configuration.Names.com_citrix_cpbm_portal_directory_service_enabled) && config.getValue(Names.com_citrix_cpbm_directory_mode).equals("pull")) { map.addAttribute("directoryServiceAuthenticationEnabled", "true"); } if (config.getValue(Names.com_citrix_cpbm_public_catalog_display).equals("true") && channelService.getDefaultServiceProviderChannel() != null) { map.addAttribute("showAnonymousCatalogBrowsing", "true"); } map.addAttribute("showLanguageSelection", "true"); map.addAttribute("supportedLocaleList", this.getLocaleDisplayName(listSupportedLocales())); map.addAttribute("logout", true); String redirect = null; Enumeration<String> en = session.getAttributeNames(); while (en.hasMoreElements()) { String attr = en.nextElement(); session.removeAttribute(attr); } Cookie cookie = new Cookie("JforumSSO", ""); cookie.setMaxAge(0); cookie.setPath("/"); response.addCookie(cookie); if (request.getRequestedSessionId() != null && request.isRequestedSessionIdValid()) { // create logout notification begins User user = userService.get(userParam); String message = "logged.out"; String messageArgs = user.getUsername(); eventService.createEvent(new Date(), user, message, messageArgs, Source.PORTAL, Scope.USER, Category.ACCOUNT, Severity.INFORMATION, true); } session.invalidate(); if (config.getAuthenticationService().compareToIgnoreCase(CAS) == 0) { try { redirect = StringUtils.isEmpty(config.getCasLogoutUrl()) ? null : config.getCasLogoutUrl() + "?service=" + URLEncoder.encode(config.getCasServiceUrl(), "UTF-8"); } catch (UnsupportedEncodingException e) { logger.error("Exception encoding: " + redirect, e); } if (redirect == null) { throw new InternalError("CAS authentication required, but login url not set"); } } SecurityContextHolder.getContext().setAuthentication(null); // ends logger.debug("###Exiting loggedout(response) method"); return redirect == null ? "redirect:/j_spring_security_logout" : "redirect:" + redirect; }
From source file:ro.raisercostin.web.DebuggingFilter.java
public String debug(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, DebuggingPrinter debuggingPrinter, boolean debugAll, boolean debugRequest) { final JspFactory jspFactory = JspFactory.getDefaultFactory(); HttpSession session = request.getSession(); debuggingPrinter.addHeader();// ww w . j a v a2 s .c o m debuggingPrinter.addSection("Request Parameters"); for (Iterator iterator = request.getParameterMap().entrySet().iterator(); iterator.hasNext();) { Map.Entry<String, Object> parameter = (Map.Entry<String, Object>) iterator.next(); addRow(debuggingPrinter, parameter.getKey(), StringUtils.arrayToCommaDelimitedString((Object[]) parameter.getValue())); } debuggingPrinter.endSection(); if (debugRequest) { debuggingPrinter.addSection("Request Header"); for (Enumeration e = request.getHeaderNames(); e.hasMoreElements();) { String parameterName = (String) e.nextElement(); addRow(debuggingPrinter, parameterName, debuggingPrinter.transform(request.getHeader(parameterName))); } debuggingPrinter.endSection(); debuggingPrinter.addSection("Request Attributes"); java.util.Enumeration en = request.getAttributeNames(); while (en.hasMoreElements()) { String attrName = (String) en.nextElement(); try { addRow(debuggingPrinter, split(attrName, 50), toString2(request.getAttribute(attrName), 120)); } catch (Exception e) { addRow(debuggingPrinter, split(attrName, 50), toString(e, 120)); } } debuggingPrinter.endSection(); debuggingPrinter.addSection("Session Attributes"); en = session.getAttributeNames(); while (en.hasMoreElements()) { String attrName = (String) en.nextElement(); try { addRow(debuggingPrinter, split(attrName, 50), toString2(session.getAttribute(attrName), 120)); } catch (Exception e) { addRow(debuggingPrinter, split(attrName, 50), toString(e, 120)); } } debuggingPrinter.endSection(); debuggingPrinter.addSection("Request Info"); addRow(debuggingPrinter, "AuthType", request.getAuthType()); addRow(debuggingPrinter, "ContextPath", request.getContextPath()); addRow(debuggingPrinter, "Method", request.getMethod()); addRow(debuggingPrinter, "PathInfo", request.getPathInfo()); addRow(debuggingPrinter, "PathTranslated", request.getPathTranslated()); addRow(debuggingPrinter, "Protocol", request.getProtocol()); addRow(debuggingPrinter, "QueryString", request.getQueryString()); addRow(debuggingPrinter, "RemoteAddr", request.getRemoteAddr()); addRow(debuggingPrinter, "RemoteUser", request.getRemoteUser()); addRow(debuggingPrinter, "RequestedSessionId", request.getRequestedSessionId()); addRow(debuggingPrinter, "RequestURI", request.getRequestURI()); addRow(debuggingPrinter, "RequestURL", request.getRequestURL().toString()); addRow(debuggingPrinter, "ServletPath", request.getServletPath()); addRow(debuggingPrinter, "Scheme", request.getScheme()); addRow(debuggingPrinter, "ServletPath", request.getServletPath()); } if (debugAll) { debuggingPrinter.addSection("Server"); addRow(debuggingPrinter, "Server Info", servletContext.getServerInfo()); addRow(debuggingPrinter, "Servlet Engine Version", servletContext.getMajorVersion() + "." + servletContext.getMinorVersion()); addRow(debuggingPrinter, "JSP Version", jspFactory.getEngineInfo().getSpecificationVersion()); debuggingPrinter.endSection(); debuggingPrinter.addSection("JVM Properties"); for (Enumeration e = System.getProperties().propertyNames(); e.hasMoreElements();) { String parameterName = (String) e.nextElement(); addRow(debuggingPrinter, parameterName, debuggingPrinter.transform(System.getProperty(parameterName))); } debuggingPrinter.endSection(); debuggingPrinter.addSection("Environment"); for (Map.Entry<String, String> property : System.getenv().entrySet()) { addRow(debuggingPrinter, property.getKey(), debuggingPrinter.transform(property.getValue())); } debuggingPrinter.endSection(); debuggingPrinter.addSection("Debugger Provided by"); addRow(debuggingPrinter, "provided by", "raisercostin"); debuggingPrinter.addRow("source", "<a target='_blank' href='http://code.google.com/p/raisercostin/wiki/DebuggingFilter'>http://code.google.com/p/raisercostin/wiki/DebuggingFilter</a>"); addRow(debuggingPrinter, "version", "1.0"); addRow(debuggingPrinter, "timestamp", "2008.June.14"); addRow(debuggingPrinter, "license", "<a target='_blank' href='http://www.apache.org/licenses/LICENSE-2.0.html'>Apache License 2.0</a>"); debuggingPrinter.endSection(); } debuggingPrinter.addFooter(); return debuggingPrinter.getString(); }