@Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
            ServletException {
        HttpServletRequest req = (HttpServletRequest) request;
        String authHeader = req.getHeader("Authorization"); //$NON-NLS-1$
        if (authHeader == null) {
            sendAuthResponse((HttpServletResponse) response);
        } else if (authHeader.toUpperCase().startsWith("BASIC")) { //$NON-NLS-1$
            Creds credentials = parseAuthorizationBasic(authHeader);
            if  (credentials == null) {
                sendAuthResponse((HttpServletResponse) response);
            } else {
                doBasicAuth(credentials, req, (HttpServletResponse) response, chain);
            }
        } else if (authHeader.toUpperCase().startsWith("AUTH-TOKEN")) { //$NON-NLS-1$
            AuthToken token = parseAuthorizationToken(authHeader);
            if (token == null) {
                sendAuthResponse((HttpServletResponse) response);
            } else {
                doTokenAuth(token, req, (HttpServletResponse) response, chain);
            }
        } else {
            sendAuthResponse((HttpServletResponse) response);
        }
    }
@ Override public void doFilter ( ServletRequest request , ServletResponse response , FilterChain chain ) throws IOException , ServletException { HttpServletRequest req = ( HttpServletRequest ) request ; String authHeader = req . getHeader ( "Authorization" ) ; if ( authHeader == null ) { sendAuthResponse ( ( HttpServletResponse ) response ) ; } else if ( authHeader . toUpperCase ( ) . startsWith ( "BASIC" ) ) { Creds credentials = parseAuthorizationBasic ( authHeader ) ; if ( credentials == null ) { sendAuthResponse ( ( HttpServletResponse ) response ) ; } else { doBasicAuth ( credentials , req , ( HttpServletResponse ) response , chain ) ; } } else if ( authHeader . toUpperCase ( ) . startsWith ( "AUTH-TOKEN" ) ) { AuthToken token = parseAuthorizationToken ( authHeader ) ; if ( token == null ) { sendAuthResponse ( ( HttpServletResponse ) response ) ; } else { doTokenAuth ( token , req , ( HttpServletResponse ) response , chain ) ; } } else { sendAuthResponse ( ( HttpServletResponse ) response ) ; } }
@see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)