예제 #1
0
 public NetNamedPipeBinding(NetNamedPipeSecurityMode securityMode)
 {
     security = new NetNamedPipeSecurity()
     {
         Mode = securityMode
     };
 }
 internal void InitializeFrom(NetNamedPipeSecurity security)
 {
     if (security == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security");
     }
     SetPropertyValueIfNotDefaultValue(ConfigurationStrings.Mode, security.Mode);
     this.Transport.InitializeFrom(security.Transport);
 }
 internal void ApplyConfiguration(NetNamedPipeSecurity security)
 {
     if (security == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security");
     }
     security.Mode = this.Mode;
     this.Transport.ApplyConfiguration(security.Transport);
 }
 internal void InitializeFrom(NetNamedPipeSecurity security)
 {
     if (security == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security");
     }
     this.Mode = security.Mode;
     this.Transport.InitializeFrom(security.Transport);
 }
 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);
        }
예제 #7
0
        private static void GetNetNamedPipeBindingDetails(NetNamedPipeBinding binding, ref string name, ref string mode, ref string credentialType)
        {
            name = GetBindingName <NetNamedPipeBinding>(binding);

            NetNamedPipeSecurity netNamedPipeSecurity = binding.Security;

            mode = netNamedPipeSecurity?.ToString();
            switch (netNamedPipeSecurity?.Mode)
            {
            case NetNamedPipeSecurityMode.None:
                credentialType = "N/A";
                break;

            case NetNamedPipeSecurityMode.Transport:
                credentialType = netNamedPipeSecurity.Transport?.ProtectionLevel.ToString();
                break;
                // No message mode
            }
        }
 NetNamedPipeBinding(NetNamedPipeSecurity security)
     : this()
 {
     this.security = security;
 }
        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 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 NetNamedPipeBinding(NetNamedPipeSecurity security) : this()
 {
     this.security = security;
 }
 private static bool TryCreateSecurity(WindowsStreamSecurityBindingElement wssbe, out NetNamedPipeSecurity security)
 {
     NetNamedPipeSecurityMode mode = (wssbe == null) ? NetNamedPipeSecurityMode.None : NetNamedPipeSecurityMode.Transport;
     return NetNamedPipeSecurity.TryCreate(wssbe, mode, out security);
 }
 public NetNamedPipeBinding()
 {
     this.security = new NetNamedPipeSecurity();
     this.Initialize();
 }
        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;
        }
 public NetNamedPipeBinding()
 {
     this.security = new NetNamedPipeSecurity();
     this.Initialize();
 }
		public NetNamedPipeBinding (NetNamedPipeSecurityMode securityMode)
		{
			security = new NetNamedPipeSecurity () { Mode = securityMode };
		}