Example #1
0
/** Get the parameter of the challenge string
 * @return NameValue containing the parameter
 */
func (this *ChallengeParser) ParseParameter(h header.AuthorizationHeader) (ParseException error) {
	var nv *core.NameValue
	if nv, ParseException = this.NameValue('='); ParseException != nil {
		return ParseException
	}
	ParseException = h.SetParameter(nv.GetName(), nv.GetValue().(string))
	return ParseException
}
Example #2
0
/** parser the String message
 * @return Challenge object
 * @throws ParseException if the message does not respect the spec.
 */
func (this *ChallengeParser) Parse(h header.AuthorizationHeader) (ParseException error) {
	var ch byte
	lexer := this.GetLexer()
	// the Scheme:
	lexer.SPorHT()
	lexer.Match(TokenTypes_ID)
	t := lexer.GetNextToken()
	lexer.SPorHT()
	h.SetScheme(t.GetTokenValue())

	// The parameters:
	for ch, _ = lexer.LookAheadK(0); ch != '\n'; ch, _ = lexer.LookAheadK(0) {
		if ParseException = this.ParseParameter(h); ParseException != nil {
			return ParseException
		}
		lexer.SPorHT()
		if ch, ParseException = lexer.LookAheadK(0); ch == '\n' || ParseException != nil { //||ch=='\0'
			break
		}
		lexer.Match(',')
		lexer.SPorHT()
	}
	return nil
}