1 7 package org.jboss.web.tomcat.security; 8 9 import java.util.Enumeration ; 10 11 import javax.servlet.http.HttpServletRequest ; 12 13 19 public class WebUtil 20 { 21 26 public static String deriveUsefulInfo(HttpServletRequest httpRequest) 27 { 28 StringBuilder sb = new StringBuilder (); 29 sb.append("[").append(httpRequest.getContextPath()); 30 sb.append(":cookies=").append(httpRequest.getCookies()).append(":headers="); 31 Enumeration en = httpRequest.getHeaderNames(); 33 for(;en.hasMoreElements();) 34 { 35 String headerName = (String )en.nextElement(); 36 sb.append(headerName).append("="); 37 sb.append(httpRequest.getHeader(headerName)).append(","); 38 } 39 sb.append("]"); 40 sb.append("[parameters="); 42 Enumeration enparam = httpRequest.getParameterNames(); 43 for(;enparam.hasMoreElements();) 44 { 45 String paramName = (String )enparam.nextElement(); 46 String [] paramValues = httpRequest.getParameterValues(paramName); 47 int len = paramValues != null ? paramValues.length : 0; 48 for(int i = 0 ; i < len ; i++) 49 sb.append(paramValues[i]).append("::"); 50 sb.append(","); 51 } 52 sb.append("][attributes="); 53 Enumeration enu = httpRequest.getAttributeNames(); 55 for(;enu.hasMoreElements();) 56 { 57 String attrName = (String )enu.nextElement(); 58 sb.append(attrName).append("="); 59 sb.append(httpRequest.getAttribute(attrName)).append(","); 60 } 61 sb.append("]"); 62 return sb.toString(); 63 } 64 } 65 | Popular Tags |