Exemplo n.º 1
0
        public override void ApplyConfiguration(BindingElement bindingElement)
        {
            base.ApplyConfiguration(bindingElement);
            WindowsStreamSecurityBindingElement element = (WindowsStreamSecurityBindingElement)bindingElement;

            element.ProtectionLevel = this.ProtectionLevel;
        }
Exemplo n.º 2
0
        protected internal override void InitializeFrom(BindingElement bindingElement)
        {
            base.InitializeFrom(bindingElement);
            WindowsStreamSecurityBindingElement element = (WindowsStreamSecurityBindingElement)bindingElement;

            this.ProtectionLevel = element.ProtectionLevel;
        }
        public WindowsStreamSecurityUpgradeProvider(WindowsStreamSecurityBindingElement bindingElement,
            BindingContext context, bool isClient)
            : base(context.Binding)
        {
            this.extractGroupsForWindowsAccounts = TransportDefaults.ExtractGroupsForWindowsAccounts;
            this.protectionLevel = bindingElement.ProtectionLevel;
            this.scheme = context.Binding.Scheme;
            this.isClient = isClient;
            this.listenUri = TransportSecurityHelpers.GetListenUri(context.ListenUriBaseAddress, context.ListenUriRelativeAddress);

            SecurityCredentialsManager credentialProvider = context.BindingParameters.Find<SecurityCredentialsManager>();
            if (credentialProvider == null)
            {
                if (isClient)
                {
                    credentialProvider = ClientCredentials.CreateDefaultCredentials();
                }
                else
                {
                    credentialProvider = ServiceCredentials.CreateDefaultCredentials();
                }
            }


            this.securityTokenManager = credentialProvider.CreateSecurityTokenManager();
        }
Exemplo n.º 4
0
        internal WindowsStreamSecurityBindingElement CreateTransportProtectionAndAuthentication()
        {
            WindowsStreamSecurityBindingElement result = new WindowsStreamSecurityBindingElement();

            result.ProtectionLevel = this.protectionLevel;
            return(result);
        }
Exemplo n.º 5
0
        protected internal override BindingElement CreateBindingElement()
        {
            WindowsStreamSecurityBindingElement bindingElement = new WindowsStreamSecurityBindingElement();

            this.ApplyConfiguration(bindingElement);
            return(bindingElement);
        }
        public WindowsStreamSecurityUpgradeProvider(WindowsStreamSecurityBindingElement bindingElement,
            BindingContext context, bool isClient)
            : base(context.Binding)
        {
            _extractGroupsForWindowsAccounts = TransportDefaults.ExtractGroupsForWindowsAccounts;
            _protectionLevel = bindingElement.ProtectionLevel;
            _scheme = context.Binding.Scheme;
            _isClient = isClient;
            _listenUri = TransportSecurityHelpers.GetListenUri(context.ListenUriBaseAddress, context.ListenUriRelativeAddress);

            SecurityCredentialsManager credentialProvider = context.BindingParameters.Find<SecurityCredentialsManager>();

            if (credentialProvider == null)
            {
                if (isClient)
                {
                    credentialProvider = ClientCredentials.CreateDefaultCredentials();
                }
                else
                {
                    throw ExceptionHelper.PlatformNotSupported("WindowsStreamSecurityUpgradeProvider for server is not supported.");
                }
            }

            _securityTokenManager = credentialProvider.CreateSecurityTokenManager();
        }
Exemplo n.º 7
0
        protected void AddWindowsStreamSecurityBindingElement(BindingElementCollection bindingElements)
        {
            WindowsStreamSecurityBindingElement item = new WindowsStreamSecurityBindingElement {
                ProtectionLevel = ProtectionLevel.EncryptAndSign
            };

            bindingElements.Add(item);
        }
Exemplo n.º 8
0
        protected internal override void InitializeFrom(BindingElement bindingElement)
        {
            base.InitializeFrom(bindingElement);
            WindowsStreamSecurityBindingElement windowsBindingElement
                = (WindowsStreamSecurityBindingElement)bindingElement;

            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ProtectionLevel, windowsBindingElement.ProtectionLevel);
        }
        protected internal override BindingElement CreateBindingElement()
        {
            WindowsStreamSecurityBindingElement windowsBindingElement
                = new WindowsStreamSecurityBindingElement();

            this.ApplyConfiguration(windowsBindingElement);
            return windowsBindingElement;
        }
        public override void ApplyConfiguration(BindingElement bindingElement)
        {
            base.ApplyConfiguration(bindingElement);
            WindowsStreamSecurityBindingElement windowsBindingElement =
                (WindowsStreamSecurityBindingElement)bindingElement;

#if DESKTOP
            windowsBindingElement.ProtectionLevel = this.ProtectionLevel;
#endif
        }
 internal static bool TryCreate(WindowsStreamSecurityBindingElement wssbe, NetNamedPipeSecurityMode mode, out NetNamedPipeSecurity security)
 {
     security = null;
     NamedPipeTransportSecurity transportSecurity = new NamedPipeTransportSecurity();
     if ((mode == NetNamedPipeSecurityMode.Transport) && !NamedPipeTransportSecurity.IsTransportProtectionAndAuthentication(wssbe, transportSecurity))
     {
         return false;
     }
     security = new NetNamedPipeSecurity(mode, transportSecurity);
     return true;
 }
        internal static bool TryCreate(WindowsStreamSecurityBindingElement wssbe, NetNamedPipeSecurityMode mode, out NetNamedPipeSecurity security)
        {
            security = null;
            NamedPipeTransportSecurity transportSecurity = new NamedPipeTransportSecurity();

            if ((mode == NetNamedPipeSecurityMode.Transport) && !NamedPipeTransportSecurity.IsTransportProtectionAndAuthentication(wssbe, transportSecurity))
            {
                return(false);
            }
            security = new NetNamedPipeSecurity(mode, transportSecurity);
            return(true);
        }
Exemplo n.º 13
0
 internal BindingElement CreateTransportProtectionAndAuthentication()
 {
     if (_clientCredentialType == TcpClientCredentialType.Certificate || _clientCredentialType == TcpClientCredentialType.None)
     {
         return(CreateSslBindingElement(_clientCredentialType == TcpClientCredentialType.Certificate));
     }
     else
     {
         WindowsStreamSecurityBindingElement result = new WindowsStreamSecurityBindingElement();
         result.ProtectionLevel = _protectionLevel;
         return(result);
     }
 }
