static void VerifySecurity(MsmqTransportSecurity security, bool?useActiveDirectory) { if (security.MsmqAuthenticationMode == MsmqAuthenticationMode.WindowsDomain && !Msmq.ActiveDirectoryEnabled) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqWindowsAuthnRequiresAD))); } // MsmqAuthenticationMode.None implies MsmqProtectionLevel.None if (security.MsmqAuthenticationMode == MsmqAuthenticationMode.None && security.MsmqProtectionLevel != ProtectionLevel.None) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqAuthNoneRequiresProtectionNone))); } // MsmqAuthenticationMode.Certificate implies MsmqProtectionLevel.Sign or MsmqProtectionLevel.SignAndEncrypt if (security.MsmqAuthenticationMode == MsmqAuthenticationMode.Certificate && security.MsmqProtectionLevel == ProtectionLevel.None) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqAuthCertificateRequiresProtectionSign))); } // MsmqAuthenticationMode.WindowsDomain doesn't allow MsmqProtectionLevel.None if (security.MsmqAuthenticationMode == MsmqAuthenticationMode.WindowsDomain) { if (security.MsmqProtectionLevel == ProtectionLevel.None) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqAuthWindowsRequiresProtectionNotNone))); } } // public queues (thus: AD) needed for encryption if (security.MsmqProtectionLevel == ProtectionLevel.EncryptAndSign && useActiveDirectory.HasValue && !useActiveDirectory.Value) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MsmqEncryptRequiresUseAD))); } }
public void DefaultValues() { MsmqTransportSecurity security = new MsmqTransportSecurity(); Assert.AreEqual(MsmqAuthenticationMode.WindowsDomain, security.MsmqAuthenticationMode, "#A1"); Assert.AreEqual(MsmqEncryptionAlgorithm.RC4Stream, security.MsmqEncryptionAlgorithm, "#A2"); Assert.AreEqual(ProtectionLevel.Sign, security.MsmqProtectionLevel, "#A3"); Assert.AreEqual(MsmqSecureHashAlgorithm.Sha1, security.MsmqSecureHashAlgorithm, "#A4"); }
internal void InitializeFrom(MsmqTransportSecurity security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } this.MsmqAuthenticationMode = security.MsmqAuthenticationMode; this.MsmqEncryptionAlgorithm = security.MsmqEncryptionAlgorithm; this.MsmqProtectionLevel = security.MsmqProtectionLevel; this.MsmqSecureHashAlgorithm = security.MsmqSecureHashAlgorithm; }
internal void ApplyConfiguration(MsmqTransportSecurity security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } security.MsmqAuthenticationMode = this.MsmqAuthenticationMode; security.MsmqEncryptionAlgorithm = this.MsmqEncryptionAlgorithm; security.MsmqProtectionLevel = this.MsmqProtectionLevel; security.MsmqSecureHashAlgorithm = this.MsmqSecureHashAlgorithm; }
internal void InitializeFrom(MsmqTransportSecurity security) { if (security == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security"); } SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MsmqAuthenticationMode, security.MsmqAuthenticationMode); SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MsmqEncryptionAlgorithm, security.MsmqEncryptionAlgorithm); SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MsmqProtectionLevel, security.MsmqProtectionLevel); SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MsmqSecureHashAlgorithm, security.MsmqSecureHashAlgorithm); }
internal MsmqReceiveParameters(MsmqBindingElementBase bindingElement, MsmqUri.IAddressTranslator addressTranslator) { this.addressTranslator = addressTranslator; this.durable = bindingElement.Durable; this.exactlyOnce = bindingElement.ExactlyOnce; this.maxRetryCycles = bindingElement.MaxRetryCycles; this.receiveErrorHandling = bindingElement.ReceiveErrorHandling; this.receiveRetryCount = bindingElement.ReceiveRetryCount; this.retryCycleDelay = bindingElement.RetryCycleDelay; this.transportSecurity = new MsmqTransportSecurity(bindingElement.MsmqTransportSecurity); this.useMsmqTracing = bindingElement.UseMsmqTracing; this.useSourceJournal = bindingElement.UseSourceJournal; this.receiveContextSettings = new MsmqReceiveContextSettings(bindingElement.ReceiveContextSettings); }
internal MsmqBindingElementBase() { this.customDeadLetterQueue = MsmqDefaults.CustomDeadLetterQueue; this.deadLetterQueue = MsmqDefaults.DeadLetterQueue; this.durable = MsmqDefaults.Durable; this.exactlyOnce = MsmqDefaults.ExactlyOnce; this.maxRetryCycles = MsmqDefaults.MaxRetryCycles; this.receiveContextEnabled = MsmqDefaults.ReceiveContextEnabled; this.receiveErrorHandling = MsmqDefaults.ReceiveErrorHandling; this.receiveRetryCount = MsmqDefaults.ReceiveRetryCount; this.retryCycleDelay = MsmqDefaults.RetryCycleDelay; this.timeToLive = MsmqDefaults.TimeToLive; this.msmqTransportSecurity = new MsmqTransportSecurity(); this.useMsmqTracing = MsmqDefaults.UseMsmqTracing; this.useSourceJournal = MsmqDefaults.UseSourceJournal; this.ReceiveContextSettings = new MsmqReceiveContextSettings(); }
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> }
internal MsmqBindingElementBase(MsmqBindingElementBase elementToBeCloned) : base(elementToBeCloned) { this.customDeadLetterQueue = elementToBeCloned.customDeadLetterQueue; this.deadLetterQueue = elementToBeCloned.deadLetterQueue; this.durable = elementToBeCloned.durable; this.exactlyOnce = elementToBeCloned.exactlyOnce; this.maxRetryCycles = elementToBeCloned.maxRetryCycles; this.msmqTransportSecurity = new MsmqTransportSecurity(elementToBeCloned.MsmqTransportSecurity); this.receiveContextEnabled = elementToBeCloned.ReceiveContextEnabled; this.receiveErrorHandling = elementToBeCloned.receiveErrorHandling; this.receiveRetryCount = elementToBeCloned.receiveRetryCount; this.retryCycleDelay = elementToBeCloned.retryCycleDelay; this.timeToLive = elementToBeCloned.timeToLive; this.useMsmqTracing = elementToBeCloned.useMsmqTracing; this.useSourceJournal = elementToBeCloned.useSourceJournal; // this.ReceiveContextSettings = elementToBeCloned.ReceiveContextSettings; }
private static void VerifySecurity(MsmqTransportSecurity security, bool?useActiveDirectory) { if ((security.MsmqAuthenticationMode == MsmqAuthenticationMode.WindowsDomain) && !Msmq.ActiveDirectoryEnabled) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MsmqWindowsAuthnRequiresAD"))); } if ((security.MsmqAuthenticationMode == MsmqAuthenticationMode.None) && (security.MsmqProtectionLevel != ProtectionLevel.None)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MsmqAuthNoneRequiresProtectionNone"))); } if ((security.MsmqAuthenticationMode == MsmqAuthenticationMode.Certificate) && (security.MsmqProtectionLevel == ProtectionLevel.None)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MsmqAuthCertificateRequiresProtectionSign"))); } if ((security.MsmqAuthenticationMode == MsmqAuthenticationMode.WindowsDomain) && (security.MsmqProtectionLevel == ProtectionLevel.None)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MsmqAuthWindowsRequiresProtectionNotNone"))); } if (((security.MsmqProtectionLevel == ProtectionLevel.EncryptAndSign) && useActiveDirectory.HasValue) && !useActiveDirectory.Value) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MsmqEncryptRequiresUseAD"))); } }
protected MsmqChannelFactoryBase(MsmqBindingElementBase bindingElement, BindingContext context, MessageEncoderFactory encoderFactory) : base(bindingElement, context) { this.addressTranslator = bindingElement.AddressTranslator; this.customDeadLetterQueue = bindingElement.CustomDeadLetterQueue; this.durable = bindingElement.Durable; this.deadLetterQueue = bindingElement.DeadLetterQueue; this.exactlyOnce = bindingElement.ExactlyOnce; this.msmqTransportSecurity = new MsmqTransportSecurity(bindingElement.MsmqTransportSecurity); this.timeToLive = bindingElement.TimeToLive; this.useMsmqTracing = bindingElement.UseMsmqTracing; this.useSourceJournal = bindingElement.UseSourceJournal; if (this.MsmqTransportSecurity.MsmqAuthenticationMode == MsmqAuthenticationMode.Certificate) { InitializeSecurityTokenManager(context); } if (null != this.customDeadLetterQueue) { this.deadLetterQueuePathName = MsmqUri.DeadLetterQueueAddressTranslator.UriToFormatName(this.customDeadLetterQueue); } }
public MsmqIntegrationSecurity() { this.mode = DefaultMode; this.transportSecurity = new MsmqTransportSecurity(); }
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); }