class SecurityFilter implements Filter {

    @Override
    public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain )
            throws IOException, ServletException
    {

        validateRequestType( request );
        validateResponseType( response );

        HttpServletRequest httpReq = (HttpServletRequest) request;
        String path = httpReq.getContextPath() + (httpReq.getPathInfo() == null ? "" : httpReq.getPathInfo());

        boolean requestIsForbidden = false;
        for ( UriPathWildcardMatcher uriPathWildcardMatcher : rules.keySet() )
        {
            if ( uriPathWildcardMatcher.matches( path ) )
            {
                HashSet<ForbiddingSecurityRule> securityRules = rules.get( uriPathWildcardMatcher );
                for ( ForbiddingSecurityRule securityRule : securityRules )
                {
                    // 401 on the first failed rule we come along
                    if ( !securityRule.isAuthorized( httpReq ) )
                    {
                        createUnauthorizedChallenge( response, securityRule );
                        return;
                    }
                    requestIsForbidden |= securityRule.isForbidden( httpReq );
                }
            }
        }
        if ( requestIsForbidden )
        {
            createForbiddenResponse( response );
            return;
        }

        chain.doFilter( request, response );
    }

    public  SecurityFilter( SecurityRule rule, SecurityRule... rules );
    public  SecurityFilter( Iterable<SecurityRule> securityRules );

}