Exemplo n.º 14
0
 internal BindingElement CreateTransportProtectionAndAuthentication()
 {
     if (_clientCredentialType == TcpClientCredentialType.Certificate || _clientCredentialType == TcpClientCredentialType.None)
     {
         return this.CreateSslBindingElement(_clientCredentialType == TcpClientCredentialType.Certificate);
     }
     else
     {
         WindowsStreamSecurityBindingElement result = new WindowsStreamSecurityBindingElement();
         result.ProtectionLevel = _protectionLevel;
         return result;
     }
 }
        public override BindingElementCollection CreateBindingElements()
        {
            BindingElementCollection elements = new BindingElementCollection {
                this.context,
                this.encoding
            };
            WindowsStreamSecurityBindingElement item = this.CreateTransportSecurity();

            if (item != null)
            {
                elements.Add(item);
            }
            elements.Add(this.namedPipe);
            return(elements.Clone());
        }
        public WindowsStreamSecurityUpgradeProvider(WindowsStreamSecurityBindingElement bindingElement,
            BindingContext context, bool isClient)
            : base(context.Binding)
        {
            Contract.Assert(isClient, ".NET Core and .NET Native does not support server side");

            _extractGroupsForWindowsAccounts = TransportDefaults.ExtractGroupsForWindowsAccounts;
            _protectionLevel = bindingElement.ProtectionLevel;
            _scheme = context.Binding.Scheme;
            _isClient = isClient;
            _listenUri = TransportSecurityHelpers.GetListenUri(context.ListenUriBaseAddress, context.ListenUriRelativeAddress);

            SecurityCredentialsManager credentialProvider = context.BindingParameters.Find<SecurityCredentialsManager>();
            if (credentialProvider == null)
            {
                credentialProvider = ClientCredentials.CreateDefaultCredentials();
            }

            _securityTokenManager = credentialProvider.CreateSecurityTokenManager();
        }
        public override BindingElementCollection CreateBindingElements()
        {   // return collection of BindingElements
            BindingElementCollection bindingElements = new BindingElementCollection();

            // order of BindingElements is important
            // add context
            bindingElements.Add(context);
            // add encoding
            bindingElements.Add(encoding);
            // add transport security
            WindowsStreamSecurityBindingElement transportSecurity = CreateTransportSecurity();

            if (transportSecurity != null)
            {
                bindingElements.Add(transportSecurity);
            }
            // add transport (named pipes)
            bindingElements.Add(this.namedPipe);

            return(bindingElements.Clone());
        }
        internal static bool TryCreate(BindingElementCollection elements, out Binding binding)
        {
            binding = null;
            if (elements.Count > 4)
            {
                return(false);
            }

            TransactionFlowBindingElement       context   = null;
            BinaryMessageEncodingBindingElement encoding  = null;
            WindowsStreamSecurityBindingElement security  = null;
            NamedPipeTransportBindingElement    namedPipe = null;

            foreach (BindingElement element in elements)
            {
                if (element is TransactionFlowBindingElement)
                {
                    context = element as TransactionFlowBindingElement;
                }
                else if (element is BinaryMessageEncodingBindingElement)
                {
                    encoding = element as BinaryMessageEncodingBindingElement;
                }
                else if (element is WindowsStreamSecurityBindingElement)
                {
                    security = element as WindowsStreamSecurityBindingElement;
                }
                else if (element is NamedPipeTransportBindingElement)
                {
                    namedPipe = element as NamedPipeTransportBindingElement;
                }
                else
                {
                    return(false);
                }
            }

            if (namedPipe == null)
            {
                return(false);
            }

            if (encoding == null)
            {
                return(false);
            }

            if (context == null)
            {
                context = GetDefaultTransactionFlowBindingElement();
            }

            NetNamedPipeSecurity pipeSecurity;

            if (!TryCreateSecurity(security, out pipeSecurity))
            {
                return(false);
            }

            NetNamedPipeBinding netNamedPipeBinding = new NetNamedPipeBinding(pipeSecurity);

            netNamedPipeBinding.InitializeFrom(namedPipe, encoding, context);

            if (!netNamedPipeBinding.IsBindingElementsMatch(namedPipe, encoding, context))
            {
                return(false);
            }

            binding = netNamedPipeBinding;
            return(true);
        }
 private static bool TryCreateSecurity(WindowsStreamSecurityBindingElement wssbe, out NetNamedPipeSecurity security)
 {
     NetNamedPipeSecurityMode mode = (wssbe == null) ? NetNamedPipeSecurityMode.None : NetNamedPipeSecurityMode.Transport;
     return NetNamedPipeSecurity.TryCreate(wssbe, mode, out security);
 }
