public static void snippetSecurity() { //<Snippet8> WSHttpBinding wsHttpBinding = new WSHttpBinding(); WSHttpSecurity whSecurity = wsHttpBinding.Security; //</Snippet8> }
internal void ApplyConfiguration(WSHttpSecurity security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } security.Mode = this.Mode; this.Transport.ApplyConfiguration(security.Transport); this.Message.ApplyConfiguration(security.Message); }
internal void InitializeFrom(WSHttpSecurity security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } this.Mode = security.Mode; this.Transport.InitializeFrom(security.Transport); this.Message.InitializeFrom(security.Message); }
internal void InitializeFrom(WSHttpSecurity security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } SetPropertyValueIfNotDefaultValue(ConfigurationStrings.Mode, security.Mode); this.Transport.InitializeFrom(security.Transport); this.Message.InitializeFrom(security.Message); }
public static Binding GetBinding() { // securityMode is Message // reliableSessionEnabled is true WSHttpBinding binding = new WSHttpBinding(SecurityMode.Message, true); binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows; WSHttpSecurity security = binding.Security; return(binding); }
private static WSHttpBinding getWebHttpBinding() { #region WSHttpBinding httpbinding = new WSHttpBinding(); WSHttpSecurity security = new WSHttpSecurity(); security.Mode = SecurityMode.None; httpbinding.Security = security; httpbinding.MaxBufferPoolSize = 2147483647; httpbinding.MaxReceivedMessageSize = 2147483647; return(httpbinding); #endregion }
public void DefaultValues() { WSHttpBinding b = new WSHttpBinding(); // common tests DefaultValues(b, "http"); // WSHttpSecurity WSHttpSecurity sec = b.Security; Assert.IsNotNull(sec, "#2-1"); Assert.AreEqual(SecurityMode.Message, sec.Mode, "#2-2"); // Security.Message NonDualMessageSecurityOverHttp msg = sec.Message; Assert.IsNotNull(msg, "#2-3"); Assert.AreEqual(true, msg.EstablishSecurityContext, "#2-3-1"); Assert.AreEqual(SecurityAlgorithmSuite.Default, msg.AlgorithmSuite, "#2-3-2"); // it is not worthy of test, just for checking default value. Assert.AreEqual(MessageCredentialType.Windows, msg.ClientCredentialType, "#2-3-3"); Assert.AreEqual(true, msg.NegotiateServiceCredential, "#2-3-4"); // FIXME: test Security.Transport Assert.IsNotNull(sec.Transport, "#2-4"); // Binding elements BindingElementCollection bec = b.CreateBindingElements(); Assert.AreEqual(4, bec.Count, "#5-1"); Assert.AreEqual(typeof(TransactionFlowBindingElement), bec [0].GetType(), "#5-2"); Assert.AreEqual(typeof(SymmetricSecurityBindingElement), bec [1].GetType(), "#5-3"); Assert.AreEqual(typeof(TextMessageEncodingBindingElement), bec [2].GetType(), "#5-4"); Assert.AreEqual(typeof(HttpTransportBindingElement), bec [3].GetType(), "#5-5"); }
public static void snippetSecurity() { WSHttpBinding wsHttpBinding = new WSHttpBinding(); WSHttpSecurity whSecurity = wsHttpBinding.Security; }
public static List <WSHttpBinding> GetWsHttpBindings(string exeConfigPath) { if (string.IsNullOrWhiteSpace(exeConfigPath)) { return(null); } var svcSection = Read.Config.ExeConfig.GetServiceModelSection(exeConfigPath); var configs = new List <WSHttpBinding>(); foreach ( var section in svcSection.Bindings.WSHttpBinding.ConfiguredBindings .Cast <WSHttpBindingElement>()) { var df = new WSHttpBinding(); var binding = new WSHttpBinding { Name = section.Name, MaxBufferPoolSize = section.MaxBufferPoolSize > 0 ? section.MaxBufferPoolSize : df.MaxBufferPoolSize, MaxReceivedMessageSize = section.MaxReceivedMessageSize > 0 ? section.MaxReceivedMessageSize : df.MaxReceivedMessageSize, CloseTimeout = section.CloseTimeout != TimeSpan.Zero ? section.CloseTimeout : df.CloseTimeout, OpenTimeout = section.OpenTimeout != TimeSpan.Zero ? section.OpenTimeout : df.OpenTimeout, SendTimeout = section.SendTimeout != TimeSpan.Zero ? section.SendTimeout : df.SendTimeout, ReceiveTimeout = section.ReceiveTimeout != TimeSpan.Zero ? section.ReceiveTimeout : df.ReceiveTimeout, TextEncoding = section.TextEncoding ?? df.TextEncoding, MessageEncoding = section.MessageEncoding, AllowCookies = section.AllowCookies, BypassProxyOnLocal = section.BypassProxyOnLocal, TransactionFlow = section.TransactionFlow, HostNameComparisonMode = section.HostNameComparisonMode, UseDefaultWebProxy = section.UseDefaultWebProxy, }; 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 reliableSessionSection = section.ReliableSession; var dfRss = new OptionalReliableSession(); var reliableSession = new OptionalReliableSession { Enabled = reliableSessionSection.Enabled, Ordered = reliableSessionSection.Ordered, InactivityTimeout = reliableSessionSection.InactivityTimeout != TimeSpan.Zero ? reliableSessionSection.InactivityTimeout : dfRss.InactivityTimeout, }; var messageSection = section.Security.Message; var message = new NonDualMessageSecurityOverHttp { EstablishSecurityContext = messageSection.EstablishSecurityContext, ClientCredentialType = messageSection.ClientCredentialType, NegotiateServiceCredential = messageSection.NegotiateServiceCredential, AlgorithmSuite = messageSection.AlgorithmSuite }; var transportSection = section.Security.Transport; var transport = new HttpTransportSecurity { ClientCredentialType = transportSection.ClientCredentialType, ProxyCredentialType = transportSection.ProxyCredentialType }; var wsHttpSecuritySection = section.Security; var wsHttpSecurity = new WSHttpSecurity { Mode = wsHttpSecuritySection.Mode, Transport = transport, Message = message }; ; binding.Security = wsHttpSecurity; if (readerQuotas != null) { binding.ReaderQuotas = readerQuotas; } binding.ReliableSession = reliableSession; configs.Add(binding); } return(configs); }