Class InvalidRequestFilter

  • All Implemented Interfaces:
    javax.servlet.Filter, org.apache.shiro.util.Nameable, PathConfigProcessor

    public class InvalidRequestFilter
    extends AccessControlFilter
    A request filter that blocks malicious requests. Invalid request will respond with a 400 response code.

    This filter checks and blocks the request if the following characters are found in the request URI:

    • Semicolon - can be disabled by setting blockSemicolon = false
    • Backslash - can be disabled by setting blockBackslash = false
    • Non-ASCII characters - can be disabled by setting blockNonAscii = false, the ability to disable this check will be removed in future version.
    Since:
    1.6
    See Also:
    This class was inspired by Spring Security StrictHttpFirewall
    • Constructor Detail

      • InvalidRequestFilter

        public InvalidRequestFilter()
    • Method Detail

      • onAccessDenied

        protected boolean onAccessDenied​(javax.servlet.ServletRequest request,
                                         javax.servlet.ServletResponse response)
                                  throws Exception
        Description copied from class: AccessControlFilter
        Processes requests where the subject was denied access as determined by the isAccessAllowed method.
        Specified by:
        onAccessDenied in class AccessControlFilter
        Parameters:
        request - the incoming ServletRequest
        response - the outgoing ServletResponse
        Returns:
        true if the request should continue to be processed; false if the subclass will handle/render the response directly.
        Throws:
        Exception - if there is an error processing the request.
      • isBlockSemicolon

        public boolean isBlockSemicolon()
      • setBlockSemicolon

        public void setBlockSemicolon​(boolean blockSemicolon)
      • isBlockBackslash

        public boolean isBlockBackslash()
      • setBlockBackslash

        public void setBlockBackslash​(boolean blockBackslash)
      • isBlockNonAscii

        public boolean isBlockNonAscii()
      • setBlockNonAscii

        public void setBlockNonAscii​(boolean blockNonAscii)