Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / BasicHttpSecurity.cs / 1 / BasicHttpSecurity.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel { using System.ServiceModel.Channels; using System.Net.Security; using System.ServiceModel.Security; using System.ServiceModel.Configuration; using System.Diagnostics; public sealed class BasicHttpSecurity { internal const BasicHttpSecurityMode DefaultMode = BasicHttpSecurityMode.None; BasicHttpSecurityMode mode; HttpTransportSecurity transportSecurity; BasicHttpMessageSecurity messageSecurity; internal BasicHttpSecurity() : this(DefaultMode, new HttpTransportSecurity(), new BasicHttpMessageSecurity()) { } BasicHttpSecurity(BasicHttpSecurityMode mode, HttpTransportSecurity transportSecurity, BasicHttpMessageSecurity messageSecurity) { DiagnosticUtility.DebugAssert(BasicHttpSecurityModeHelper.IsDefined(mode), string.Format("Invalid BasicHttpSecurityMode value: {0}.", mode.ToString())); this.Mode = mode; this.transportSecurity = transportSecurity == null ? new HttpTransportSecurity() : transportSecurity; this.messageSecurity = messageSecurity == null ? new BasicHttpMessageSecurity() : messageSecurity; } public BasicHttpSecurityMode Mode { get { return this.mode; } set { if (!BasicHttpSecurityModeHelper.IsDefined(value)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value")); } this.mode = value; } } public HttpTransportSecurity Transport { get { return this.transportSecurity; } } public BasicHttpMessageSecurity Message { get { return this.messageSecurity; } } internal void EnableTransportSecurity(HttpsTransportBindingElement https) { if (this.mode == BasicHttpSecurityMode.TransportWithMessageCredential) { this.transportSecurity.ConfigureTransportProtectionOnly(https); } else { this.transportSecurity.ConfigureTransportProtectionAndAuthentication(https); } } internal static void EnableTransportSecurity(HttpsTransportBindingElement https, HttpTransportSecurity transportSecurity) { HttpTransportSecurity.ConfigureTransportProtectionAndAuthentication(https, transportSecurity); } internal void EnableTransportAuthentication(HttpTransportBindingElement http) { this.transportSecurity.ConfigureTransportAuthentication(http); } internal static bool IsEnabledTransportAuthentication(HttpTransportBindingElement http, HttpTransportSecurity transportSecurity) { return HttpTransportSecurity.IsConfiguredTransportAuthentication(http, transportSecurity); } internal void DisableTransportAuthentication(HttpTransportBindingElement http) { this.transportSecurity.DisableTransportAuthentication(http); } internal SecurityBindingElement CreateMessageSecurity() { if (this.mode == BasicHttpSecurityMode.Message || this.mode == BasicHttpSecurityMode.TransportWithMessageCredential) { return this.messageSecurity.CreateMessageSecurity(this.Mode == BasicHttpSecurityMode.TransportWithMessageCredential); } else { return null; } } internal static bool TryCreate(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, out BasicHttpSecurity security) { security = null; BasicHttpMessageSecurity messageSecurity = null; if (sbe != null) { mode &= UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential; bool isSecureTransportMode; if (!BasicHttpMessageSecurity.TryCreate(sbe, out messageSecurity, out isSecureTransportMode)) { return false; } } else { mode &= ~(UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential); } BasicHttpSecurityMode basicHttpSecurityMode = BasicHttpSecurityModeHelper.ToSecurityMode(mode); DiagnosticUtility.DebugAssert(BasicHttpSecurityModeHelper.IsDefined(basicHttpSecurityMode), string.Format("Invalid BasicHttpSecurityMode value: {0}.", basicHttpSecurityMode.ToString())); security = new BasicHttpSecurity(basicHttpSecurityMode, transportSecurity, messageSecurity); return SecurityElement.AreBindingsMatching(security.CreateMessageSecurity(), sbe); } } } // 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
- DesignerTransactionCloseEvent.cs
- DataGridViewRowEventArgs.cs
- SqlComparer.cs
- TextSimpleMarkerProperties.cs
- ComplexType.cs
- RequiredAttributeAttribute.cs
- TreeWalkHelper.cs
- FunctionDefinition.cs
- SafeNativeMethods.cs
- TiffBitmapDecoder.cs
- DbParameterCollection.cs
- RuntimeConfigLKG.cs
- ChannelManagerHelpers.cs
- OdbcConnectionStringbuilder.cs
- ObjectTag.cs
- ColumnResizeAdorner.cs
- VectorKeyFrameCollection.cs
- WebScriptClientGenerator.cs
- ProfilePropertySettingsCollection.cs
- NumberFormatter.cs
- UnmanagedMarshal.cs
- TextSchema.cs
- RemotingServices.cs
- ISFTagAndGuidCache.cs
- ArgumentDesigner.xaml.cs
- SharedDp.cs
- AppDomainAttributes.cs
- JoinSymbol.cs
- GenericWebPart.cs
- GeneralTransform3D.cs
- DrawListViewColumnHeaderEventArgs.cs
- BitVector32.cs
- CutCopyPasteHelper.cs
- TableLayoutColumnStyleCollection.cs
- AssemblyBuilder.cs
- HttpInputStream.cs
- SqlUDTStorage.cs
- SQlBooleanStorage.cs
- RoleServiceManager.cs
- IndexingContentUnit.cs
- XmlUrlResolver.cs
- WebPartZoneAutoFormat.cs
- InstanceKey.cs
- SelectorAutomationPeer.cs
- ExpandSegment.cs
- PaginationProgressEventArgs.cs
- PageThemeParser.cs
- TransportBindingElement.cs
- bidPrivateBase.cs
- Set.cs
- WindowInteropHelper.cs
- DatePickerAutomationPeer.cs
- ContentControl.cs
- ResourcesGenerator.cs
- DoWorkEventArgs.cs
- Point3DValueSerializer.cs
- JoinGraph.cs
- GeometryDrawing.cs
- XPathSelectionIterator.cs
- ThousandthOfEmRealDoubles.cs
- SqlGenerator.cs
- XmlAttributeAttribute.cs
- Utils.cs
- XmlSerializationGeneratedCode.cs
- InputScope.cs
- messageonlyhwndwrapper.cs
- TrackingStringDictionary.cs
- Point3DValueSerializer.cs
- CursorInteropHelper.cs
- UpdateCommand.cs
- ConfigurationManagerInternalFactory.cs
- LinearGradientBrush.cs
- BuildDependencySet.cs
- ConstructorExpr.cs
- UriTemplateQueryValue.cs
- BaseTemplateParser.cs
- EntityContainerAssociationSet.cs
- ScriptResourceMapping.cs
- PageCodeDomTreeGenerator.cs
- PermissionAttributes.cs
- StringSorter.cs
- MachineKeySection.cs
- ResourceIDHelper.cs
- QilScopedVisitor.cs
- DesignerEditorPartChrome.cs
- ImageIndexConverter.cs
- DocumentsTrace.cs
- ResourcePool.cs
- ObjectKeyFrameCollection.cs
- AppSettingsExpressionBuilder.cs
- MultiPartWriter.cs
- MenuCommands.cs
- _FtpControlStream.cs
- ToolStripGripRenderEventArgs.cs
- RuntimeCompatibilityAttribute.cs
- WebHttpBindingElement.cs
- ReflectionPermission.cs
- SingleKeyFrameCollection.cs
- EmptyEnumerator.cs
- OleDbDataReader.cs