当前位置: 首页>>代码示例>>C#>>正文


C# CustomBinding.GetProperty方法代码示例

本文整理汇总了C#中System.ServiceModel.Channels.CustomBinding.GetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# CustomBinding.GetProperty方法的具体用法?C# CustomBinding.GetProperty怎么用?C# CustomBinding.GetProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ServiceModel.Channels.CustomBinding的用法示例。


在下文中一共展示了CustomBinding.GetProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateWsspBootstrapPolicyAssertion

        public virtual XmlElement CreateWsspBootstrapPolicyAssertion(MetadataExporter exporter, SecurityBindingElement bootstrapSecurity)
        {
            if (bootstrapSecurity == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bootstrapBinding");

            WSSecurityPolicy sp = WSSecurityPolicy.GetSecurityPolicyDriver(bootstrapSecurity.MessageSecurityVersion);

            // create complete bootstrap binding

            CustomBinding bootstrapBinding = new CustomBinding(bootstrapSecurity);
            if (exporter.State.ContainsKey(SecurityPolicyStrings.SecureConversationBootstrapBindingElementsBelowSecurityKey))
            {
                BindingElementCollection bindingElementsBelowSecurity = exporter.State[SecurityPolicyStrings.SecureConversationBootstrapBindingElementsBelowSecurityKey] as BindingElementCollection;
                if (bindingElementsBelowSecurity != null)
                {
                    foreach (BindingElement be in bindingElementsBelowSecurity)
                    {
                        bootstrapBinding.Elements.Add(be);
                    }
                }
            }

            // generate policy for the "how" of security 

            ServiceEndpoint bootstrapEndpoint = new ServiceEndpoint(NullContract);
            bootstrapEndpoint.Binding = bootstrapBinding;
            PolicyConversionContext policyContext = exporter.ExportPolicy(bootstrapEndpoint);

            // generate policy for the "what" of security (protection assertions)

            // hard-coded requirements in V1: sign and encrypt RST and RSTR body
            ChannelProtectionRequirements bootstrapProtection = new ChannelProtectionRequirements();
            bootstrapProtection.IncomingEncryptionParts.AddParts(new MessagePartSpecification(true));
            bootstrapProtection.OutgoingEncryptionParts.AddParts(new MessagePartSpecification(true));
            bootstrapProtection.IncomingSignatureParts.AddParts(new MessagePartSpecification(true));
            bootstrapProtection.OutgoingSignatureParts.AddParts(new MessagePartSpecification(true));

            // add boostrap binding protection requirements (e.g. addressing headers)
            ChannelProtectionRequirements cpr = bootstrapBinding.GetProperty<ChannelProtectionRequirements>(new BindingParameterCollection());
            if (cpr != null)
            {
                bootstrapProtection.Add(cpr);
            }

            // extract channel-scope protection requirements and union them across request and response
            MessagePartSpecification encryption = new MessagePartSpecification();
            encryption.Union(bootstrapProtection.IncomingEncryptionParts.ChannelParts);
            encryption.Union(bootstrapProtection.OutgoingEncryptionParts.ChannelParts);
            encryption.MakeReadOnly();
            MessagePartSpecification signature = new MessagePartSpecification();
            signature.Union(bootstrapProtection.IncomingSignatureParts.ChannelParts);
            signature.Union(bootstrapProtection.OutgoingSignatureParts.ChannelParts);
            signature.MakeReadOnly();

            // create final boostrap policy assertion

            XmlElement nestedPolicy = CreateWspPolicyWrapper(
                    exporter,
                    sp.CreateWsspSignedPartsAssertion(signature),
                    sp.CreateWsspEncryptedPartsAssertion(encryption));
            foreach (XmlElement e in sp.FilterWsspPolicyAssertions(policyContext.GetBindingAssertions()))
            {
                nestedPolicy.AppendChild(e);
            }
            XmlElement result = CreateWsspAssertion(BootstrapPolicyName);
            result.AppendChild(nestedPolicy);

            return result;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:69,代码来源:WSSecurityPolicy.cs

示例2: CreateWsspBootstrapPolicyAssertion

 public virtual XmlElement CreateWsspBootstrapPolicyAssertion(MetadataExporter exporter, SecurityBindingElement bootstrapSecurity)
 {
     if (bootstrapSecurity == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bootstrapBinding");
     }
     WSSecurityPolicy securityPolicyDriver = GetSecurityPolicyDriver(bootstrapSecurity.MessageSecurityVersion);
     CustomBinding binding = new CustomBinding(new BindingElement[] { bootstrapSecurity });
     if (exporter.State.ContainsKey("SecureConversationBootstrapBindingElementsBelowSecurityKey"))
     {
         BindingElementCollection elements = exporter.State["SecureConversationBootstrapBindingElementsBelowSecurityKey"] as BindingElementCollection;
         if (elements != null)
         {
             foreach (BindingElement element in elements)
             {
                 binding.Elements.Add(element);
             }
         }
     }
     ServiceEndpoint endpoint = new ServiceEndpoint(NullContract) {
         Binding = binding
     };
     PolicyConversionContext context = exporter.ExportPolicy(endpoint);
     ChannelProtectionRequirements requirements = new ChannelProtectionRequirements();
     requirements.IncomingEncryptionParts.AddParts(new MessagePartSpecification(true));
     requirements.OutgoingEncryptionParts.AddParts(new MessagePartSpecification(true));
     requirements.IncomingSignatureParts.AddParts(new MessagePartSpecification(true));
     requirements.OutgoingSignatureParts.AddParts(new MessagePartSpecification(true));
     ChannelProtectionRequirements property = binding.GetProperty<ChannelProtectionRequirements>(new BindingParameterCollection());
     if (property != null)
     {
         requirements.Add(property);
     }
     MessagePartSpecification parts = new MessagePartSpecification();
     parts.Union(requirements.IncomingEncryptionParts.ChannelParts);
     parts.Union(requirements.OutgoingEncryptionParts.ChannelParts);
     parts.MakeReadOnly();
     MessagePartSpecification specification2 = new MessagePartSpecification();
     specification2.Union(requirements.IncomingSignatureParts.ChannelParts);
     specification2.Union(requirements.OutgoingSignatureParts.ChannelParts);
     specification2.MakeReadOnly();
     XmlElement newChild = this.CreateWspPolicyWrapper(exporter, new XmlElement[] { securityPolicyDriver.CreateWsspSignedPartsAssertion(specification2), securityPolicyDriver.CreateWsspEncryptedPartsAssertion(parts) });
     foreach (XmlElement element3 in securityPolicyDriver.FilterWsspPolicyAssertions(context.GetBindingAssertions()))
     {
         newChild.AppendChild(element3);
     }
     XmlElement element4 = this.CreateWsspAssertion("BootstrapPolicy");
     element4.AppendChild(newChild);
     return element4;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:50,代码来源:WSSecurityPolicy.cs


注:本文中的System.ServiceModel.Channels.CustomBinding.GetProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。