FileDocCategorySizeDatePackage
ChallengeParser.javaAPI DocphoneME MR2 API (J2ME)3403Wed May 02 18:00:42 BST 2007gov.nist.siplite.parser

ChallengeParser

public abstract class ChallengeParser extends HeaderParser
Parser for the challenge portion of the authentication header.
version
JAIN-SIP-1.1 This code is in the public domain.
version
1.0

Fields Summary
Constructors Summary
protected ChallengeParser()
Default constructor.

protected ChallengeParser(String challenge)
Constructor with initial challenge string.

param
challenge message to parse to set

        super(challenge);
    
protected ChallengeParser(Lexer lexer)
Constructor with initial lexer engine.

param
lexer initial lexer engine

        super(lexer);
    
Methods Summary
public voidparse(AuthenticationHeader header)
Parses the String message.

param
header Challenge object for parsed data
throws
ParseException if the message does not respect the spec.

        // the Scheme:
        this.lexer.SPorHT();
        lexer.match(TokenTypes.ID);
        Token type = lexer.getNextToken();
        this.lexer.SPorHT();
        header.setScheme(type.getTokenValue());

        // The parameters:
        try {
            while (lexer.lookAhead(0) != '\n") {
                this.parseParameter(header);
                this.lexer.SPorHT();
                if (lexer.lookAhead(0) == '\n" ||
                        lexer.lookAhead(0) == '\0") break;
                this.lexer.match(',");
                this.lexer.SPorHT();
            }
        } catch (ParseException ex) {
            throw ex;
        }
    
protected voidparseParameter(AuthenticationHeader header)
Gets the parameter of the challenge string.

param
header header field to process


        if (debug) dbg_enter("parseParameter");
        try {
            NameValue nv = nameValue('=");
            if (header.hasParameter(nv.getName())) {
                throw new ParseException("Duplicated parameter: " +
                    nv.getName(), 0);
            }
            header.setParameter(nv);
        } finally {
            if (debug) dbg_leave("parseParameter");
        }