Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / NetMsmqSecurity.cs / 1 / NetMsmqSecurity.cs
//---------------------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------------------- namespace System.ServiceModel { using System.Diagnostics; using System.Net.Security; using System.ServiceModel.Channels; using Config = System.ServiceModel.Configuration; public sealed class NetMsmqSecurity { internal const NetMsmqSecurityMode DefaultMode = NetMsmqSecurityMode.Transport; NetMsmqSecurityMode mode; MsmqTransportSecurity transportSecurity; MessageSecurityOverMsmq messageSecurity; internal NetMsmqSecurity() : this(DefaultMode, null, null) { } internal NetMsmqSecurity(NetMsmqSecurityMode mode) : this(mode, null, null) { } NetMsmqSecurity(NetMsmqSecurityMode mode, MsmqTransportSecurity transportSecurity, MessageSecurityOverMsmq messageSecurity) { DiagnosticUtility.DebugAssert(NetMsmqSecurityModeHelper.IsDefined(mode), string.Format("Invalid NetMsmqSecurityMode value: {0}.", mode.ToString())); this.mode = mode; this.transportSecurity = transportSecurity == null ? new MsmqTransportSecurity() : transportSecurity; this.messageSecurity = messageSecurity == null ? new MessageSecurityOverMsmq() : messageSecurity; } public NetMsmqSecurityMode Mode { get { return this.mode; } set { if (!NetMsmqSecurityModeHelper.IsDefined(value)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value")); } this.mode = value; } } public MsmqTransportSecurity Transport { get { if (this.transportSecurity == null) this.transportSecurity = new MsmqTransportSecurity(); return this.transportSecurity; } } public MessageSecurityOverMsmq Message { get { if (this.messageSecurity == null) this.messageSecurity = new MessageSecurityOverMsmq(); return this.messageSecurity; } } internal void ConfigureTransportSecurity(MsmqBindingElementBase msmq) { if (this.mode == NetMsmqSecurityMode.Transport || this.mode == NetMsmqSecurityMode.Both) msmq.MsmqTransportSecurity = this.Transport; else msmq.MsmqTransportSecurity.Disable(); } internal static bool IsConfiguredTransportSecurity(MsmqTransportBindingElement msmq, out UnifiedSecurityMode mode) { if (msmq == null) { mode = UnifiedSecurityMode.None; return false; } if (msmq.MsmqTransportSecurity.Enabled) { mode = UnifiedSecurityMode.Transport | UnifiedSecurityMode.Both; } else { mode = UnifiedSecurityMode.None | UnifiedSecurityMode.Message; } return true; } internal SecurityBindingElement CreateMessageSecurity() { return this.Message.CreateSecurityBindingElement(); } // internal static bool TryCreate(SecurityBindingElement sbe, NetMsmqSecurityMode mode, out NetMsmqSecurity security) { security = null; MessageSecurityOverMsmq messageSecurity; if (!MessageSecurityOverMsmq.TryCreate(sbe, out messageSecurity)) messageSecurity = null; security = new NetMsmqSecurity(mode, null, messageSecurity); return sbe == null || Config.SecurityElement.AreBindingsMatching(security.CreateMessageSecurity(), sbe, false); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Metafile.cs
- ManualResetEvent.cs
- _KerberosClient.cs
- Attribute.cs
- BamlMapTable.cs
- ReferenceEqualityComparer.cs
- AutomationPropertyInfo.cs
- UInt32Storage.cs
- Vector3DCollectionConverter.cs
- Wizard.cs
- TransformValueSerializer.cs
- SqlNodeAnnotation.cs
- TextTabProperties.cs
- CodeAssignStatement.cs
- CompilerCollection.cs
- MenuItemAutomationPeer.cs
- CounterSampleCalculator.cs
- ComponentChangedEvent.cs
- PlaceHolder.cs
- CodeDelegateInvokeExpression.cs
- XmlSerializerNamespaces.cs
- AgileSafeNativeMemoryHandle.cs
- ConstraintConverter.cs
- IConvertible.cs
- _ShellExpression.cs
- WebEvents.cs
- InfoCardSymmetricAlgorithm.cs
- Vector3DCollectionValueSerializer.cs
- DocumentApplication.cs
- WebPageTraceListener.cs
- DependencyObjectType.cs
- DiscoveryClientDocuments.cs
- WinOEToolBoxItem.cs
- HttpWebRequestElement.cs
- RubberbandSelector.cs
- WorkflowFileItem.cs
- SoapInteropTypes.cs
- TypefaceCollection.cs
- AssemblyInfo.cs
- Condition.cs
- SBCSCodePageEncoding.cs
- SelectedCellsCollection.cs
- HwndMouseInputProvider.cs
- RawTextInputReport.cs
- NaturalLanguageHyphenator.cs
- SQLRoleProvider.cs
- VerificationAttribute.cs
- MissingManifestResourceException.cs
- AsyncOperation.cs
- EmptyEnumerable.cs
- XmlQualifiedName.cs
- ManagementException.cs
- ProviderConnectionPoint.cs
- PropertyValue.cs
- InputProcessorProfiles.cs
- BatchServiceHost.cs
- precedingquery.cs
- IconBitmapDecoder.cs
- PasswordRecoveryDesigner.cs
- XamlSerializationHelper.cs
- EventProviderWriter.cs
- PagesSection.cs
- ResourceManagerWrapper.cs
- SslStreamSecurityElement.cs
- SqlXml.cs
- BufferedStream.cs
- ExpandedProjectionNode.cs
- DataContext.cs
- DependencyObjectPropertyDescriptor.cs
- ChooseAction.cs
- DescendantQuery.cs
- RunWorkerCompletedEventArgs.cs
- Vector3DConverter.cs
- HttpRequestTraceRecord.cs
- ReflectionUtil.cs
- Matrix3D.cs
- TextEditorTables.cs
- X509Certificate2.cs
- HttpCookieCollection.cs
- ToolStripItemCollection.cs
- RadioButtonList.cs
- RangeValueProviderWrapper.cs
- CommandField.cs
- Identity.cs
- UnaryExpressionHelper.cs
- EndpointReference.cs
- WsdlInspector.cs
- NavigationFailedEventArgs.cs
- RC2CryptoServiceProvider.cs
- EventEntry.cs
- DbConnectionPool.cs
- X509CertificateEndpointIdentity.cs
- TableFieldsEditor.cs
- Random.cs
- RepeaterItemCollection.cs
- SRef.cs
- SendActivityDesignerTheme.cs
- ControlCachePolicy.cs
- SBCSCodePageEncoding.cs
- ContentIterators.cs