Exemplo n.º 20
0
        static void FillBindingInfo(BindingElement bindingElement, ref IWmiInstance instance)
        {
            Fx.Assert(null != bindingElement, "");
            Fx.Assert(null != instance, "");

            if (bindingElement is IWmiInstanceProvider)
            {
                IWmiInstanceProvider instanceProvider = (IWmiInstanceProvider)bindingElement;
                instance = instance.NewInstance(instanceProvider.GetInstanceType());
                instanceProvider.FillInstance(instance);
                return;
            }

            Type elementType = AdministrationHelpers.GetServiceModelBaseType(bindingElement.GetType());

            if (null != elementType)
            {
                instance = instance.NewInstance(elementType.Name);
                if (bindingElement is TransportBindingElement)
                {
                    TransportBindingElement transport = (TransportBindingElement)bindingElement;
                    instance.SetProperty(AdministrationStrings.ManualAddressing, transport.ManualAddressing);
                    instance.SetProperty(AdministrationStrings.MaxReceivedMessageSize, transport.MaxReceivedMessageSize);
                    instance.SetProperty(AdministrationStrings.MaxBufferPoolSize, transport.MaxBufferPoolSize);
                    instance.SetProperty(AdministrationStrings.Scheme, transport.Scheme);

                    if (bindingElement is ConnectionOrientedTransportBindingElement)
                    {
                        ConnectionOrientedTransportBindingElement connectionOriented = (ConnectionOrientedTransportBindingElement)bindingElement;
                        instance.SetProperty(AdministrationStrings.ConnectionBufferSize, connectionOriented.ConnectionBufferSize);
                        instance.SetProperty(AdministrationStrings.HostNameComparisonMode, connectionOriented.HostNameComparisonMode.ToString());
                        instance.SetProperty(AdministrationStrings.ChannelInitializationTimeout, connectionOriented.ChannelInitializationTimeout);
                        instance.SetProperty(AdministrationStrings.MaxBufferSize, connectionOriented.MaxBufferSize);
                        instance.SetProperty(AdministrationStrings.MaxPendingConnections, connectionOriented.MaxPendingConnections);
                        instance.SetProperty(AdministrationStrings.MaxOutputDelay, connectionOriented.MaxOutputDelay);
                        instance.SetProperty(AdministrationStrings.MaxPendingAccepts, connectionOriented.MaxPendingAccepts);
                        instance.SetProperty(AdministrationStrings.TransferMode, connectionOriented.TransferMode.ToString());

                        if (bindingElement is TcpTransportBindingElement)
                        {
                            TcpTransportBindingElement tcp = (TcpTransportBindingElement)bindingElement;
                            instance.SetProperty(AdministrationStrings.ListenBacklog, tcp.ListenBacklog);
                            instance.SetProperty(AdministrationStrings.PortSharingEnabled, tcp.PortSharingEnabled);
                            instance.SetProperty(AdministrationStrings.TeredoEnabled, tcp.TeredoEnabled);

                            IWmiInstance connectionPool = instance.NewInstance(AdministrationStrings.TcpConnectionPoolSettings);
                            connectionPool.SetProperty(AdministrationStrings.GroupName, tcp.ConnectionPoolSettings.GroupName);
                            connectionPool.SetProperty(AdministrationStrings.IdleTimeout, tcp.ConnectionPoolSettings.IdleTimeout);
                            connectionPool.SetProperty(AdministrationStrings.LeaseTimeout, tcp.ConnectionPoolSettings.LeaseTimeout);
                            connectionPool.SetProperty(AdministrationStrings.MaxOutboundConnectionsPerEndpoint, tcp.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint);

                            instance.SetProperty(AdministrationStrings.ConnectionPoolSettings, connectionPool);

                            FillExtendedProtectionPolicy(instance, tcp.ExtendedProtectionPolicy);
                        }
                        else if (bindingElement is NamedPipeTransportBindingElement)
                        {
                            NamedPipeTransportBindingElement namedPipe = (NamedPipeTransportBindingElement)bindingElement;
                            IWmiInstance connectionPool = instance.NewInstance(AdministrationStrings.NamedPipeConnectionPoolSettings);

                            connectionPool.SetProperty(AdministrationStrings.GroupName, namedPipe.ConnectionPoolSettings.GroupName);
                            connectionPool.SetProperty(AdministrationStrings.IdleTimeout, namedPipe.ConnectionPoolSettings.IdleTimeout);
                            connectionPool.SetProperty(AdministrationStrings.MaxOutboundConnectionsPerEndpoint, namedPipe.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint);

                            instance.SetProperty(AdministrationStrings.ConnectionPoolSettings, connectionPool);
                        }
                    }
                    else if (bindingElement is HttpTransportBindingElement)
                    {
                        HttpTransportBindingElement http = (HttpTransportBindingElement)bindingElement;
                        instance.SetProperty(AdministrationStrings.AllowCookies, http.AllowCookies);
                        instance.SetProperty(AdministrationStrings.AuthenticationScheme, http.AuthenticationScheme.ToString());

                        instance.SetProperty(AdministrationStrings.BypassProxyOnLocal, http.BypassProxyOnLocal);
                        instance.SetProperty(AdministrationStrings.DecompressionEnabled, http.DecompressionEnabled);
                        instance.SetProperty(AdministrationStrings.HostNameComparisonMode, http.HostNameComparisonMode.ToString());
                        instance.SetProperty(AdministrationStrings.KeepAliveEnabled, http.KeepAliveEnabled);
                        instance.SetProperty(AdministrationStrings.MaxBufferSize, http.MaxBufferSize);
                        if (null != http.ProxyAddress)
                        {
                            instance.SetProperty(AdministrationStrings.ProxyAddress, http.ProxyAddress.AbsoluteUri.ToString());
                        }
                        instance.SetProperty(AdministrationStrings.ProxyAuthenticationScheme, http.ProxyAuthenticationScheme.ToString());
                        instance.SetProperty(AdministrationStrings.Realm, http.Realm);
                        instance.SetProperty(AdministrationStrings.TransferMode, http.TransferMode.ToString());
                        instance.SetProperty(AdministrationStrings.UnsafeConnectionNtlmAuthentication, http.UnsafeConnectionNtlmAuthentication);
                        instance.SetProperty(AdministrationStrings.UseDefaultWebProxy, http.UseDefaultWebProxy);

                        FillExtendedProtectionPolicy(instance, http.ExtendedProtectionPolicy);

                        if (bindingElement is HttpsTransportBindingElement)
                        {
                            HttpsTransportBindingElement https = (HttpsTransportBindingElement)bindingElement;
                            instance.SetProperty(AdministrationStrings.RequireClientCertificate, https.RequireClientCertificate);
                        }
                    }
                    else if (bindingElement is MsmqBindingElementBase)
                    {
                        MsmqBindingElementBase msmq = (MsmqBindingElementBase)bindingElement;

                        if (null != msmq.CustomDeadLetterQueue)
                        {
                            instance.SetProperty(AdministrationStrings.CustomDeadLetterQueue, msmq.CustomDeadLetterQueue.AbsoluteUri.ToString());
                        }
                        instance.SetProperty(AdministrationStrings.DeadLetterQueue, msmq.DeadLetterQueue);
                        instance.SetProperty(AdministrationStrings.Durable, msmq.Durable);
                        instance.SetProperty(AdministrationStrings.ExactlyOnce, msmq.ExactlyOnce);
                        instance.SetProperty(AdministrationStrings.MaxRetryCycles, msmq.MaxRetryCycles);
                        instance.SetProperty(AdministrationStrings.ReceiveContextEnabled, msmq.ReceiveContextEnabled);
                        instance.SetProperty(AdministrationStrings.ReceiveErrorHandling, msmq.ReceiveErrorHandling);
                        instance.SetProperty(AdministrationStrings.ReceiveRetryCount, msmq.ReceiveRetryCount);
                        instance.SetProperty(AdministrationStrings.RetryCycleDelay, msmq.RetryCycleDelay);
                        instance.SetProperty(AdministrationStrings.TimeToLive, msmq.TimeToLive);
                        instance.SetProperty(AdministrationStrings.UseSourceJournal, msmq.UseSourceJournal);
                        instance.SetProperty(AdministrationStrings.UseMsmqTracing, msmq.UseMsmqTracing);
                        instance.SetProperty(AdministrationStrings.ValidityDuration, msmq.ValidityDuration);

                        MsmqTransportBindingElement msmqTransport = msmq as MsmqTransportBindingElement;
                        if (null != msmqTransport)
                        {
                            instance.SetProperty(AdministrationStrings.MaxPoolSize, msmqTransport.MaxPoolSize);
                            instance.SetProperty(AdministrationStrings.QueueTransferProtocol, msmqTransport.QueueTransferProtocol);
                            instance.SetProperty(AdministrationStrings.UseActiveDirectory, msmqTransport.UseActiveDirectory);
                        }

                        MsmqIntegrationBindingElement msmqIntegration = msmq as MsmqIntegrationBindingElement;
                        if (null != msmqIntegration)
                        {
                            instance.SetProperty(AdministrationStrings.SerializationFormat, msmqIntegration.SerializationFormat.ToString());
                        }
                    }
#pragma warning disable 0618
                    else if (bindingElement is PeerTransportBindingElement)
                    {
                        PeerTransportBindingElement peer = (PeerTransportBindingElement)bindingElement;
                        instance.SetProperty(AdministrationStrings.ListenIPAddress, peer.ListenIPAddress);
                        instance.SetProperty(AdministrationStrings.Port, peer.Port);

                        IWmiInstance securitySettings = instance.NewInstance(AdministrationStrings.PeerSecuritySettings);
                        securitySettings.SetProperty(AdministrationStrings.PeerSecurityMode, peer.Security.Mode.ToString());
                        IWmiInstance transportSecuritySettings = securitySettings.NewInstance(AdministrationStrings.PeerTransportSecuritySettings);
                        transportSecuritySettings.SetProperty(AdministrationStrings.PeerTransportCredentialType, peer.Security.Transport.CredentialType.ToString());
                        securitySettings.SetProperty(AdministrationStrings.Transport, transportSecuritySettings);
                        instance.SetProperty(AdministrationStrings.Security, securitySettings);
                    }
                }
                else if (bindingElement is PeerResolverBindingElement)
                {
                    PeerResolverBindingElement baseResolver = (PeerResolverBindingElement)bindingElement;
                    instance.SetProperty(AdministrationStrings.ReferralPolicy, baseResolver.ReferralPolicy.ToString());
                    if (bindingElement is PeerCustomResolverBindingElement)
                    {
                        PeerCustomResolverBindingElement specificElement = (PeerCustomResolverBindingElement)bindingElement;
                        if (specificElement.Address != null)
                        {
                            instance.SetProperty(AdministrationStrings.Address, specificElement.Address.ToString());
                        }
                        if (specificElement.Binding != null)
                        {
                            instance.SetProperty(AdministrationStrings.Binding, specificElement.Binding.ToString());
                        }
                    }
                }
#pragma warning restore 0618
                else if (bindingElement is ReliableSessionBindingElement)
                {
                    ReliableSessionBindingElement specificElement = (ReliableSessionBindingElement)bindingElement;
                    instance.SetProperty(AdministrationStrings.AcknowledgementInterval, specificElement.AcknowledgementInterval);
                    instance.SetProperty(AdministrationStrings.FlowControlEnabled, specificElement.FlowControlEnabled);
                    instance.SetProperty(AdministrationStrings.InactivityTimeout, specificElement.InactivityTimeout);
                    instance.SetProperty(AdministrationStrings.MaxPendingChannels, specificElement.MaxPendingChannels);
                    instance.SetProperty(AdministrationStrings.MaxRetryCount, specificElement.MaxRetryCount);
                    instance.SetProperty(AdministrationStrings.MaxTransferWindowSize, specificElement.MaxTransferWindowSize);
                    instance.SetProperty(AdministrationStrings.Ordered, specificElement.Ordered);
                    instance.SetProperty(AdministrationStrings.ReliableMessagingVersion, specificElement.ReliableMessagingVersion.ToString());
                }
                else if (bindingElement is SecurityBindingElement)
                {
                    SecurityBindingElement specificElement = (SecurityBindingElement)bindingElement;
                    instance.SetProperty(AdministrationStrings.AllowInsecureTransport, specificElement.AllowInsecureTransport);
                    instance.SetProperty(AdministrationStrings.DefaultAlgorithmSuite, specificElement.DefaultAlgorithmSuite.ToString());
                    instance.SetProperty(AdministrationStrings.EnableUnsecuredResponse, specificElement.EnableUnsecuredResponse);
                    instance.SetProperty(AdministrationStrings.IncludeTimestamp, specificElement.IncludeTimestamp);
                    instance.SetProperty(AdministrationStrings.KeyEntropyMode, specificElement.KeyEntropyMode.ToString());
                    instance.SetProperty(AdministrationStrings.SecurityHeaderLayout, specificElement.SecurityHeaderLayout.ToString());
                    instance.SetProperty(AdministrationStrings.MessageSecurityVersion, specificElement.MessageSecurityVersion.ToString());

                    IWmiInstance localServiceSecuritySettings = instance.NewInstance(AdministrationStrings.LocalServiceSecuritySettings);
                    localServiceSecuritySettings.SetProperty(AdministrationStrings.DetectReplays, specificElement.LocalServiceSettings.DetectReplays);
                    localServiceSecuritySettings.SetProperty(AdministrationStrings.InactivityTimeout, specificElement.LocalServiceSettings.InactivityTimeout);
                    localServiceSecuritySettings.SetProperty(AdministrationStrings.IssuedCookieLifetime, specificElement.LocalServiceSettings.IssuedCookieLifetime);
                    localServiceSecuritySettings.SetProperty(AdministrationStrings.MaxCachedCookies, specificElement.LocalServiceSettings.MaxCachedCookies);
                    localServiceSecuritySettings.SetProperty(AdministrationStrings.MaxClockSkew, specificElement.LocalServiceSettings.MaxClockSkew);
                    localServiceSecuritySettings.SetProperty(AdministrationStrings.MaxPendingSessions, specificElement.LocalServiceSettings.MaxPendingSessions);
                    localServiceSecuritySettings.SetProperty(AdministrationStrings.MaxStatefulNegotiations, specificElement.LocalServiceSettings.MaxStatefulNegotiations);
                    localServiceSecuritySettings.SetProperty(AdministrationStrings.NegotiationTimeout, specificElement.LocalServiceSettings.NegotiationTimeout);
                    localServiceSecuritySettings.SetProperty(AdministrationStrings.ReconnectTransportOnFailure, specificElement.LocalServiceSettings.ReconnectTransportOnFailure);
                    localServiceSecuritySettings.SetProperty(AdministrationStrings.ReplayCacheSize, specificElement.LocalServiceSettings.ReplayCacheSize);
                    localServiceSecuritySettings.SetProperty(AdministrationStrings.ReplayWindow, specificElement.LocalServiceSettings.ReplayWindow);
                    localServiceSecuritySettings.SetProperty(AdministrationStrings.SessionKeyRenewalInterval, specificElement.LocalServiceSettings.SessionKeyRenewalInterval);
                    localServiceSecuritySettings.SetProperty(AdministrationStrings.SessionKeyRolloverInterval, specificElement.LocalServiceSettings.SessionKeyRolloverInterval);
                    localServiceSecuritySettings.SetProperty(AdministrationStrings.TimestampValidityDuration, specificElement.LocalServiceSettings.TimestampValidityDuration);
                    instance.SetProperty(AdministrationStrings.LocalServiceSecuritySettings, localServiceSecuritySettings);

                    if (bindingElement is AsymmetricSecurityBindingElement)
                    {
                        AsymmetricSecurityBindingElement specificElement1 = (AsymmetricSecurityBindingElement)bindingElement;

                        instance.SetProperty(AdministrationStrings.MessageProtectionOrder, specificElement1.MessageProtectionOrder.ToString());
                        instance.SetProperty(AdministrationStrings.RequireSignatureConfirmation, specificElement1.RequireSignatureConfirmation);
                    }
                    else if (bindingElement is SymmetricSecurityBindingElement)
                    {
                        SymmetricSecurityBindingElement specificElement1 = (SymmetricSecurityBindingElement)bindingElement;

                        instance.SetProperty(AdministrationStrings.MessageProtectionOrder, specificElement1.MessageProtectionOrder.ToString());
                        instance.SetProperty(AdministrationStrings.RequireSignatureConfirmation, specificElement1.RequireSignatureConfirmation);
                    }
                }
                else if (bindingElement is WindowsStreamSecurityBindingElement)
                {
                    WindowsStreamSecurityBindingElement specificElement
                        = (WindowsStreamSecurityBindingElement)bindingElement;
                    instance.SetProperty(AdministrationStrings.ProtectionLevel, specificElement.ProtectionLevel.ToString());
                }
                else if (bindingElement is SslStreamSecurityBindingElement)
                {
                    SslStreamSecurityBindingElement specificElement = (SslStreamSecurityBindingElement)bindingElement;
                    instance.SetProperty(AdministrationStrings.RequireClientCertificate, specificElement.RequireClientCertificate);
                }
                else if (bindingElement is CompositeDuplexBindingElement)
                {
                    CompositeDuplexBindingElement specificElement = (CompositeDuplexBindingElement)bindingElement;
                    if (specificElement.ClientBaseAddress != null)
                    {
                        instance.SetProperty(AdministrationStrings.ClientBaseAddress, specificElement.ClientBaseAddress.AbsoluteUri);
                    }
                }
                else if (bindingElement is OneWayBindingElement)
                {
                    OneWayBindingElement oneWay = (OneWayBindingElement)bindingElement;
                    IWmiInstance         channelPoolSettings = instance.NewInstance(AdministrationStrings.ChannelPoolSettings);
                    channelPoolSettings.SetProperty(AdministrationStrings.IdleTimeout, oneWay.ChannelPoolSettings.IdleTimeout);
                    channelPoolSettings.SetProperty(AdministrationStrings.LeaseTimeout, oneWay.ChannelPoolSettings.LeaseTimeout);
                    channelPoolSettings.SetProperty(AdministrationStrings.MaxOutboundChannelsPerEndpoint, oneWay.ChannelPoolSettings.MaxOutboundChannelsPerEndpoint);
                    instance.SetProperty(AdministrationStrings.ChannelPoolSettings, channelPoolSettings);
                    instance.SetProperty(AdministrationStrings.PacketRoutable, oneWay.PacketRoutable);
                    instance.SetProperty(AdministrationStrings.MaxAcceptedChannels, oneWay.MaxAcceptedChannels);
                }
                else if (bindingElement is MessageEncodingBindingElement)
                {
                    MessageEncodingBindingElement encodingElement = (MessageEncodingBindingElement)bindingElement;

                    instance.SetProperty(AdministrationStrings.MessageVersion, encodingElement.MessageVersion.ToString());

                    if (bindingElement is BinaryMessageEncodingBindingElement)
                    {
                        BinaryMessageEncodingBindingElement specificElement = (BinaryMessageEncodingBindingElement)bindingElement;
                        instance.SetProperty(AdministrationStrings.MaxSessionSize, specificElement.MaxSessionSize);
                        instance.SetProperty(AdministrationStrings.MaxReadPoolSize, specificElement.MaxReadPoolSize);
                        instance.SetProperty(AdministrationStrings.MaxWritePoolSize, specificElement.MaxWritePoolSize);
                        if (null != specificElement.ReaderQuotas)
                        {
                            FillReaderQuotas(instance, specificElement.ReaderQuotas);
                        }
                        instance.SetProperty(AdministrationStrings.CompressionFormat, specificElement.CompressionFormat.ToString());
                    }
                    else if (bindingElement is TextMessageEncodingBindingElement)
                    {
                        TextMessageEncodingBindingElement specificElement = (TextMessageEncodingBindingElement)bindingElement;
                        instance.SetProperty(AdministrationStrings.Encoding, specificElement.WriteEncoding.WebName);
                        instance.SetProperty(AdministrationStrings.MaxReadPoolSize, specificElement.MaxReadPoolSize);
                        instance.SetProperty(AdministrationStrings.MaxWritePoolSize, specificElement.MaxWritePoolSize);
                        if (null != specificElement.ReaderQuotas)
                        {
                            FillReaderQuotas(instance, specificElement.ReaderQuotas);
                        }
                    }
                    else if (bindingElement is MtomMessageEncodingBindingElement)
                    {
                        MtomMessageEncodingBindingElement specificElement = (MtomMessageEncodingBindingElement)bindingElement;
                        instance.SetProperty(AdministrationStrings.Encoding, specificElement.WriteEncoding.WebName);
                        instance.SetProperty(AdministrationStrings.MessageVersion, specificElement.MessageVersion.ToString());
                        instance.SetProperty(AdministrationStrings.MaxReadPoolSize, specificElement.MaxReadPoolSize);
                        instance.SetProperty(AdministrationStrings.MaxWritePoolSize, specificElement.MaxWritePoolSize);
                        if (null != specificElement.ReaderQuotas)
                        {
                            FillReaderQuotas(instance, specificElement.ReaderQuotas);
                        }
                    }
                }
                else if (bindingElement is TransactionFlowBindingElement)
                {
                    TransactionFlowBindingElement specificElement = (TransactionFlowBindingElement)bindingElement;
                    instance.SetProperty(AdministrationStrings.TransactionFlow, specificElement.Transactions);
                    instance.SetProperty(AdministrationStrings.TransactionProtocol, specificElement.TransactionProtocol.ToString());
                    instance.SetProperty(AdministrationStrings.AllowWildcardAction, specificElement.AllowWildcardAction);
                }
                else if (bindingElement is PrivacyNoticeBindingElement)
                {
                    PrivacyNoticeBindingElement specificElement = (PrivacyNoticeBindingElement)bindingElement;
                    instance.SetProperty(AdministrationStrings.Url, specificElement.Url.ToString());
                    instance.SetProperty(AdministrationStrings.PrivacyNoticeVersion, specificElement.Version);
                }
            }
        }
 internal WindowsStreamSecurityBindingElement CreateTransportProtectionAndAuthentication()
 {
     WindowsStreamSecurityBindingElement result = new WindowsStreamSecurityBindingElement();
     result.ProtectionLevel = this.protectionLevel;
     return result;
 }
