public XElement ToXElement() { var x = new XElement(Saml2Namespaces.Saml2P + LocalName); x.Add(base.ToXNodes()); if (Binding.HasValue) { x.AddAttributeIfNotNullOrEmpty("ProtocolBinding", Saml2Binding.Saml2BindingTypeToUri(Binding.Value)); } x.AddAttributeIfNotNullOrEmpty("AssertionConsumerServiceURL", AssertionConsumerServiceUrl); x.AddAttributeIfNotNullOrEmpty("AttributeConsumingServiceIndex", AttributeConsumingServiceIndex); if (ForceAuthentication) { x.Add(new XAttribute("ForceAuthn", ForceAuthentication)); } AddNameIdPolicy(x); if (RequestedAuthnContext != null && RequestedAuthnContext.ClassRef != null) { x.Add(new XElement(Saml2Namespaces.Saml2P + "RequestedAuthnContext", new XAttribute("Comparison", RequestedAuthnContext.Comparison.ToString().ToLowerInvariant()), // Add the classref as original string to avoid URL normalization // and make sure the emitted value is exactly the configured. new XElement(Saml2Namespaces.Saml2 + "AuthnContextClassRef", RequestedAuthnContext.ClassRef.OriginalString))); } AddScoping(x); OnXmlCreated(x); return(x); }
public void Saml2Binding_Saml2BindingTypeToUri_Unknown() { Action a = () => Saml2Binding.Saml2BindingTypeToUri(Saml2BindingType.HttpRedirect); a.Should().Throw <ArgumentException>().And.Message.Should().Be("Unknown Saml2 Binding Type \"HttpRedirect\"."); }
public void Saml2Binding_Saml2BindingTypeToUri_Post() { Saml2Binding.Saml2BindingTypeToUri(Saml2BindingType.HttpPost) .Should().Be(Saml2Binding.HttpPostUri); }
public void Saml2Binding_Saml2BindingTypeToUri_Artifact() { Saml2Binding.Saml2BindingTypeToUri(Saml2BindingType.Artifact) .Should().Be(Saml2Binding.HttpArtifactUri); }