Element returns an etree.Element representing the object in XML form.
()
| 179 | |
| 180 | // Element returns an etree.Element representing the object in XML form. |
| 181 | func (r *AuthnRequest) Element() *etree.Element { |
| 182 | el := etree.NewElement("samlp:AuthnRequest") |
| 183 | el.CreateAttr("xmlns:saml", "urn:oasis:names:tc:SAML:2.0:assertion") |
| 184 | el.CreateAttr("xmlns:samlp", "urn:oasis:names:tc:SAML:2.0:protocol") |
| 185 | el.CreateAttr("ID", r.ID) |
| 186 | el.CreateAttr("Version", r.Version) |
| 187 | el.CreateAttr("IssueInstant", r.IssueInstant.Format(timeFormat)) |
| 188 | if r.Destination != "" { |
| 189 | el.CreateAttr("Destination", r.Destination) |
| 190 | } |
| 191 | if r.Consent != "" { |
| 192 | el.CreateAttr("Consent", r.Consent) |
| 193 | } |
| 194 | if r.Issuer != nil { |
| 195 | el.AddChild(r.Issuer.Element()) |
| 196 | } |
| 197 | if r.Signature != nil { |
| 198 | el.AddChild(r.Signature) |
| 199 | } |
| 200 | if r.Subject != nil { |
| 201 | el.AddChild(r.Subject.Element()) |
| 202 | } |
| 203 | if r.NameIDPolicy != nil { |
| 204 | el.AddChild(r.NameIDPolicy.Element()) |
| 205 | } |
| 206 | if r.Conditions != nil { |
| 207 | el.AddChild(r.Conditions.Element()) |
| 208 | } |
| 209 | if r.RequestedAuthnContext != nil { |
| 210 | el.AddChild(r.RequestedAuthnContext.Element()) |
| 211 | } |
| 212 | //if r.Scoping != nil { |
| 213 | // el.AddChild(r.Scoping.Element()) |
| 214 | //} |
| 215 | if r.ForceAuthn != nil { |
| 216 | el.CreateAttr("ForceAuthn", strconv.FormatBool(*r.ForceAuthn)) |
| 217 | } |
| 218 | if r.IsPassive != nil { |
| 219 | el.CreateAttr("IsPassive", strconv.FormatBool(*r.IsPassive)) |
| 220 | } |
| 221 | if r.AssertionConsumerServiceIndex != "" { |
| 222 | el.CreateAttr("AssertionConsumerServiceIndex", r.AssertionConsumerServiceIndex) |
| 223 | } |
| 224 | if r.AssertionConsumerServiceURL != "" { |
| 225 | el.CreateAttr("AssertionConsumerServiceURL", r.AssertionConsumerServiceURL) |
| 226 | } |
| 227 | if r.ProtocolBinding != "" { |
| 228 | el.CreateAttr("ProtocolBinding", r.ProtocolBinding) |
| 229 | } |
| 230 | if r.AttributeConsumingServiceIndex != "" { |
| 231 | el.CreateAttr("AttributeConsumingServiceIndex", r.AttributeConsumingServiceIndex) |
| 232 | } |
| 233 | if r.ProviderName != "" { |
| 234 | el.CreateAttr("ProviderName", r.ProviderName) |
| 235 | } |
| 236 | return el |
| 237 | } |
| 238 |