Skip to content

Commit

Permalink
fix some minor lint / style errors
Browse files Browse the repository at this point in the history
  • Loading branch information
crewjam committed Jan 7, 2018
1 parent f33bc82 commit b1cfb79
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
12 changes: 6 additions & 6 deletions schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,31 +100,31 @@ func (r *AuthnRequest) Element() *etree.Element {
}

// MarshalXML implements xml.Marshaler
func (a *AuthnRequest) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
func (r *AuthnRequest) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
type Alias AuthnRequest
aux := &struct {
IssueInstant RelaxedTime `xml:",attr"`
*Alias
}{
IssueInstant: RelaxedTime(a.IssueInstant),
Alias: (*Alias)(a),
IssueInstant: RelaxedTime(r.IssueInstant),
Alias: (*Alias)(r),
}
return e.Encode(aux)
}

// UnmarshalXML implements xml.Unmarshaler
func (a *AuthnRequest) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
func (r *AuthnRequest) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
type Alias AuthnRequest
aux := &struct {
IssueInstant RelaxedTime `xml:",attr"`
*Alias
}{
Alias: (*Alias)(a),
Alias: (*Alias)(r),
}
if err := d.DecodeElement(&aux, &start); err != nil {
return err
}
a.IssueInstant = time.Time(aux.IssueInstant)
r.IssueInstant = time.Time(aux.IssueInstant)
return nil
}

Expand Down
1 change: 1 addition & 0 deletions service_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
// NameIDFormat is the format of the id
type NameIDFormat string

// Element returns an XML element representation of n.
func (n NameIDFormat) Element() *etree.Element {
el := etree.NewElement("")
el.SetText(string(n))
Expand Down
4 changes: 4 additions & 0 deletions time.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package saml

import "time"

// RelaxedTime is a version of time.Time that supports the time format
// found in SAML documents.
type RelaxedTime time.Time

const timeFormat = "2006-01-02T15:04:05.999Z07:00"

// MarshalText implements encoding.TextMarshaler
func (m RelaxedTime) MarshalText() ([]byte, error) {
// According to section 1.2.2 of the OASIS SAML 1.1 spec, we can't trust
// other applications to handle time resolution finer than a millisecond.
Expand All @@ -18,6 +21,7 @@ func (m RelaxedTime) String() string {
return time.Time(m).Round(time.Millisecond).UTC().Format(timeFormat)
}

// UnmarshalText implements encoding.TextUnmarshaler
func (m *RelaxedTime) UnmarshalText(text []byte) error {
if len(text) == 0 {
*m = RelaxedTime(time.Time{})
Expand Down

0 comments on commit b1cfb79

Please sign in to comment.