public static void ClientCredentialType_Property_Values_Not_Supported(MessageCredentialType credentialType) { MessageSecurityOverTcp msot = new MessageSecurityOverTcp(); Assert.Throws <PlatformNotSupportedException>(() => { msot.ClientCredentialType = credentialType; }); }
internal void ApplyConfiguration(MessageSecurityOverTcp security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(security)); } security.ClientCredentialType = this.ClientCredentialType; }
public static void Ctor_Default_Properties_Not_Supported() { MessageSecurityOverTcp msot = new MessageSecurityOverTcp(); Assert.Throws <PlatformNotSupportedException>(() => { MessageCredentialType unused = msot.ClientCredentialType; }); }
public static void ClientCredentialType_Property_Values_Supported(MessageCredentialType credentialType) { MessageSecurityOverTcp msot = new MessageSecurityOverTcp(); msot.ClientCredentialType = credentialType; MessageCredentialType actual = msot.ClientCredentialType; Assert.True(actual == credentialType, string.Format("ClientCredentialType returned '{0}' but expected '{1}'", credentialType, actual)); }
internal void InitializeFrom(MessageSecurityOverTcp security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ClientCredentialType, security.ClientCredentialType); if (security.WasAlgorithmSuiteSet) { SetPropertyValueIfNotDefaultValue(ConfigurationStrings.AlgorithmSuite, security.AlgorithmSuite); } }
internal void ApplyConfiguration(MessageSecurityOverTcp security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } security.ClientCredentialType = this.ClientCredentialType; if (PropertyValueOrigin.Default != this.ElementInformation.Properties[ConfigurationStrings.AlgorithmSuite].ValueOrigin) { security.AlgorithmSuite = this.AlgorithmSuite; } }
internal void InitializeFrom(MessageSecurityOverTcp security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } this.ClientCredentialType = security.ClientCredentialType; if (security.WasAlgorithmSuiteSet) { this.AlgorithmSuite = security.AlgorithmSuite; } }
public static void Main() { // <Snippet0> using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService))) { serviceHost.Open(); ServiceEndpointCollection endpoints = serviceHost.Description.Endpoints; ServiceEndpoint endpoint = endpoints.Find(typeof(ICalculator)); NetTcpBinding binding = (NetTcpBinding)endpoint.Binding; // <Snippet1> NetTcpSecurity security = binding.Security; MessageSecurityOverTcp msTcp = security.Message; Console.WriteLine("Dumping NetTcpSecurity object:"); Console.WriteLine("\tMessageSecurityOverTcp:"); Console.WriteLine("\t\tAlgorithm Suite: {0}", msTcp.AlgorithmSuite); Console.WriteLine("\t\tClient Credential Type: {0}", msTcp.ClientCredentialType); // </Snippet1> Console.WriteLine("\tSecurity Mode: {0}", security.Mode); // <Snippet3> TcpTransportSecurity tsTcp = security.Transport; Console.WriteLine("\tTcpTransportSecurity:"); Console.WriteLine("\t\tClient Credential Type: {0}", tsTcp.ClientCredentialType); Console.WriteLine("\t\tProtectionLevel: {0}", tsTcp.ProtectionLevel); // </Snippet3> // The service can now be accessed. Console.WriteLine("The service is ready."); Console.WriteLine("Press <ENTER> to terminate service."); Console.WriteLine(); Console.ReadLine(); } // </Snippet0> }
public static void Ctor_Default_Properties() { MessageSecurityOverTcp msot = new MessageSecurityOverTcp(); Assert.True(msot != null, "MessageSecurityOverTcp default ctor failed"); }
public static List <NetTcpBinding> GetNetTcpBindings(string exeConfigPath) { if (string.IsNullOrWhiteSpace(exeConfigPath)) { return(null); } var svcSection = Read.Config.ExeConfig.GetServiceModelSection(exeConfigPath); var defaultTimeout = new TimeSpan(0, 0, 60); var configs = new List <NetTcpBinding>(); foreach ( var section in svcSection.Bindings.NetTcpBinding.ConfiguredBindings .Cast <NetTcpBindingElement>()) { var dfltb = new NetTcpBinding(); var binding = new NetTcpBinding { Name = section.Name, CloseTimeout = section.CloseTimeout != TimeSpan.Zero ? section.CloseTimeout : defaultTimeout, OpenTimeout = section.OpenTimeout != TimeSpan.Zero ? section.OpenTimeout : defaultTimeout, SendTimeout = section.SendTimeout != TimeSpan.Zero ? section.SendTimeout : defaultTimeout, ReceiveTimeout = section.ReceiveTimeout != TimeSpan.Zero ? section.ReceiveTimeout : defaultTimeout, MaxReceivedMessageSize = section.MaxReceivedMessageSize > 0 ? section.MaxReceivedMessageSize : dfltb.MaxReceivedMessageSize, MaxBufferPoolSize = section.MaxBufferPoolSize > 0 ? section.MaxBufferPoolSize : dfltb.MaxBufferPoolSize, MaxConnections = section.MaxConnections > 0 ? section.MaxConnections : dfltb.MaxConnections, ListenBacklog = section.ListenBacklog > 0 ? section.ListenBacklog : dfltb.ListenBacklog, PortSharingEnabled = section.PortSharingEnabled, TransactionFlow = section.TransactionFlow, TransferMode = section.TransferMode, HostNameComparisonMode = section.HostNameComparisonMode }; var readerQuotasSection = section.ReaderQuotas; var readerQuotas = new System.Xml.XmlDictionaryReaderQuotas(); if (readerQuotasSection != null && readerQuotasSection.MaxDepth > 0) { readerQuotas.MaxDepth = readerQuotasSection.MaxDepth; readerQuotas.MaxStringContentLength = readerQuotasSection.MaxStringContentLength; readerQuotas.MaxArrayLength = readerQuotasSection.MaxArrayLength; readerQuotas.MaxBytesPerRead = readerQuotasSection.MaxBytesPerRead; readerQuotas.MaxNameTableCharCount = readerQuotasSection.MaxNameTableCharCount; } else { readerQuotas = null; } var netTcpSecurity = new NetTcpSecurity { Mode = section.Security.Mode }; var tcpTransportSecurity = new TcpTransportSecurity(); var msgSecurityOverTcp = new MessageSecurityOverTcp { ClientCredentialType = section.Security.Message.ClientCredentialType, AlgorithmSuite = section.Security.Message.AlgorithmSuite }; netTcpSecurity.Message = msgSecurityOverTcp; netTcpSecurity.Transport = tcpTransportSecurity; binding.Security = netTcpSecurity; if (readerQuotas != null) { binding.ReaderQuotas = readerQuotas; } binding.ReliableSession = new OptionalReliableSession { Enabled = section.ReliableSession.Enabled, InactivityTimeout = section.ReliableSession.InactivityTimeout, Ordered = section.ReliableSession.Ordered }; configs.Add(binding); } return(configs); }
private NetTcpSecurity(SecurityMode mode, TcpTransportSecurity transportSecurity, MessageSecurityOverTcp messageSecurity) { Fx.Assert(SecurityModeHelper.IsDefined(mode), string.Format("Invalid SecurityMode value: {0}.", mode.ToString())); _mode = mode; Transport = transportSecurity ?? new TcpTransportSecurity(); Message = messageSecurity ?? new MessageSecurityOverTcp(); }