forked from mikemacd/go-saml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogoutresponse.go
47 lines (37 loc) · 1.25 KB
/
logoutresponse.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
42
43
44
45
46
47
package saml
import (
"encoding/base64"
"encoding/xml"
"github.com/mikemacd/go-saml/util"
)
func ParseCompressedEncodedLogoutResponse(b64RequestXML string) (*Response, error) {
var logoutResponse Response
compressedXML, err := base64.StdEncoding.DecodeString(b64RequestXML)
if err != nil {
return nil, err
}
bXML := util.Decompress(compressedXML)
err = xml.Unmarshal(bXML, &logoutResponse)
if err != nil {
return nil, err
}
// There is a bug with XML namespaces in Go that's causing XML attributes with colons to not be roundtrip
// marshal and unmarshaled so we'll keep the original string around for validation.
logoutResponse.originalString = string(bXML)
return &logoutResponse, nil
}
func ParseEncodedLogoutResponse(b64RequestXML string) (*Response, error) {
logoutResponse := Response{}
bytesXML, err := base64.StdEncoding.DecodeString(b64RequestXML)
if err != nil {
return nil, err
}
err = xml.Unmarshal(bytesXML, &logoutResponse)
if err != nil {
return nil, err
}
// There is a bug with XML namespaces in Go that's causing XML attributes with colons to not be roundtrip
// marshal and unmarshaled so we'll keep the original string around for validation.
logoutResponse.originalString = string(bytesXML)
return &logoutResponse, nil
}