code: private AuthenticationResult handleBasicAuth(String inRealm, HttpServletRequest req, HttpServletResponse res) {
  
          AuthenticationResult result = null;
          String hdrValue = req.getHeader(BASIC_AUTH_HEADER_NAME);
          if (hdrValue == null || !hdrValue.startsWith("Basic ")) {
              result = new AuthenticationResult(AuthResult.SEND_401, inRealm, AuditEvent.CRED_TYPE_BASIC, null, AuditEvent.OUTCOME_CHALLENGE);
              return result;
          }
          // Parse the username & password from the header.
          String encoding = req.getHeader("Authorization-Encoding");
  
          hdrValue = decodeBasicAuth(hdrValue.substring(6), encoding);
  
          int idx = hdrValue.indexOf(':');
          if (idx < 0) {
              result = new AuthenticationResult(AuthResult.SEND_401, inRealm, AuditEvent.CRED_TYPE_BASIC, null, AuditEvent.OUTCOME_CHALLENGE);
              return result;
          }
  
          String username = hdrValue.substring(0, idx);
          String password = hdrValue.substring(idx + 1);
  
          return basicAuthenticate(inRealm, username, password, req, res);
      }
docs: handleBasicAuth generates AuthenticationResult
  This routine invokes basicAuthenticate which also generates AuthenticationResult.