public int match(final AuthScope that) {
        int factor = 0;
        if (Objects.equals(this.schemeName, that.schemeName)) {
            factor += 1;
        } else {
            if (this.schemeName != null && that.schemeName != null) {
                return -1;
            }
        }
        if (Objects.equals(this.realm, that.realm)) {
            factor += 2;
        } else {
            if (this.realm != null && that.realm != null) {
                return -1;
            }
        }
        if (this.port == that.port) {
            factor += 4;
        } else {
            if (this.port != -1 && that.port != -1) {
                return -1;
            }
        }
        if (Objects.equals(this.protocol, that.protocol)) {
            factor += 8;
        } else {
            if (this.protocol != null && that.protocol != null) {
                return -1;
            }
        }
        if (Objects.equals(this.host, that.host)) {
            factor += 16;
        } else {
            if (this.host != null && that.host != null) {
                return -1;
            }
        }
        return factor;
    }
Tests if the authentication scopes match.

@return the match factor. Negative value signifies no match.
   Non-negative signifies a match. The greater the returned value
   the closer the match.
httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthScope.java