Example #1
0
        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);
            }
        }
Example #2
0
		static XmlElement FindAndRemove (PolicyAssertionCollection collection, string name, string ns)
		{
			var element = collection.Find (name, ns);
			if (element != null)
				collection.Remove (element);
			return element;
		}
        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 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 void AssertPolicy(
            PolicyAssertionCollection assertions, QName qname, TestLabel label)
        {
            var assertion = assertions.Find(qname.Name, qname.Namespace);

            label.EnterScope(qname.Name);
            Assert.That(assertion, Is.Not.Null, label.ToString());
            assertions.Remove(assertion);
            label.LeaveScope();
        }
Example #6
0
        static XmlElement FindAndRemove(PolicyAssertionCollection collection, string name, string ns)
        {
            var element = collection.Find(name, ns);

            if (element != null)
            {
                collection.Remove(element);
            }
            return(element);
        }
Example #7
0
        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);
        }
Example #8
0
		public static void AssertPolicy (
			PolicyAssertionCollection assertions, QName qname, TestLabel label)
		{
			var assertion = assertions.Find (qname.Name, qname.Namespace);
			label.EnterScope (qname.Name);
			Assert.That (assertion, Is.Not.Null, label.ToString ());
			assertions.Remove (assertion);
			label.LeaveScope ();
		}
 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;
        }