Code with Finding: |
class HttpCredential { /** * parse. * @exception HttpParserException if parsing failed. */ protected void parse() throws HttpParserException { ParseState ps = new ParseState(roff, rlen); // Get the scheme first if ( HttpParser.nextItem(raw, ps) < 0 ) error("Invalid credentials: no scheme."); this.scheme = ps.toString(raw); // Depending on the scheme... this.params = new ArrayDictionary(4, 4); ps.prepare(); if ( scheme.equalsIgnoreCase("basic") ) { // Basic Auth nasty hack if ( HttpParser.nextItem(raw, ps) < 0 ) error("Invalid basic auth credentials, no basic-cookie."); params.put("cookie", ps.toString(raw)); } else { // Normal credentials parsing ParseState it = new ParseState(); it.separator = (byte) '='; ps.separator = (byte) ','; while (HttpParser.nextItem(raw, ps) >= 0 ) { // Get the param name: it.prepare(ps); if (HttpParser.nextItem(raw, it) < 0) error("Invalid credentials: bad param name."); String key = it.toString(raw, true); // Get the param value: it.prepare(); if ( HttpParser.nextItem(raw, it) < 0) error("Invalid credentials: no param value."); it.ioff = it.start; HttpParser.unquote(raw, it); params.put(key, it.toString(raw)); ps.prepare(); } } }
}
|