/** parse the AuthenticationInfo String header * @return Header (AuthenticationInfoList object) * @throws SIPParseException if the message does not respect the spec. */ func (this *AuthenticationInfoParser) Parse() (sh header.Header, ParseException error) { var ch byte var nv *core.NameValue lexer := this.GetLexer() this.HeaderName(TokenTypes_AUTHENTICATION_INFO) authenticationInfo := header.NewAuthenticationInfo() authenticationInfo.SetHeaderName(core.SIPHeaderNames_AUTHENTICATION_INFO) lexer.SPorHT() if nv, ParseException = this.NameValue('='); ParseException != nil { return nil, ParseException } authenticationInfo.SetParameter(nv.GetName(), nv.GetValue().(string)) lexer.SPorHT() for ch, _ = lexer.LookAheadK(0); ch == ','; ch, _ = lexer.LookAheadK(0) { lexer.Match(',') lexer.SPorHT() if nv, ParseException = this.NameValue('='); ParseException != nil { return nil, ParseException } authenticationInfo.SetParameter(nv.GetName(), nv.GetValue().(string)) lexer.SPorHT() } lexer.SPorHT() lexer.Match('\n') return authenticationInfo, nil }
func (this *ParametersParser) Parse(parametersHeader header.ParametersHeader) (ParseException error) { var ch byte var nv *core.NameValue lexer := this.GetLexer() lexer.SPorHT() if ch, ParseException = lexer.LookAheadK(0); ParseException != nil { return ParseException } for ch == ';' { lexer.ConsumeK(1) // eat white space lexer.SPorHT() if nv, ParseException = this.NameValue('='); ParseException != nil { return ParseException } if nv.IsValueQuoted() { parametersHeader.SetParameter(nv.GetName(), "\""+nv.GetValue().(string)+"\"") } else { parametersHeader.SetParameter(nv.GetName(), nv.GetValue().(string)) } // eat white space lexer.SPorHT() if ch, ParseException = lexer.LookAheadK(0); ParseException != nil { return ParseException } } return nil }
/** 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 }