internal void InitializeFrom(MessageSecurityOverMsmq security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } this.ClientCredentialType = security.ClientCredentialType; if (security.WasAlgorithmSuiteSet) { this.AlgorithmSuite = security.AlgorithmSuite; } }
internal void ApplyConfiguration(MessageSecurityOverMsmq security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } security.ClientCredentialType = this.ClientCredentialType; if (base.ElementInformation.Properties["algorithmSuite"].ValueOrigin != PropertyValueOrigin.Default) { security.AlgorithmSuite = this.AlgorithmSuite; } }
internal void InitializeFrom(MessageSecurityOverMsmq security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ClientCredentialType, security.ClientCredentialType); if (security.WasAlgorithmSuiteSet) { this.AlgorithmSuite = security.AlgorithmSuite; } }
static void Main(string[] args) { // <Snippet1> NetMsmqBinding binding = new NetMsmqBinding(); NetMsmqSecurity security = binding.Security; MessageSecurityOverMsmq msOverMsmq = security.Message; // </Snippet1> // <Snippet2> msOverMsmq.AlgorithmSuite = SecurityAlgorithmSuite.Basic128; // </Snippet2> // <Snippet3> msOverMsmq.ClientCredentialType = MessageCredentialType.Certificate; // </Snippet3> }
static void Main(string[] args) { // <Snippet1> NetMsmqBinding binding = new NetMsmqBinding(); NetMsmqSecurity security = binding.Security; // </Snippet1> // <Snippet2> MessageSecurityOverMsmq msgSecurity = security.Message; // </Snippet2> // <Snippet3> NetMsmqSecurityMode secMode = security.Mode; // </Snippet3> // <Snippet4> MsmqTransportSecurity trnsSecurity = security.Transport; // </Snippet4> }
public static List <NetMsmqBinding> GetNetMsmqBindings(string exeConfigPath) { if (string.IsNullOrWhiteSpace(exeConfigPath)) { return(null); } var svcSection = Read.Config.ExeConfig.GetServiceModelSection(exeConfigPath); var configs = new List <NetMsmqBinding>(); foreach ( var section in svcSection.Bindings.NetMsmqBinding.ConfiguredBindings .Cast <NetMsmqBindingElement>()) { var df = new NetMsmqBinding(); var binding = new NetMsmqBinding { 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, MaxRetryCycles = section.MaxRetryCycles > 0 ? section.MaxRetryCycles : df.MaxRetryCycles, ReceiveRetryCount = section.ReceiveRetryCount > 0 ? section.ReceiveRetryCount : df.ReceiveRetryCount, RetryCycleDelay = section.RetryCycleDelay != TimeSpan.Zero ? section.RetryCycleDelay : df.RetryCycleDelay, TimeToLive = section.TimeToLive != TimeSpan.Zero ? section.TimeToLive : df.TimeToLive, DeadLetterQueue = section.DeadLetterQueue, Durable = section.Durable, ExactlyOnce = section.ExactlyOnce, ReceiveErrorHandling = section.ReceiveErrorHandling, UseSourceJournal = section.UseSourceJournal, UseMsmqTracing = section.UseMsmqTracing, QueueTransferProtocol = section.QueueTransferProtocol, UseActiveDirectory = section.UseActiveDirectory }; 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 msmqSecurity = new NetMsmqSecurity { Mode = section.Security.Mode }; var securityTransportSection = section.Security.Transport; var msmqSecurityTransport = new MsmqTransportSecurity { MsmqAuthenticationMode = securityTransportSection.MsmqAuthenticationMode, MsmqEncryptionAlgorithm = securityTransportSection.MsmqEncryptionAlgorithm, MsmqProtectionLevel = securityTransportSection.MsmqProtectionLevel, MsmqSecureHashAlgorithm = securityTransportSection.MsmqSecureHashAlgorithm }; var msmqSecurityMessage = new MessageSecurityOverMsmq { ClientCredentialType = section.Security.Message.ClientCredentialType }; msmqSecurity.Message = msmqSecurityMessage; msmqSecurity.Transport = msmqSecurityTransport; binding.Security = msmqSecurity; if (readerQuotas != null) { binding.ReaderQuotas = readerQuotas; } configs.Add(binding); } return(configs); }