private ContextBindingElement(ContextBindingElement other) : base(other) { this.ProtectionLevel = other.ProtectionLevel; this.ContextExchangeMechanism = other.ContextExchangeMechanism; this.ClientCallbackAddress = other.ClientCallbackAddress; this.ContextManagementEnabled = other.ContextManagementEnabled; }
internal override bool IsMatch(BindingElement b) { if (b == null) { return(false); } ContextBindingElement element = b as ContextBindingElement; if (element == null) { return(false); } if (this.ClientCallbackAddress != element.ClientCallbackAddress) { return(false); } if (this.ContextExchangeMechanism != element.ContextExchangeMechanism) { return(false); } if (this.ContextManagementEnabled != element.ContextManagementEnabled) { return(false); } if (this.ProtectionLevel != element.protectionLevel) { return(false); } return(true); }
public static bool TryImportRequireContextAssertion(PolicyAssertionCollection assertions, out ContextBindingElement bindingElement) { if (assertions == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("assertions"); } bindingElement = null; foreach (XmlElement element in assertions) { if (((element.LocalName == "IncludeContext") && (element.NamespaceURI == "http://schemas.microsoft.com/ws/2006/05/context")) && ContainOnlyWhitespaceChild(element)) { string attribute = element.GetAttribute("ProtectionLevel"); if ("EncryptAndSign".Equals(attribute, StringComparison.Ordinal)) { bindingElement = new ContextBindingElement(ProtectionLevel.EncryptAndSign); } else if ("Sign".Equals(attribute, StringComparison.Ordinal)) { bindingElement = new ContextBindingElement(ProtectionLevel.Sign); } else if ("None".Equals(attribute, StringComparison.Ordinal)) { bindingElement = new ContextBindingElement(ProtectionLevel.None); } if (bindingElement != null) { assertions.Remove(element); return(true); } } } return(false); }
public static bool TryImportRequireContextAssertion(PolicyAssertionCollection assertions, out ContextBindingElement bindingElement) { if (assertions == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("assertions"); } bindingElement = null; foreach (XmlElement assertion in assertions) { if (assertion.LocalName == IncludeContextName && assertion.NamespaceURI == WscNamespace && ContainOnlyWhitespaceChild(assertion)) { string protectionLevelAttribute = assertion.GetAttribute(ProtectionLevelName); if (EncryptAndSignName.Equals(protectionLevelAttribute, StringComparison.Ordinal)) { bindingElement = new ContextBindingElement(ProtectionLevel.EncryptAndSign); } else if (SignName.Equals(protectionLevelAttribute, StringComparison.Ordinal)) { bindingElement = new ContextBindingElement(ProtectionLevel.Sign); } else if (NoneName.Equals(protectionLevelAttribute, StringComparison.Ordinal)) { bindingElement = new ContextBindingElement(ProtectionLevel.None); } if (bindingElement != null) { assertions.Remove(assertion); return(true); } } } return(false); }
public static void ExportRequireContextAssertion(ContextBindingElement bindingElement, PolicyAssertionCollection assertions) { if (bindingElement == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElement"); } if (assertions == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("assertions"); } if (bindingElement.ContextExchangeMechanism == ContextExchangeMechanism.ContextSoapHeader) { XmlElement assertion = Document.CreateElement(null, IncludeContextName, WscNamespace); XmlAttribute protectionLevelAttribute = Document.CreateAttribute(ProtectionLevelName); switch (bindingElement.ProtectionLevel) { case ProtectionLevel.EncryptAndSign: protectionLevelAttribute.Value = EncryptAndSignName; break; case ProtectionLevel.Sign: protectionLevelAttribute.Value = SignName; break; default: protectionLevelAttribute.Value = NoneName; break; } assertion.Attributes.Append(protectionLevelAttribute); assertions.Add(assertion); } else { XmlElement assertion = Document.CreateElement(null, HttpUseCookieName, HttpNamespace); assertions.Add(assertion); } }
public static void ExportRequireContextAssertion(ContextBindingElement bindingElement, PolicyAssertionCollection assertions) { if (bindingElement == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElement"); } if (assertions == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("assertions"); } if (bindingElement.ContextExchangeMechanism != ContextExchangeMechanism.ContextSoapHeader) { XmlElement item = Document.CreateElement(null, "HttpUseCookie", "http://schemas.xmlsoap.org/soap/http"); assertions.Add(item); } else { XmlElement element = Document.CreateElement(null, "IncludeContext", "http://schemas.microsoft.com/ws/2006/05/context"); System.Xml.XmlAttribute node = Document.CreateAttribute("ProtectionLevel"); switch (bindingElement.ProtectionLevel) { case ProtectionLevel.Sign: node.Value = "Sign"; break; case ProtectionLevel.EncryptAndSign: node.Value = "EncryptAndSign"; break; default: node.Value = "None"; break; } element.Attributes.Append(node); assertions.Add(element); } }