File tree 3 files changed +11
-6
lines changed
3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -100,31 +100,31 @@ func (r *AuthnRequest) Element() *etree.Element {
100
100
}
101
101
102
102
// MarshalXML implements xml.Marshaler
103
- func (a * AuthnRequest ) MarshalXML (e * xml.Encoder , start xml.StartElement ) error {
103
+ func (r * AuthnRequest ) MarshalXML (e * xml.Encoder , start xml.StartElement ) error {
104
104
type Alias AuthnRequest
105
105
aux := & struct {
106
106
IssueInstant RelaxedTime `xml:",attr"`
107
107
* Alias
108
108
}{
109
- IssueInstant : RelaxedTime (a .IssueInstant ),
110
- Alias : (* Alias )(a ),
109
+ IssueInstant : RelaxedTime (r .IssueInstant ),
110
+ Alias : (* Alias )(r ),
111
111
}
112
112
return e .Encode (aux )
113
113
}
114
114
115
115
// UnmarshalXML implements xml.Unmarshaler
116
- func (a * AuthnRequest ) UnmarshalXML (d * xml.Decoder , start xml.StartElement ) error {
116
+ func (r * AuthnRequest ) UnmarshalXML (d * xml.Decoder , start xml.StartElement ) error {
117
117
type Alias AuthnRequest
118
118
aux := & struct {
119
119
IssueInstant RelaxedTime `xml:",attr"`
120
120
* Alias
121
121
}{
122
- Alias : (* Alias )(a ),
122
+ Alias : (* Alias )(r ),
123
123
}
124
124
if err := d .DecodeElement (& aux , & start ); err != nil {
125
125
return err
126
126
}
127
- a .IssueInstant = time .Time (aux .IssueInstant )
127
+ r .IssueInstant = time .Time (aux .IssueInstant )
128
128
return nil
129
129
}
130
130
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import (
25
25
// NameIDFormat is the format of the id
26
26
type NameIDFormat string
27
27
28
+ // Element returns an XML element representation of n.
28
29
func (n NameIDFormat ) Element () * etree.Element {
29
30
el := etree .NewElement ("" )
30
31
el .SetText (string (n ))
Original file line number Diff line number Diff line change @@ -2,10 +2,13 @@ package saml
2
2
3
3
import "time"
4
4
5
+ // RelaxedTime is a version of time.Time that supports the time format
6
+ // found in SAML documents.
5
7
type RelaxedTime time.Time
6
8
7
9
const timeFormat = "2006-01-02T15:04:05.999Z07:00"
8
10
11
+ // MarshalText implements encoding.TextMarshaler
9
12
func (m RelaxedTime ) MarshalText () ([]byte , error ) {
10
13
// According to section 1.2.2 of the OASIS SAML 1.1 spec, we can't trust
11
14
// other applications to handle time resolution finer than a millisecond.
@@ -18,6 +21,7 @@ func (m RelaxedTime) String() string {
18
21
return time .Time (m ).Round (time .Millisecond ).UTC ().Format (timeFormat )
19
22
}
20
23
24
+ // UnmarshalText implements encoding.TextUnmarshaler
21
25
func (m * RelaxedTime ) UnmarshalText (text []byte ) error {
22
26
if len (text ) == 0 {
23
27
* m = RelaxedTime (time.Time {})
You can’t perform that action at this time.
0 commit comments