Exemplo n.º 22
0
 internal static bool IsTransportProtectionAndAuthentication(WindowsStreamSecurityBindingElement wssbe, NamedPipeTransportSecurity transportSecurity)
 {
     transportSecurity.protectionLevel = wssbe.ProtectionLevel;
     return(true);
 }
        static bool TryCreateSecurity(WindowsStreamSecurityBindingElement wssbe, out NetNamedPipeSecurity security)
        {
            NetNamedPipeSecurityMode mode = wssbe == null ? NetNamedPipeSecurityMode.None : NetNamedPipeSecurityMode.Transport;

            return(NetNamedPipeSecurity.TryCreate(wssbe, mode, out security));
        }
 internal static bool IsTransportProtectionAndAuthentication(WindowsStreamSecurityBindingElement wssbe, NamedPipeTransportSecurity transportSecurity)
 {
     transportSecurity.protectionLevel = wssbe.ProtectionLevel;
     return true;
 }
Exemplo n.º 25
0
		bool ImportWindowsTransportSecurity (MetadataImporter importer,
		                                     PolicyConversionContext context,
		                                     XmlElement policyElement)
		{
			var protectionLevel = PolicyImportHelper.GetElement (
				importer, policyElement, "ProtectionLevel",
				PolicyImportHelper.FramingPolicyNS, true);
			if (protectionLevel == null) {
				importer.AddWarning (
					"Invalid policy assertion: {0}", policyElement.OuterXml);
				return false;
			}

			var element = new WindowsStreamSecurityBindingElement ();

			switch (protectionLevel.InnerText.ToLowerInvariant ()) {
			case "none":
				element.ProtectionLevel = ProtectionLevel.None;
				break;
			case "sign":
				element.ProtectionLevel = ProtectionLevel.Sign;
				break;
			case "encryptandsign":
				element.ProtectionLevel = ProtectionLevel.EncryptAndSign;
				break;
			default:
				importer.AddWarning (
					"Invalid policy assertion: {0}", protectionLevel.OuterXml);
				return false;
			}

			context.BindingElements.Add (element);
			return true;
		}
