void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context) { if (importer == null) { throw new ArgumentNullException("importer"); } if (context == null) { throw new ArgumentNullException("context"); } ICollection<XmlElement> assertions = context.GetBindingAssertions(); foreach (XmlElement assertion in assertions) { if (assertion.NamespaceURI == MakeConnectionConstants.Namespace) { if (assertion.LocalName == MakeConnectionConstants.Policy.Assertion) { assertions.Remove(assertion); context.BindingElements.Insert(0, new MakeConnectionBindingElement()); return; } } } }
protected virtual void OnImportPolicy (XmlElement assertion, MessageVersion messageVersion, MetadataImporter exporter, PolicyConversionContext context) { throw new NotImplementedException (); }
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context) { if (importer == null) { throw new ArgumentNullException("importer"); } if (context == null) { throw new ArgumentNullException("context"); } UdpTransportBindingElement udpBindingElement = null; bool multicast = false; PolicyAssertionCollection policyAssertions = context.GetBindingAssertions(); if (policyAssertions.Remove(UdpPolicyStrings.TransportAssertion, UdpPolicyStrings.UdpNamespace) != null) { udpBindingElement = new UdpTransportBindingElement(); } if (policyAssertions.Remove(UdpPolicyStrings.MulticastAssertion, UdpPolicyStrings.UdpNamespace) != null) { multicast = true; } if (udpBindingElement != null) { udpBindingElement.Multicast = multicast; context.BindingElements.Add(udpBindingElement); } }
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext policyContext) { if (policyContext == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("policyContext"); XmlElement privacyNoticeAssertion = PolicyConversionContext.FindAssertion(policyContext.GetBindingAssertions(), PrivacyNoticePolicyStrings.PrivacyNoticeName, PrivacyNoticePolicyStrings.PrivacyNoticeNamespace, true); if (privacyNoticeAssertion != null) { PrivacyNoticeBindingElement settings = policyContext.BindingElements.Find<PrivacyNoticeBindingElement>(); if (null == settings) { settings = new PrivacyNoticeBindingElement(); policyContext.BindingElements.Add(settings); } settings.Url = new Uri(privacyNoticeAssertion.InnerText); string versionString = privacyNoticeAssertion.GetAttribute(PrivacyNoticePolicyStrings.PrivacyNoticeVersionAttributeName, PrivacyNoticePolicyStrings.PrivacyNoticeNamespace); if (string.IsNullOrEmpty(versionString)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.CannotImportPrivacyNoticeElementWithoutVersionAttribute))); } int version = 0; if (!Int32.TryParse(versionString, out version)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.PrivacyNoticeElementVersionAttributeInvalid))); } settings.Version = version; } }
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context) { if (importer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("importer"); } if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } XmlElement element = PolicyConversionContext.FindAssertion(context.GetBindingAssertions(), "OneWay", "http://schemas.microsoft.com/ws/2005/05/routing/policy", true); if (element != null) { OneWayBindingElement item = new OneWayBindingElement(); context.BindingElements.Add(item); for (int i = 0; i < element.ChildNodes.Count; i++) { System.Xml.XmlNode node = element.ChildNodes[i]; if (((node != null) && (node.NodeType == XmlNodeType.Element)) && ((node.NamespaceURI == "http://schemas.microsoft.com/ws/2005/05/routing/policy") && (node.LocalName == "PacketRoutable"))) { item.PacketRoutable = true; return; } } } else if (WsdlImporter.WSAddressingHelper.DetermineSupportedAddressingMode(importer, context) == SupportedAddressingMode.NonAnonymous) { context.BindingElements.Add(new OneWayBindingElement()); } }
internal void OnImportPolicy(MetadataImporter importer, PolicyConversionContext context) { XmlElement element = PolicyConversionContext.FindAssertion(context.GetBindingAssertions(), PeerTransportPolicyConstants.PeerTransportSecurityMode, TransportPolicyConstants.PeerTransportUri, true); this.Mode = SecurityMode.Transport; if (element != null) { switch (element.InnerText) { case PeerTransportPolicyConstants.PeerTransportSecurityModeNone: this.Mode = SecurityMode.None; break; case PeerTransportPolicyConstants.PeerTransportSecurityModeTransport: this.Mode = SecurityMode.Transport; break; case PeerTransportPolicyConstants.PeerTransportSecurityModeMessage: this.Mode = SecurityMode.Message; break; case PeerTransportPolicyConstants.PeerTransportSecurityModeTransportWithMessageCredential: this.Mode = SecurityMode.TransportWithMessageCredential; break; default: break; } } transportSecurity.OnImportPolicy(importer, context); }
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext policyContext) { if (policyContext == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("policyContext"); } XmlElement element = PolicyConversionContext.FindAssertion(policyContext.GetBindingAssertions(), "PrivacyNotice", "http://schemas.xmlsoap.org/ws/2005/05/identity", true); if (element != null) { PrivacyNoticeBindingElement item = policyContext.BindingElements.Find<PrivacyNoticeBindingElement>(); if (item == null) { item = new PrivacyNoticeBindingElement(); policyContext.BindingElements.Add(item); } item.Url = new Uri(element.InnerText); string attribute = element.GetAttribute("Version", "http://schemas.xmlsoap.org/ws/2005/05/identity"); if (string.IsNullOrEmpty(attribute)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("CannotImportPrivacyNoticeElementWithoutVersionAttribute"))); } int result = 0; if (!int.TryParse(attribute, out result)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("PrivacyNoticeElementVersionAttributeInvalid"))); } item.Version = result; } }
internal void OnImportPolicy(MetadataImporter importer, PolicyConversionContext context) { string str; XmlElement element = PolicyConversionContext.FindAssertion(context.GetBindingAssertions(), "PeerTransportSecurityMode", "http://schemas.microsoft.com/soap/peer", true); this.Mode = SecurityMode.Transport; if ((element != null) && ((str = element.InnerText) != null)) { if (!(str == "PeerTransportSecurityModeNone")) { if (str == "PeerTransportSecurityModeTransport") { this.Mode = SecurityMode.Transport; } else if (str == "PeerTransportSecurityModeMessage") { this.Mode = SecurityMode.Message; } else if (str == "PeerTransportSecurityModeTransportWithMessageCredential") { this.Mode = SecurityMode.TransportWithMessageCredential; } } else { this.Mode = SecurityMode.None; } } this.transportSecurity.OnImportPolicy(importer, context); }
internal void OnExportPolicy(MetadataExporter exporter, PolicyConversionContext context) { string str = ""; switch (this.Mode) { case SecurityMode.None: str = "PeerTransportSecurityModeNone"; break; case SecurityMode.Transport: str = "PeerTransportSecurityModeTransport"; break; case SecurityMode.Message: str = "PeerTransportSecurityModeMessage"; break; case SecurityMode.TransportWithMessageCredential: str = "PeerTransportSecurityModeTransportWithMessageCredential"; break; default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); } XmlElement item = new XmlDocument().CreateElement("pc", "PeerTransportSecurityMode", "http://schemas.microsoft.com/soap/peer"); item.InnerText = str; context.GetBindingAssertions().Add(item); this.transportSecurity.OnExportPolicy(exporter, context); }
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context) { if (importer == null) { throw new ArgumentNullException("importer"); } if (context == null) { throw new ArgumentNullException("context"); } ICollection<XmlElement> assertions = context.GetBindingAssertions(); foreach (XmlElement assertion in assertions) { if ((assertion.NamespaceURI == GZipMessageEncodingPolicyConstants.GZipEncodingNamespace) && (assertion.LocalName == GZipMessageEncodingPolicyConstants.GZipEncodingName) ) { assertions.Remove(assertion); context.BindingElements.Add(new GZipMessageEncodingBindingElement()); break; } } }
internal bool TryImportPolicy(PolicyConversionContext policyContext) { foreach (IPolicyImportExtension policyImporter in policyExtensions) { try { policyImporter.ImportPolicy(this, policyContext); } }
private static ReliableSessionBindingElement GetReliableSessionBindingElement(PolicyConversionContext context) { ReliableSessionBindingElement item = context.BindingElements.Find<ReliableSessionBindingElement>(); if (item == null) { item = new ReliableSessionBindingElement(); context.BindingElements.Add(item); } return item; }
static ReliableSessionBindingElement GetReliableSessionBindingElement(PolicyConversionContext context) { ReliableSessionBindingElement settings = context.BindingElements.Find<ReliableSessionBindingElement>(); if (settings == null) { settings = new ReliableSessionBindingElement(); context.BindingElements.Add(settings); } return settings; }
public void ImportPolicy(MetadataImporter importer, PolicyConversionContext context) { XmlQualifiedName wsdlBindingQName; string transportUri = WsdlImporter.SoapInPolicyWorkaroundHelper.FindAdHocPolicy(context, this.udpTransportUriKey, out wsdlBindingQName); if (transportUri != null && transportUri.Equals(UdpConstants.WsdlSoapUdpTransportUri, StringComparison.Ordinal) && !context.BindingElements.Contains(typeof(TransportBindingElement))) { UdpTransportBindingElement transport = new UdpTransportBindingElement(); ((ITransportPolicyImport)transport).ImportPolicy(importer, context); StateHelper.RegisterTransportBindingElement(importer, wsdlBindingQName); context.BindingElements.Add(transport); } }
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context) { if (importer == null) { throw new ArgumentNullException("importer"); } if (context == null) { throw new ArgumentNullException("context"); } ICollection<XmlElement> bindingAssertions = context.GetBindingAssertions(); List<XmlElement> processedAssertions = new List<XmlElement>(); UdpTransportBindingElement udpBindingElement = null; bool multicast = false; foreach (XmlElement assertion in bindingAssertions) { if (assertion.NamespaceURI != UdpPolicyStrings.UdpNamespace) { continue; } switch (assertion.LocalName) { case UdpPolicyStrings.TransportAssertion: udpBindingElement = new UdpTransportBindingElement(); break; case UdpPolicyStrings.MulticastAssertion: multicast = true; break; default: continue; } processedAssertions.Add(assertion); } if (udpBindingElement != null) { udpBindingElement.Multicast = multicast; context.BindingElements.Add(udpBindingElement); } for (int i = 0; i < processedAssertions.Count; i++) { bindingAssertions.Remove(processedAssertions[i]); } }
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context) { if (importer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("importer"); } if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } if ((PolicyConversionContext.FindAssertion(context.GetBindingAssertions(), "CompositeDuplex", "http://schemas.microsoft.com/net/2006/06/duplex", true) != null) || (WsdlImporter.WSAddressingHelper.DetermineSupportedAddressingMode(importer, context) == SupportedAddressingMode.NonAnonymous)) { context.BindingElements.Add(new CompositeDuplexBindingElement()); } }
void ImportOperationScopeSupportingTokensPolicy(MetadataImporter importer, PolicyConversionContext policyContext, SecurityBindingElement binding) { foreach (OperationDescription operation in policyContext.Contract.Operations) { string requestAction = null; foreach (MessageDescription message in operation.Messages) { if (message.Direction == MessageDirection.Input) { requestAction = message.Action; break; } } SupportingTokenParameters requirements = new SupportingTokenParameters(); SupportingTokenParameters optionalRequirements = new SupportingTokenParameters(); ICollection<XmlElement> operationBindingAssertions = policyContext.GetOperationBindingAssertions(operation); this.ImportSupportingTokenAssertions(importer, policyContext, operationBindingAssertions, requirements, optionalRequirements); if (requirements.Endorsing.Count > 0 || requirements.Signed.Count > 0 || requirements.SignedEncrypted.Count > 0 || requirements.SignedEndorsing.Count > 0) { if (requestAction != null) { binding.OperationSupportingTokenParameters[requestAction] = requirements; } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.CannotImportSupportingTokensForOperationWithoutRequestAction))); } } if (optionalRequirements.Endorsing.Count > 0 || optionalRequirements.Signed.Count > 0 || optionalRequirements.SignedEncrypted.Count > 0 || optionalRequirements.SignedEndorsing.Count > 0) { if (requestAction != null) { binding.OptionalOperationSupportingTokenParameters[requestAction] = optionalRequirements; } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.CannotImportSupportingTokensForOperationWithoutRequestAction))); } } } }
private static TransportBindingElement CreateTransportBindingElements(string transportUri, PolicyConversionContext policyContext) { TransportBindingElement element = null; string str = transportUri; if (str != null) { if (!(str == "http://schemas.xmlsoap.org/soap/http")) { if (str == "http://schemas.microsoft.com/soap/tcp") { return new TcpTransportBindingElement(); } if (str == "http://schemas.microsoft.com/soap/named-pipe") { return new NamedPipeTransportBindingElement(); } if (str == "http://schemas.microsoft.com/soap/msmq") { return new MsmqTransportBindingElement(); } if (str != "http://schemas.microsoft.com/soap/peer") { return element; } return new PeerTransportBindingElement(); } if (policyContext != null) { WSSecurityPolicy securityPolicy = null; ICollection<XmlElement> bindingAssertions = policyContext.GetBindingAssertions(); if (WSSecurityPolicy.TryGetSecurityPolicyDriver(bindingAssertions, out securityPolicy) && securityPolicy.ContainsWsspHttpsTokenAssertion(bindingAssertions)) { HttpsTransportBindingElement element2 = new HttpsTransportBindingElement { MessageSecurityVersion = securityPolicy.GetSupportedMessageSecurityVersion(SecurityVersion.WSSecurity11) }; element = element2; } } if (element == null) { element = new HttpTransportBindingElement(); } } return element; }
internal bool TryImportPolicy(PolicyConversionContext policyContext) { foreach (IPolicyImportExtension policyImporter in _policyExtensions) { try { policyImporter.ImportPolicy(this, policyContext); } #pragma warning disable 56500 // covered by FxCOP catch (Exception e) { if (Fx.IsFatal(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateExtensionException(policyImporter, e)); } } if (policyContext.GetBindingAssertions().Count != 0) { return(false); } foreach (OperationDescription operation in policyContext.Contract.Operations) { if (policyContext.GetOperationBindingAssertions(operation).Count != 0) { return(false); } foreach (MessageDescription message in operation.Messages) { if (policyContext.GetMessageBindingAssertions(message).Count != 0) { return(false); } } } return(true); }
void IPolicyImportExtension.ImportPolicy (MetadataImporter importer, PolicyConversionContext context) { var assertions = context.GetBindingAssertions (); var mtom = PolicyImportHelper.GetMtomMessageEncodingPolicy (assertions); if (mtom != null) { // http://www.w3.org/Submission/WS-MTOMPolicy/ context.BindingElements.Add (new MtomMessageEncodingBindingElement ()); return; } var binary = PolicyImportHelper.GetBinaryMessageEncodingPolicy (assertions); if (binary != null) { context.BindingElements.Add (new BinaryMessageEncodingBindingElement ()); return; } context.BindingElements.Add (new TextMessageEncodingBindingElement ()); }
internal void OnExportPolicy(MetadataExporter exporter, PolicyConversionContext context) { string str = ""; switch (this.CredentialType) { case PeerTransportCredentialType.Password: str = "PeerTransportCredentialTypePassword"; break; case PeerTransportCredentialType.Certificate: str = "PeerTransportCredentialTypeCertificate"; break; default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); } XmlElement item = new XmlDocument().CreateElement("pc", "PeerTransportCredentialType", "http://schemas.microsoft.com/soap/peer"); item.InnerText = str; context.GetBindingAssertions().Add(item); }
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext policyContext) { if (policyContext == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("policyContext"); XmlElement useManagedPresentationAssertion = PolicyConversionContext.FindAssertion(policyContext.GetBindingAssertions(), UseManagedPresentationPolicyStrings.RequireFederatedIdentityProvisioningName, UseManagedPresentationPolicyStrings.UseManagedPresentationNamespace, true); if (useManagedPresentationAssertion != null) { UseManagedPresentationBindingElement settings = policyContext.BindingElements.Find<UseManagedPresentationBindingElement>(); if (null == settings) { settings = new UseManagedPresentationBindingElement(); policyContext.BindingElements.Add(settings); } } }
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context) { if (importer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("importer"); } if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } bool gotAssertion = false; XmlElement reliableSessionAssertion = PolicyConversionContext.FindAssertion(context.GetBindingAssertions(), ReliableSessionPolicyStrings.ReliableSessionName, ReliableSessionPolicyStrings.ReliableSessionFebruary2005Namespace, true); if (reliableSessionAssertion != null) { ProcessReliableSessionFeb2005Assertion(reliableSessionAssertion, GetReliableSessionBindingElement(context)); gotAssertion = true; } reliableSessionAssertion = PolicyConversionContext.FindAssertion(context.GetBindingAssertions(), ReliableSessionPolicyStrings.ReliableSessionName, ReliableSessionPolicyStrings.ReliableSession11Namespace, true); if (reliableSessionAssertion != null) { if (gotAssertion) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidChannelBindingException( SR.GetString(SR.MultipleVersionsFoundInPolicy, ReliableSessionPolicyStrings.ReliableSessionName))); } ProcessReliableSession11Assertion(importer, reliableSessionAssertion, GetReliableSessionBindingElement(context)); } }
private void ImportEndpointScopeMessageBindingAssertions(MetadataImporter importer, PolicyConversionContext policyContext, SecurityBindingElement binding) { XmlElement assertion = null; WSSecurityPolicy policy; this.ImportSupportingTokenAssertions(importer, policyContext, policyContext.GetBindingAssertions(), binding.EndpointSupportingTokenParameters, binding.OptionalEndpointSupportingTokenParameters); if (WSSecurityPolicy.TryGetSecurityPolicyDriver(policyContext.GetBindingAssertions(), out policy)) { if (!policy.TryImportWsspWssAssertion(importer, policyContext.GetBindingAssertions(), binding, out assertion) && (assertion != null)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("UnsupportedSecurityPolicyAssertion", new object[] { assertion.OuterXml }))); } if (!policy.TryImportWsspTrustAssertion(importer, policyContext.GetBindingAssertions(), binding, out assertion) && (assertion != null)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("UnsupportedSecurityPolicyAssertion", new object[] { assertion.OuterXml }))); } } if (assertion == null) { binding.DoNotEmitTrust = true; } }
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context) { if (importer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("importer"); } if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } XmlElement compositeDuplexAssertion = PolicyConversionContext.FindAssertion(context.GetBindingAssertions(), TransportPolicyConstants.CompositeDuplex, TransportPolicyConstants.CompositeDuplexNamespace, true); if (compositeDuplexAssertion != null || WsdlImporter.WSAddressingHelper.DetermineSupportedAddressingMode(importer, context) == SupportedAddressingMode.NonAnonymous) { context.BindingElements.Add(new CompositeDuplexBindingElement()); } }
internal void OnImportPolicy(MetadataImporter importer, PolicyConversionContext context) { string str; XmlElement element = PolicyConversionContext.FindAssertion(context.GetBindingAssertions(), "PeerTransportCredentialType", "http://schemas.microsoft.com/soap/peer", true); PeerTransportCredentialType password = PeerTransportCredentialType.Password; if ((element != null) && ((str = element.InnerText) != null)) { if (!(str == "PeerTransportCredentialTypePassword")) { if (str == "PeerTransportCredentialTypeCertificate") { password = PeerTransportCredentialType.Certificate; } } else { password = PeerTransportCredentialType.Password; } } this.CredentialType = password; }
internal void OnExportPolicy(MetadataExporter exporter, PolicyConversionContext context) { string assertion = ""; switch (this.CredentialType) { case PeerTransportCredentialType.Password: assertion = PeerTransportPolicyConstants.PeerTransportCredentialTypePassword; break; case PeerTransportCredentialType.Certificate: assertion = PeerTransportPolicyConstants.PeerTransportCredentialTypeCertificate; break; default: Fx.Assert("Unsupported value for PeerTransportSecuritySettings.CredentialType"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); } XmlDocument doc = new XmlDocument(); XmlElement element = doc.CreateElement(PeerTransportPolicyConstants.PeerTransportPrefix, PeerTransportPolicyConstants.PeerTransportCredentialType, TransportPolicyConstants.PeerTransportUri); element.InnerText = assertion; context.GetBindingAssertions().Add(element); }
internal void OnImportPolicy(MetadataImporter importer, PolicyConversionContext context) { XmlElement element = PolicyConversionContext.FindAssertion(context.GetBindingAssertions(), PeerTransportPolicyConstants.PeerTransportCredentialType, TransportPolicyConstants.PeerTransportUri, true); PeerTransportCredentialType credentialType = PeerTransportCredentialType.Password; if (element != null) { switch (element.InnerText) { case PeerTransportPolicyConstants.PeerTransportCredentialTypePassword: credentialType = PeerTransportCredentialType.Password; break; case PeerTransportPolicyConstants.PeerTransportCredentialTypeCertificate: credentialType = PeerTransportCredentialType.Certificate; break; default: break; } } this.CredentialType = credentialType; }
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context) { if (importer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("importer"); } if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } XmlElement oneWayAssertion = PolicyConversionContext.FindAssertion(context.GetBindingAssertions(), OneWayPolicyConstants.OneWay, OneWayPolicyConstants.Namespace, true); if (oneWayAssertion != null) { OneWayBindingElement bindingElement = new OneWayBindingElement(); context.BindingElements.Add(bindingElement); for (int i = 0; i < oneWayAssertion.ChildNodes.Count; i++) { XmlNode currentNode = oneWayAssertion.ChildNodes[i]; if (currentNode != null && currentNode.NodeType == XmlNodeType.Element && currentNode.NamespaceURI == OneWayPolicyConstants.Namespace && currentNode.LocalName == OneWayPolicyConstants.PacketRoutable) { bindingElement.PacketRoutable = true; break; } } } else if (WsdlImporter.WSAddressingHelper.DetermineSupportedAddressingMode(importer, context) == SupportedAddressingMode.NonAnonymous) { context.BindingElements.Add(new OneWayBindingElement()); } }
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context) { foreach (XmlElement assertion in context.GetBindingAssertions()) { if (assertion.Name == HttpCookiePolicyStrings.HttpCookiePolicyElement && assertion.NamespaceURI == HttpCookiePolicyStrings.Namespace) { HttpCookieSessionBindingElement bindingElement = new HttpCookieSessionBindingElement(); XmlAttribute attribute = assertion.Attributes[HttpCookiePolicyStrings.ExchangeTerminateAttribute]; if(attribute != null) { bindingElement.ExchangeTerminateMessage = true; } context.BindingElements.Add(bindingElement); break; } } }
void IPolicyImportExtension.ImportPolicy(MetadataImporter importer, PolicyConversionContext context) { Console.WriteLine("ImportPolicy"); if (importer == null) { throw new ArgumentNullException("importer"); } if (context == null) { throw new ArgumentNullException("context"); } SsbBindingElement ssbBindingElement = null; PolicyAssertionCollection policyAssertions = context.GetBindingAssertions(); if (policyAssertions.Remove(SsbConstants.SsbTransportAssertion, SsbConstants.SsbNs) != null) { ssbBindingElement = new SsbBindingElement(); ssbBindingElement.SqlConnectionString = ""; } if (ssbBindingElement != null) { context.BindingElements.Add(ssbBindingElement); } }
public virtual bool TryImportWsspAsymmetricBindingAssertion(MetadataImporter importer, PolicyConversionContext policyContext, ICollection<XmlElement> assertions, out AsymmetricSecurityBindingElement binding, out XmlElement assertion) { binding = null; Collection<Collection<XmlElement>> alternatives; if (TryImportWsspAssertion(assertions, AsymmetricBindingName, out assertion) && TryGetNestedPolicyAlternatives(importer, assertion, out alternatives)) { foreach (Collection<XmlElement> alternative in alternatives) { MessageProtectionOrder order; bool protectTokens; binding = new AsymmetricSecurityBindingElement(); if (TryImportWsspInitiatorTokenAssertion(importer, policyContext, alternative, binding) && TryImportWsspRecipientTokenAssertion(importer, policyContext, alternative, binding) && TryImportWsspAlgorithmSuiteAssertion(importer, alternative, binding) && TryImportWsspLayoutAssertion(importer, alternative, binding) && TryImportWsspIncludeTimestampAssertion(alternative, binding) && TryImportMessageProtectionOrderAssertions(alternative, out order) && TryImportWsspProtectTokensAssertion(alternative, out protectTokens) && TryImportWsspAssertion(alternative, OnlySignEntireHeadersAndBodyName, true) && alternative.Count == 0) { binding.MessageProtectionOrder = order; binding.ProtectTokens = protectTokens; break; } else { binding = null; } } } return binding != null; }