@Override
  public boolean shouldApply(HttpServletRequest httpServletRequest) {

    if (LOG.isDebugEnabled()) {
      RequestUtils.logRequestHeadersAndQueryParams(httpServletRequest, LOG);
    }

    String header = httpServletRequest.getHeader("Authorization");
    if ((header != null) && header.startsWith("Basic ")) {
      // If doAs is sent as a query parameter, ignore the basic auth header.
      // This logic is here to help deal with a potential issue when Knox is the trusted proxy and it
      // forwards the original request's Authorization header (for Basic Auth) when Kerberos authentication
      // is required.
      String doAsQueryParameterValue = RequestUtils.getQueryStringParameterValue(httpServletRequest, "doAs");
      if (StringUtils.isEmpty(doAsQueryParameterValue)) {
        return true;
      } else {
        LOG.warn("The 'doAs' query parameter was provided; however, the BasicAuth header is found. " +
            "Ignoring the BasicAuth header hoping to negotiate Kerberos authentication.");
        return false;
      }
    } else {
      return false;
    }
  }
Tests to see if this {@link AmbariBasicAuthenticationFilter} should be applied in the authentication
filter chain.
<p>
<code>true</code> will be returned if the HTTP request contains the basic authentication header;
otherwise <code>false</code> will be returned.
<p>
The basic authentication header is named "Authorization" and the value begins with the string
"Basic" following by the encoded username and password information.
<p>
For example:
<code>
Authorization: Basic YWRtaW46YWRtaW4=
</code>

@param httpServletRequest the HttpServletRequest the HTTP service request
@return <code>true</code> if the HTTP request contains the basic authentication header; otherwise <code>false</code>
ambari-server/src/main/java/org/apache/ambari/server/security/authentication/AmbariBasicAuthenticationFilter.java