/** return the name of the preferred scheme */ public String scheme() { if (preferred != null) { return preferred.findKey(0); } else { return null; } }
/* Iterate through each header line, and then within each line. * If multiple entries exist for a particular scheme (unlikely) * then the last one will be used. The * preferred scheme that we support will be used. */ private void parse() { Iterator iter = rsp.multiValueIterator(hdrname); while (iter.hasNext()) { String raw = (String) iter.next(); HeaderParser hp = new HeaderParser(raw); Iterator keys = hp.keys(); int i, lastSchemeIndex; for (i = 0, lastSchemeIndex = -1; keys.hasNext(); i++) { keys.next(); if (hp.findValue(i) == null) { /* found a scheme name */ if (lastSchemeIndex != -1) { HeaderParser hpn = hp.subsequence(lastSchemeIndex, i); String scheme = hpn.findKey(0); schemes.put(scheme, new SchemeMapValue(hpn, raw)); } lastSchemeIndex = i; } } if (i > lastSchemeIndex) { HeaderParser hpn = hp.subsequence(lastSchemeIndex, i); String scheme = hpn.findKey(0); schemes.put(scheme, new SchemeMapValue(hpn, raw)); } } /* choose the best of them */ SchemeMapValue v; if ((v = (SchemeMapValue) schemes.get("digest")) == null) { if (!NTLMAuthentication.isSupported() || ((v = (SchemeMapValue) schemes.get("ntlm")) == null)) { v = (SchemeMapValue) schemes.get("basic"); } } if (v != null) { preferred = v.parser; preferred_r = v.raw; ; } }