code: public static AuthContext getAuth(HttpContext cx, HttpRequest req) throws IOException {
          AuthContext auth = (AuthContext) cx.getAttribute(HttpServer.CX_AUTH);
          if (auth == null) {
              Header authHdr = req.getLastHeader(HttpHeaders.AUTHORIZATION);
              if (authHdr == null) {
                  auth = new AuthContext();
              } else {
                  auth = new AuthContext(authHdr.getValue());
              }
          }
          return auth;
      }
docs: Get any authorization credentials supplied over the connection. If no credentials were provided in the request,
  an empty AuthContex is returned
  @param cx The HTTP Context (from httpcomonents)
  @param req The request
  @return The authentication info
  @throws IOException if an I/O error occurs