-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwsse.go
121 lines (77 loc) · 2.83 KB
/
wsse.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package wsse
import (
"encoding/xml"
"github.com/gosoap/xsd"
)
const Namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
const (
UsernameTokenProfilePasswordDigest = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"
SOAPMessageSecurityBase64Binary = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"
)
// AttributedString represents an element with arbitrary attributes
type AttributedString struct {
ID xsd.String `xml:",attr,omitempty"`
Value string `xml:",chardata"`
}
// PasswordString is used for password elements per Section 4.1
type PasswordString struct { // extends AttributedString
ID xsd.String `xml:",attr,omitempty"`
Type xsd.AnyURI `xml:",attr,omitempty"`
Value string `xml:",chardata"`
}
func (o *PasswordString) UnmarshalText(text []byte) error {
o.Value = string(text)
return nil
}
// EncodedString is used for elements containing stringified binary data
type EncodedString struct { // extends AttributedString
ID xsd.String `xml:",attr,omitempty"`
Type xsd.AnyURI `xml:",attr,omitempty"`
EncodingType xsd.AnyURI `xml:",attr,omitempty"`
Value string `xml:",chardata"`
}
// UsernameToken defines the wsse:UsernameToken element per Section 4.1
type UsernameToken struct {
XMLName xml.Name `xml:"wsse:UsernameToken"`
NS string `xml:"xmlns:wsse,attr,omitempty"`
ID xsd.String `xml:",attr,omitempty"`
Username AttributedString `xml:"wsse:Username"`
EncodingType xsd.AnyURI `xml:",attr,omitempty"`
Extra []interface{}
}
// BinarySecurityToken defines the wsse:BinarySecurityToken element per Section 4.2
type BinarySecurityToken struct {
XMLName xml.Name `xml:"wsse:BinarySecurityToken"`
NS string `xml:"xmlns:wsse,attr,omitempty"`
ValueType xsd.AnyURI `xml:",attr,omitempty"`
ID xsd.String `xml:",attr,omitempty"`
EncodingType xsd.AnyURI `xml:",attr,omitempty"`
Value string `xml:",chardata"`
}
// Reference defines a security token reference
type Reference struct {
XMLName xml.Name `xml:"wsse:Reference"`
NS string `xml:"xmlns:wsse,attr,omitempty"`
URI xsd.AnyURI `xml:",attr,omitempty"`
ValueType xsd.AnyURI `xml:",attr,omitempty"`
}
// Embedded defines a security token embedded reference
type Embedded struct {
XMLName xml.Name `xml:"wsse:Embedded"`
NS string `xml:"xmlns:wsse,attr,omitempty"`
ValueType xsd.AnyURI `xml:",attr,omitempty"`
Extra []interface{}
}
type Password struct {
XMLName xml.Name `xml:"wsse:Password"`
ID xsd.String `xml:",attr,omitempty"`
Type xsd.AnyURI `xml:",attr,omitempty"`
Value string `xml:",chardata"`
}
type Nonce struct {
XMLName xml.Name `xml:"wsse:Nonce"`
ID xsd.String `xml:",attr,omitempty"`
Type xsd.AnyURI `xml:",attr,omitempty"`
EncodingType xsd.AnyURI `xml:",attr,omitempty"`
Value string `xml:",chardata"`
}