Package net.mingsoft.basic.filter
Class XssHttpServletRequestWrapper
java.lang.Object
jakarta.servlet.ServletRequestWrapper
jakarta.servlet.http.HttpServletRequestWrapper
net.mingsoft.basic.filter.XssHttpServletRequestWrapper
- All Implemented Interfaces:
jakarta.servlet.http.HttpServletRequest,jakarta.servlet.ServletRequest
public class XssHttpServletRequestWrapper
extends jakarta.servlet.http.HttpServletRequestWrapper
XSS 过滤器 用于请求参数的脚本数据
-
Field Summary
FieldsModifier and TypeFieldDescriptionFields inherited from interface jakarta.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH -
Constructor Summary
ConstructorsConstructorDescriptionXssHttpServletRequestWrapper(jakarta.servlet.http.HttpServletRequest request) XssHttpServletRequestWrapper(jakarta.servlet.http.HttpServletRequest request, List<String> excludesFiled) -
Method Summary
Modifier and TypeMethodDescription覆盖getHeader方法,将参数名和参数值都做xss过滤。jakarta.servlet.ServletInputStreamstatic jakarta.servlet.http.HttpServletRequestgetOrgRequest(jakarta.servlet.http.HttpServletRequest req) 获取最原始的request的静态方法getParameter(String name) 覆盖getParameter方法,将参数名和参数值都做xss过滤。String[]getParameterValues(String name) jakarta.servlet.http.HttpServletRequest获取最原始的requestMethods inherited from class jakarta.servlet.http.HttpServletRequestWrapper
authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeaderNames, getHeaders, getHttpServletMapping, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getTrailerFields, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isTrailerFieldsReady, isUserInRole, login, logout, newPushBuilder, upgradeMethods inherited from class jakarta.servlet.ServletRequestWrapper
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameterNames, getProtocol, getProtocolRequestId, getReader, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getRequestId, getScheme, getServerName, getServerPort, getServletConnection, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsyncMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.servlet.ServletRequest
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameterNames, getProtocol, getProtocolRequestId, getReader, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getRequestId, getScheme, getServerName, getServerPort, getServletConnection, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync
-
Field Details
-
TIMED_XSS_CACHE
-
TIMED_REQ_CACHE
-
-
Constructor Details
-
XssHttpServletRequestWrapper
public XssHttpServletRequestWrapper(jakarta.servlet.http.HttpServletRequest request) -
XssHttpServletRequestWrapper
-
-
Method Details
-
getInputStream
- Specified by:
getInputStreamin interfacejakarta.servlet.ServletRequest- Overrides:
getInputStreamin classjakarta.servlet.ServletRequestWrapper- Throws:
IOException
-
getParameter
覆盖getParameter方法,将参数名和参数值都做xss过滤。如果需要获得原始的值,则通过super.getParameterValues(name)来获取
getParameterNames,getParameterValues和getParameterMap也可能需要覆盖
- Specified by:
getParameterin interfacejakarta.servlet.ServletRequest- Overrides:
getParameterin classjakarta.servlet.ServletRequestWrapper
-
getParameterMap
- Specified by:
getParameterMapin interfacejakarta.servlet.ServletRequest- Overrides:
getParameterMapin classjakarta.servlet.ServletRequestWrapper
-
getParameterValues
- Specified by:
getParameterValuesin interfacejakarta.servlet.ServletRequest- Overrides:
getParameterValuesin classjakarta.servlet.ServletRequestWrapper
-
getHeader
覆盖getHeader方法,将参数名和参数值都做xss过滤。如果需要获得原始的值,则通过super.getHeaders(name)来获取
getHeaderNames 也可能需要覆盖
- Specified by:
getHeaderin interfacejakarta.servlet.http.HttpServletRequest- Overrides:
getHeaderin classjakarta.servlet.http.HttpServletRequestWrapper
-
getRequest
public jakarta.servlet.http.HttpServletRequest getRequest()获取最原始的request- Overrides:
getRequestin classjakarta.servlet.ServletRequestWrapper- Returns:
-
getOrgRequest
public static jakarta.servlet.http.HttpServletRequest getOrgRequest(jakarta.servlet.http.HttpServletRequest req) 获取最原始的request的静态方法- Returns:
-