Element returns an etree.Element representing the object in XML form.
()
| 80 | |
| 81 | // Element returns an etree.Element representing the object in XML form. |
| 82 | func (r *LogoutRequest) Element() *etree.Element { |
| 83 | el := etree.NewElement("samlp:LogoutRequest") |
| 84 | el.CreateAttr("xmlns:saml", "urn:oasis:names:tc:SAML:2.0:assertion") |
| 85 | el.CreateAttr("xmlns:samlp", "urn:oasis:names:tc:SAML:2.0:protocol") |
| 86 | el.CreateAttr("ID", r.ID) |
| 87 | el.CreateAttr("Version", r.Version) |
| 88 | el.CreateAttr("IssueInstant", r.IssueInstant.Format(timeFormat)) |
| 89 | if r.NotOnOrAfter != nil { |
| 90 | el.CreateAttr("NotOnOrAfter", r.NotOnOrAfter.Format(timeFormat)) |
| 91 | } |
| 92 | if r.Destination != "" { |
| 93 | el.CreateAttr("Destination", r.Destination) |
| 94 | } |
| 95 | if r.Issuer != nil { |
| 96 | el.AddChild(r.Issuer.Element()) |
| 97 | } |
| 98 | if r.Signature != nil { |
| 99 | el.AddChild(r.Signature) |
| 100 | } |
| 101 | if r.NameID != nil { |
| 102 | el.AddChild(r.NameID.Element()) |
| 103 | } |
| 104 | if r.SessionIndex != nil { |
| 105 | el.AddChild(r.SessionIndex.Element()) |
| 106 | } |
| 107 | return el |
| 108 | } |
| 109 | |
| 110 | // MarshalXML implements xml.Marshaler |
| 111 | func (r *LogoutRequest) MarshalXML(e *xml.Encoder, start xml.StartElement) error { |