forked from rainliu/sip
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AuthorizationParser.go
41 lines (36 loc) · 987 Bytes
/
AuthorizationParser.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package parser
import (
"sip/core"
"sip/header"
)
/** SIPParser for authorization headers.
*/
type AuthorizationParser struct {
ChallengeParser
}
/** Constructor
* @param String Authorization message to parse
*/
func NewAuthorizationParser(authorization string) *AuthorizationParser {
this := &AuthorizationParser{}
this.ChallengeParser.super(authorization)
return this
}
/** Cosntructor
* @param lexer to set
*/
func NewAuthorizationParserFromLexer(lexer core.Lexer) *AuthorizationParser {
this := &AuthorizationParser{}
this.ChallengeParser.superFromLexer(lexer)
return this
}
/** parse the String message
* @return Header (Authorization object)
* @throws SIPParseException if the message does not respect the spec.
*/
func (this *AuthorizationParser) Parse() (sh header.Header, ParseException error) {
this.HeaderName(TokenTypes_AUTHORIZATION)
auth := header.NewAuthorization()
ParseException = this.ChallengeParser.Parse(auth)
return auth, ParseException
}