Exemplo n.º 26
0
        public static void CheckNetTcpBinding(
            Binding binding, SecurityMode security, bool reliableSession,
            TransferMode transferMode, TestLabel label)
        {
            label.EnterScope("net-tcp");
            if (security == SecurityMode.Message)
            {
                Assert.That(binding, Is.InstanceOfType(typeof(CustomBinding)), label.Get());
            }
            else
            {
                Assert.That(binding, Is.InstanceOfType(typeof(NetTcpBinding)), label.Get());
                var netTcp = (NetTcpBinding)binding;
                Assert.That(netTcp.EnvelopeVersion, Is.EqualTo(EnvelopeVersion.Soap12), label.Get());
                Assert.That(netTcp.MessageVersion, Is.EqualTo(MessageVersion.Soap12WSAddressing10), label.Get());
                Assert.That(netTcp.Scheme, Is.EqualTo("net.tcp"), label.Get());
                Assert.That(netTcp.TransferMode, Is.EqualTo(transferMode), label.Get());

                label.EnterScope("security");
                Assert.That(netTcp.Security, Is.Not.Null, label.Get());
                Assert.That(netTcp.Security.Mode, Is.EqualTo(security), label.Get());

                Assert.That(netTcp.Security.Transport, Is.Not.Null, label.Get());
                Assert.That(netTcp.Security.Transport.ProtectionLevel, Is.EqualTo(ProtectionLevel.EncryptAndSign), label.Get());
                Assert.That(netTcp.Security.Transport.ClientCredentialType, Is.EqualTo(TcpClientCredentialType.Windows), label.Get());
                label.LeaveScope();
            }

            label.EnterScope("elements");

            var elements = binding.CreateBindingElements();

            Assert.That(elements, Is.Not.Null, label.Get());

            TcpTransportBindingElement          transportElement         = null;
            TransactionFlowBindingElement       transactionFlowElement   = null;
            BinaryMessageEncodingBindingElement encodingElement          = null;
            WindowsStreamSecurityBindingElement windowsStreamElement     = null;
            ReliableSessionBindingElement       reliableSessionElement   = null;
            TransportSecurityBindingElement     transportSecurityElement = null;
            SslStreamSecurityBindingElement     sslStreamElement         = null;
            SymmetricSecurityBindingElement     symmSecurityElement      = null;

            foreach (var element in elements)
            {
                if (element is TcpTransportBindingElement)
                {
                    transportElement = (TcpTransportBindingElement)element;
                }
                else if (element is TransactionFlowBindingElement)
                {
                    transactionFlowElement = (TransactionFlowBindingElement)element;
                }
                else if (element is BinaryMessageEncodingBindingElement)
                {
                    encodingElement = (BinaryMessageEncodingBindingElement)element;
                }
                else if (element is WindowsStreamSecurityBindingElement)
                {
                    windowsStreamElement = (WindowsStreamSecurityBindingElement)element;
                }
                else if (element is ReliableSessionBindingElement)
                {
                    reliableSessionElement = (ReliableSessionBindingElement)element;
                }
                else if (element is TransportSecurityBindingElement)
                {
                    transportSecurityElement = (TransportSecurityBindingElement)element;
                }
                else if (element is SslStreamSecurityBindingElement)
                {
                    sslStreamElement = (SslStreamSecurityBindingElement)element;
                }
                else if (element is SymmetricSecurityBindingElement)
                {
                    symmSecurityElement = (SymmetricSecurityBindingElement)element;
                }
                else
                {
                    Assert.Fail(string.Format(
                                    "Unknown element `{0}'.", element.GetType()), label.Get());
                }
            }

            label.EnterScope("windows-stream");
            if (security == SecurityMode.Transport)
            {
                Assert.That(windowsStreamElement, Is.Not.Null, label.Get());
                Assert.That(windowsStreamElement.ProtectionLevel, Is.EqualTo(ProtectionLevel.EncryptAndSign), label.Get());
            }
            else
            {
                Assert.That(windowsStreamElement, Is.Null, label.Get());
            }
            label.LeaveScope();

            label.EnterScope("reliable-session");
            if (reliableSession)
            {
                Assert.That(reliableSessionElement, Is.Not.Null, label.Get());
            }
            else
            {
                Assert.That(reliableSessionElement, Is.Null, label.Get());
            }
            label.LeaveScope();

            label.EnterScope("encoding");
            Assert.That(encodingElement, Is.Not.Null, label.Get());
            label.LeaveScope();

            label.EnterScope("transaction");
            if (security == SecurityMode.Message)
            {
                Assert.That(transactionFlowElement, Is.Null, label.Get());
            }
            else
            {
                Assert.That(transactionFlowElement, Is.Not.Null, label.Get());
            }
            label.LeaveScope();

            label.EnterScope("transport");
            Assert.That(transportElement, Is.Not.Null, label.Get());

            Assert.That(transportElement.Scheme, Is.EqualTo("net.tcp"), label.Get());
            Assert.That(transportElement.TransferMode, Is.EqualTo(transferMode), label.Get());
            label.LeaveScope();              // transport

            label.EnterScope("security");
            switch (security)
            {
            case SecurityMode.None:
            case SecurityMode.Transport:
                Assert.That(transportSecurityElement, Is.Null, label.Get());
                Assert.That(sslStreamElement, Is.Null, label.Get());
                Assert.That(symmSecurityElement, Is.Null, label.Get());
                break;

            case SecurityMode.TransportWithMessageCredential:
                Assert.That(transportSecurityElement, Is.Not.Null, label.Get());
                Assert.That(sslStreamElement, Is.Not.Null, label.Get());
                Assert.That(symmSecurityElement, Is.Null, label.Get());
                break;

            case SecurityMode.Message:
                Assert.That(transportSecurityElement, Is.Null, label.Get());
                Assert.That(sslStreamElement, Is.Null, label.Get());
                Assert.That(symmSecurityElement, Is.Not.Null, label.Get());
                break;

            default:
                throw new InvalidOperationException();
            }
            label.LeaveScope();

            label.LeaveScope();              // elements
            label.LeaveScope();              // net-tcp
        }
 private static void FillBindingInfo(BindingElement bindingElement, ref IWmiInstance instance)
 {
     if (bindingElement is IWmiInstanceProvider)
     {
         IWmiInstanceProvider provider = (IWmiInstanceProvider)bindingElement;
         instance = instance.NewInstance(provider.GetInstanceType());
         provider.FillInstance(instance);
     }
     else
     {
         System.Type serviceModelBaseType = AdministrationHelpers.GetServiceModelBaseType(bindingElement.GetType());
         if (null != serviceModelBaseType)
         {
             instance = instance.NewInstance(serviceModelBaseType.Name);
             if (bindingElement is TransportBindingElement)
             {
                 TransportBindingElement element = (TransportBindingElement)bindingElement;
                 instance.SetProperty("ManualAddressing", element.ManualAddressing);
                 instance.SetProperty("MaxReceivedMessageSize", element.MaxReceivedMessageSize);
                 instance.SetProperty("MaxBufferPoolSize", element.MaxBufferPoolSize);
                 instance.SetProperty("Scheme", element.Scheme);
                 if (bindingElement is ConnectionOrientedTransportBindingElement)
                 {
                     ConnectionOrientedTransportBindingElement element2 = (ConnectionOrientedTransportBindingElement)bindingElement;
                     instance.SetProperty("ConnectionBufferSize", element2.ConnectionBufferSize);
                     instance.SetProperty("HostNameComparisonMode", element2.HostNameComparisonMode.ToString());
                     instance.SetProperty("ChannelInitializationTimeout", element2.ChannelInitializationTimeout);
                     instance.SetProperty("MaxBufferSize", element2.MaxBufferSize);
                     instance.SetProperty("MaxPendingConnections", element2.MaxPendingConnections);
                     instance.SetProperty("MaxOutputDelay", element2.MaxOutputDelay);
                     instance.SetProperty("MaxPendingAccepts", element2.MaxPendingAccepts);
                     instance.SetProperty("TransferMode", element2.TransferMode.ToString());
                     if (bindingElement is TcpTransportBindingElement)
                     {
                         TcpTransportBindingElement element3 = (TcpTransportBindingElement)bindingElement;
                         instance.SetProperty("ListenBacklog", element3.ListenBacklog);
                         instance.SetProperty("PortSharingEnabled", element3.PortSharingEnabled);
                         instance.SetProperty("TeredoEnabled", element3.TeredoEnabled);
                         IWmiInstance instance2 = instance.NewInstance("TcpConnectionPoolSettings");
                         instance2.SetProperty("GroupName", element3.ConnectionPoolSettings.GroupName);
                         instance2.SetProperty("IdleTimeout", element3.ConnectionPoolSettings.IdleTimeout);
                         instance2.SetProperty("LeaseTimeout", element3.ConnectionPoolSettings.LeaseTimeout);
                         instance2.SetProperty("MaxOutboundConnectionsPerEndpoint", element3.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint);
                         instance.SetProperty("ConnectionPoolSettings", instance2);
                         FillExtendedProtectionPolicy(instance, element3.ExtendedProtectionPolicy);
                     }
                     else if (bindingElement is NamedPipeTransportBindingElement)
                     {
                         NamedPipeTransportBindingElement element4 = (NamedPipeTransportBindingElement)bindingElement;
                         IWmiInstance instance3 = instance.NewInstance("NamedPipeConnectionPoolSettings");
                         instance3.SetProperty("GroupName", element4.ConnectionPoolSettings.GroupName);
                         instance3.SetProperty("IdleTimeout", element4.ConnectionPoolSettings.IdleTimeout);
                         instance3.SetProperty("MaxOutboundConnectionsPerEndpoint", element4.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint);
                         instance.SetProperty("ConnectionPoolSettings", instance3);
                     }
                 }
                 else if (!(bindingElement is HttpTransportBindingElement))
                 {
                     if (!(bindingElement is MsmqBindingElementBase))
                     {
                         if (bindingElement is PeerTransportBindingElement)
                         {
                             PeerTransportBindingElement element9 = (PeerTransportBindingElement)bindingElement;
                             instance.SetProperty("ListenIPAddress", element9.ListenIPAddress);
                             instance.SetProperty("Port", element9.Port);
                             IWmiInstance instance4 = instance.NewInstance("PeerSecuritySettings");
                             instance4.SetProperty("Mode", element9.Security.Mode.ToString());
                             IWmiInstance instance5 = instance4.NewInstance("PeerTransportSecuritySettings");
                             instance5.SetProperty("CredentialType", element9.Security.Transport.CredentialType.ToString());
                             instance4.SetProperty("Transport", instance5);
                             instance.SetProperty("Security", instance4);
                         }
                     }
                     else
                     {
                         MsmqBindingElementBase base2 = (MsmqBindingElementBase)bindingElement;
                         if (null != base2.CustomDeadLetterQueue)
                         {
                             instance.SetProperty("CustomDeadLetterQueue", base2.CustomDeadLetterQueue.AbsoluteUri.ToString());
                         }
                         instance.SetProperty("DeadLetterQueue", base2.DeadLetterQueue);
                         instance.SetProperty("Durable", base2.Durable);
                         instance.SetProperty("ExactlyOnce", base2.ExactlyOnce);
                         instance.SetProperty("MaxRetryCycles", base2.MaxRetryCycles);
                         instance.SetProperty("ReceiveContextEnabled", base2.ReceiveContextEnabled);
                         instance.SetProperty("ReceiveErrorHandling", base2.ReceiveErrorHandling);
                         instance.SetProperty("ReceiveRetryCount", base2.ReceiveRetryCount);
                         instance.SetProperty("RetryCycleDelay", base2.RetryCycleDelay);
                         instance.SetProperty("TimeToLive", base2.TimeToLive);
                         instance.SetProperty("UseSourceJournal", base2.UseSourceJournal);
                         instance.SetProperty("UseMsmqTracing", base2.UseMsmqTracing);
                         instance.SetProperty("ValidityDuration", base2.ValidityDuration);
                         MsmqTransportBindingElement element7 = base2 as MsmqTransportBindingElement;
                         if (element7 != null)
                         {
                             instance.SetProperty("MaxPoolSize", element7.MaxPoolSize);
                             instance.SetProperty("QueueTransferProtocol", element7.QueueTransferProtocol);
                             instance.SetProperty("UseActiveDirectory", element7.UseActiveDirectory);
                         }
                         MsmqIntegrationBindingElement element8 = base2 as MsmqIntegrationBindingElement;
                         if (element8 != null)
                         {
                             instance.SetProperty("SerializationFormat", element8.SerializationFormat.ToString());
                         }
                     }
                 }
                 else
                 {
                     HttpTransportBindingElement element5 = (HttpTransportBindingElement)bindingElement;
                     instance.SetProperty("AllowCookies", element5.AllowCookies);
                     instance.SetProperty("AuthenticationScheme", element5.AuthenticationScheme.ToString());
                     instance.SetProperty("BypassProxyOnLocal", element5.BypassProxyOnLocal);
                     instance.SetProperty("DecompressionEnabled", element5.DecompressionEnabled);
                     instance.SetProperty("HostNameComparisonMode", element5.HostNameComparisonMode.ToString());
                     instance.SetProperty("KeepAliveEnabled", element5.KeepAliveEnabled);
                     instance.SetProperty("MaxBufferSize", element5.MaxBufferSize);
                     if (null != element5.ProxyAddress)
                     {
                         instance.SetProperty("ProxyAddress", element5.ProxyAddress.AbsoluteUri.ToString());
                     }
                     instance.SetProperty("ProxyAuthenticationScheme", element5.ProxyAuthenticationScheme.ToString());
                     instance.SetProperty("Realm", element5.Realm);
                     instance.SetProperty("TransferMode", element5.TransferMode.ToString());
                     instance.SetProperty("UnsafeConnectionNtlmAuthentication", element5.UnsafeConnectionNtlmAuthentication);
                     instance.SetProperty("UseDefaultWebProxy", element5.UseDefaultWebProxy);
                     FillExtendedProtectionPolicy(instance, element5.ExtendedProtectionPolicy);
                     if (bindingElement is HttpsTransportBindingElement)
                     {
                         HttpsTransportBindingElement element6 = (HttpsTransportBindingElement)bindingElement;
                         instance.SetProperty("RequireClientCertificate", element6.RequireClientCertificate);
                     }
                 }
             }
             else if (bindingElement is PeerResolverBindingElement)
             {
                 PeerResolverBindingElement element10 = (PeerResolverBindingElement)bindingElement;
                 instance.SetProperty("ReferralPolicy", element10.ReferralPolicy.ToString());
                 if (bindingElement is PeerCustomResolverBindingElement)
                 {
                     PeerCustomResolverBindingElement element11 = (PeerCustomResolverBindingElement)bindingElement;
                     if (element11.Address != null)
                     {
                         instance.SetProperty("Address", element11.Address.ToString());
                     }
                     if (element11.Binding != null)
                     {
                         instance.SetProperty("Binding", element11.Binding.ToString());
                     }
                 }
             }
             else if (bindingElement is ReliableSessionBindingElement)
             {
                 ReliableSessionBindingElement element12 = (ReliableSessionBindingElement)bindingElement;
                 instance.SetProperty("AcknowledgementInterval", element12.AcknowledgementInterval);
                 instance.SetProperty("FlowControlEnabled", element12.FlowControlEnabled);
                 instance.SetProperty("InactivityTimeout", element12.InactivityTimeout);
                 instance.SetProperty("MaxPendingChannels", element12.MaxPendingChannels);
                 instance.SetProperty("MaxRetryCount", element12.MaxRetryCount);
                 instance.SetProperty("MaxTransferWindowSize", element12.MaxTransferWindowSize);
                 instance.SetProperty("Ordered", element12.Ordered);
                 instance.SetProperty("ReliableMessagingVersion", element12.ReliableMessagingVersion.ToString());
             }
             else if (bindingElement is SecurityBindingElement)
             {
                 SecurityBindingElement element13 = (SecurityBindingElement)bindingElement;
                 instance.SetProperty("AllowInsecureTransport", element13.AllowInsecureTransport);
                 instance.SetProperty("DefaultAlgorithmSuite", element13.DefaultAlgorithmSuite.ToString());
                 instance.SetProperty("EnableUnsecuredResponse", element13.EnableUnsecuredResponse);
                 instance.SetProperty("IncludeTimestamp", element13.IncludeTimestamp);
                 instance.SetProperty("KeyEntropyMode", element13.KeyEntropyMode.ToString());
                 instance.SetProperty("SecurityHeaderLayout", element13.SecurityHeaderLayout.ToString());
                 instance.SetProperty("MessageSecurityVersion", element13.MessageSecurityVersion.ToString());
                 IWmiInstance instance6 = instance.NewInstance("LocalServiceSecuritySettings");
                 instance6.SetProperty("DetectReplays", element13.LocalServiceSettings.DetectReplays);
                 instance6.SetProperty("InactivityTimeout", element13.LocalServiceSettings.InactivityTimeout);
                 instance6.SetProperty("IssuedCookieLifetime", element13.LocalServiceSettings.IssuedCookieLifetime);
                 instance6.SetProperty("MaxCachedCookies", element13.LocalServiceSettings.MaxCachedCookies);
                 instance6.SetProperty("MaxClockSkew", element13.LocalServiceSettings.MaxClockSkew);
                 instance6.SetProperty("MaxPendingSessions", element13.LocalServiceSettings.MaxPendingSessions);
                 instance6.SetProperty("MaxStatefulNegotiations", element13.LocalServiceSettings.MaxStatefulNegotiations);
                 instance6.SetProperty("NegotiationTimeout", element13.LocalServiceSettings.NegotiationTimeout);
                 instance6.SetProperty("ReconnectTransportOnFailure", element13.LocalServiceSettings.ReconnectTransportOnFailure);
                 instance6.SetProperty("ReplayCacheSize", element13.LocalServiceSettings.ReplayCacheSize);
                 instance6.SetProperty("ReplayWindow", element13.LocalServiceSettings.ReplayWindow);
                 instance6.SetProperty("SessionKeyRenewalInterval", element13.LocalServiceSettings.SessionKeyRenewalInterval);
                 instance6.SetProperty("SessionKeyRolloverInterval", element13.LocalServiceSettings.SessionKeyRolloverInterval);
                 instance6.SetProperty("TimestampValidityDuration", element13.LocalServiceSettings.TimestampValidityDuration);
                 instance.SetProperty("LocalServiceSecuritySettings", instance6);
                 if (bindingElement is AsymmetricSecurityBindingElement)
                 {
                     AsymmetricSecurityBindingElement element14 = (AsymmetricSecurityBindingElement)bindingElement;
                     instance.SetProperty("MessageProtectionOrder", element14.MessageProtectionOrder.ToString());
                     instance.SetProperty("RequireSignatureConfirmation", element14.RequireSignatureConfirmation);
                 }
                 else if (bindingElement is SymmetricSecurityBindingElement)
                 {
                     SymmetricSecurityBindingElement element15 = (SymmetricSecurityBindingElement)bindingElement;
                     instance.SetProperty("MessageProtectionOrder", element15.MessageProtectionOrder.ToString());
                     instance.SetProperty("RequireSignatureConfirmation", element15.RequireSignatureConfirmation);
                 }
             }
             else if (bindingElement is WindowsStreamSecurityBindingElement)
             {
                 WindowsStreamSecurityBindingElement element16 = (WindowsStreamSecurityBindingElement)bindingElement;
                 instance.SetProperty("ProtectionLevel", element16.ProtectionLevel.ToString());
             }
             else if (bindingElement is SslStreamSecurityBindingElement)
             {
                 SslStreamSecurityBindingElement element17 = (SslStreamSecurityBindingElement)bindingElement;
                 instance.SetProperty("RequireClientCertificate", element17.RequireClientCertificate);
             }
             else if (bindingElement is CompositeDuplexBindingElement)
             {
                 CompositeDuplexBindingElement element18 = (CompositeDuplexBindingElement)bindingElement;
                 if (element18.ClientBaseAddress != null)
                 {
                     instance.SetProperty("ClientBaseAddress", element18.ClientBaseAddress.AbsoluteUri);
                 }
             }
             else if (bindingElement is OneWayBindingElement)
             {
                 OneWayBindingElement element19 = (OneWayBindingElement)bindingElement;
                 IWmiInstance         instance7 = instance.NewInstance("ChannelPoolSettings");
                 instance7.SetProperty("IdleTimeout", element19.ChannelPoolSettings.IdleTimeout);
                 instance7.SetProperty("LeaseTimeout", element19.ChannelPoolSettings.LeaseTimeout);
                 instance7.SetProperty("MaxOutboundChannelsPerEndpoint", element19.ChannelPoolSettings.MaxOutboundChannelsPerEndpoint);
                 instance.SetProperty("ChannelPoolSettings", instance7);
                 instance.SetProperty("PacketRoutable", element19.PacketRoutable);
                 instance.SetProperty("MaxAcceptedChannels", element19.MaxAcceptedChannels);
             }
             else if (bindingElement is MessageEncodingBindingElement)
             {
                 MessageEncodingBindingElement element20 = (MessageEncodingBindingElement)bindingElement;
                 instance.SetProperty("MessageVersion", element20.MessageVersion.ToString());
                 if (bindingElement is BinaryMessageEncodingBindingElement)
                 {
                     BinaryMessageEncodingBindingElement element21 = (BinaryMessageEncodingBindingElement)bindingElement;
                     instance.SetProperty("MaxSessionSize", element21.MaxSessionSize);
                     instance.SetProperty("MaxReadPoolSize", element21.MaxReadPoolSize);
                     instance.SetProperty("MaxWritePoolSize", element21.MaxWritePoolSize);
                     if (element21.ReaderQuotas != null)
                     {
                         FillReaderQuotas(instance, element21.ReaderQuotas);
                     }
                 }
                 else if (!(bindingElement is TextMessageEncodingBindingElement))
                 {
                     if (bindingElement is MtomMessageEncodingBindingElement)
                     {
                         MtomMessageEncodingBindingElement element23 = (MtomMessageEncodingBindingElement)bindingElement;
                         instance.SetProperty("Encoding", element23.WriteEncoding.WebName);
                         instance.SetProperty("MessageVersion", element23.MessageVersion.ToString());
                         instance.SetProperty("MaxReadPoolSize", element23.MaxReadPoolSize);
                         instance.SetProperty("MaxWritePoolSize", element23.MaxWritePoolSize);
                         if (element23.ReaderQuotas != null)
                         {
                             FillReaderQuotas(instance, element23.ReaderQuotas);
                         }
                     }
                 }
                 else
                 {
                     TextMessageEncodingBindingElement element22 = (TextMessageEncodingBindingElement)bindingElement;
                     instance.SetProperty("Encoding", element22.WriteEncoding.WebName);
                     instance.SetProperty("MaxReadPoolSize", element22.MaxReadPoolSize);
                     instance.SetProperty("MaxWritePoolSize", element22.MaxWritePoolSize);
                     if (element22.ReaderQuotas != null)
                     {
                         FillReaderQuotas(instance, element22.ReaderQuotas);
                     }
                 }
             }
             else if (bindingElement is TransactionFlowBindingElement)
             {
                 TransactionFlowBindingElement element24 = (TransactionFlowBindingElement)bindingElement;
                 instance.SetProperty("TransactionFlow", element24.Transactions);
                 instance.SetProperty("TransactionProtocol", element24.TransactionProtocol.ToString());
                 instance.SetProperty("AllowWildcardAction", element24.AllowWildcardAction);
             }
             else if (bindingElement is PrivacyNoticeBindingElement)
             {
                 PrivacyNoticeBindingElement element25 = (PrivacyNoticeBindingElement)bindingElement;
                 instance.SetProperty("Url", element25.Url.ToString());
                 instance.SetProperty("PrivacyNoticeVersion", element25.Version);
             }
         }
     }
 }