public List<AuthChallenge> parse(
            final ChallengeType challengeType, final CharSequence buffer, final ParserCursor cursor) throws ParseException {
        tokenParser.skipWhiteSpace(buffer, cursor);
        if (cursor.atEnd()) {
            throw new ParseException("Malformed auth challenge");
        }
        final List<ChallengeInt> internalChallenges = new ArrayList<>();
        final String schemeName = tokenParser.parseToken(buffer, cursor, SPACE);
        if (TextUtils.isBlank(schemeName)) {
            throw new ParseException("Malformed auth challenge");
        }
        ChallengeInt current = new ChallengeInt(schemeName);
        while (current != null) {
            internalChallenges.add(current);
            current = parseChallenge(buffer, cursor, current);
        }
        final List<AuthChallenge> challenges = new ArrayList<>(internalChallenges.size());
        for (final ChallengeInt internal : internalChallenges) {
            final List<NameValuePair> params = internal.params;
            String token68 = null;
            if (params.size() == 1) {
                final NameValuePair param = params.get(0);
                if (param.getValue() == null) {
                    token68 = param.getName();
                    params.clear();
                }
            }
            challenges.add(
                    new AuthChallenge(challengeType, internal.schemeName, token68, !params.isEmpty() ? params : null));
        }
        return challenges;
    }
Parses the given sequence of characters into a list of {@link AuthChallenge} elements.

@param challengeType the type of challenge (target or proxy).
@param buffer the sequence of characters to be parsed.
@param cursor the parser cursor.
@return a list of auth challenge elements.
httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/AuthChallengeParser.java