Element returns an etree.Element representing the object in XML form.
()
| 417 | |
| 418 | // Element returns an etree.Element representing the object in XML form. |
| 419 | func (r *ArtifactResponse) Element() *etree.Element { |
| 420 | el := etree.NewElement("samlp:ArtifactResponse") |
| 421 | el.CreateAttr("xmlns:saml", "urn:oasis:names:tc:SAML:2.0:assertion") |
| 422 | el.CreateAttr("xmlns:samlp", "urn:oasis:names:tc:SAML:2.0:protocol") |
| 423 | |
| 424 | // Note: This namespace is not used by any element or attribute name, but |
| 425 | // is required so that the AttributeValue type element can have a value like |
| 426 | // "xs:string". If we don't declare it here, then it will be stripped by the |
| 427 | // cannonicalizer. This could be avoided by providing a prefix list to the |
| 428 | // cannonicalizer, but prefix lists do not appear to be implemented correctly |
| 429 | // in some libraries, so the safest action is to always produce XML that is |
| 430 | // (a) in canonical form and (b) does not require prefix lists. |
| 431 | el.CreateAttr("xmlns:xs", "http://www.w3.org/2001/XMLSchema") |
| 432 | |
| 433 | el.CreateAttr("ID", r.ID) |
| 434 | if r.InResponseTo != "" { |
| 435 | el.CreateAttr("InResponseTo", r.InResponseTo) |
| 436 | } |
| 437 | el.CreateAttr("Version", r.Version) |
| 438 | el.CreateAttr("IssueInstant", r.IssueInstant.Format(timeFormat)) |
| 439 | if r.Issuer != nil { |
| 440 | el.AddChild(r.Issuer.Element()) |
| 441 | } |
| 442 | if r.Signature != nil { |
| 443 | el.AddChild(r.Signature) |
| 444 | } |
| 445 | el.AddChild(r.Status.Element()) |
| 446 | el.AddChild(r.Response.Element()) |
| 447 | return el |
| 448 | } |
| 449 | |
| 450 | // MarshalXML implements xml.Marshaler |
| 451 | func (r *ArtifactResponse) MarshalXML(e *xml.Encoder, start xml.StartElement) error { |