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
- BuildProviderUtils.cs
- PreviewKeyDownEventArgs.cs
- EtwTrace.cs
- TableDesigner.cs
- PropertyOverridesDialog.cs
- RuntimeConfigurationRecord.cs
- MimeXmlReflector.cs
- SqlInternalConnection.cs
- infer.cs
- BindingExpressionUncommonField.cs
- WebPartConnectionsDisconnectVerb.cs
- UnsafeNativeMethodsCLR.cs
- _SslSessionsCache.cs
- GifBitmapEncoder.cs
- ObjectQueryProvider.cs
- NavigationExpr.cs
- Rights.cs
- CharacterBuffer.cs
- ConfigXmlCDataSection.cs
- TimeEnumHelper.cs
- CellConstant.cs
- SerialReceived.cs
- BindingsCollection.cs
- TextComposition.cs
- EndOfStreamException.cs
- SoapCodeExporter.cs
- ValidatingReaderNodeData.cs
- ProxyGenerationError.cs
- ServiceNameElementCollection.cs
- AnimatedTypeHelpers.cs
- StringExpressionSet.cs
- FunctionDefinition.cs
- GlobalizationSection.cs
- Border.cs
- EnvelopedPkcs7.cs
- DesignerAttribute.cs
- CursorConverter.cs
- AutomationTextAttribute.cs
- ExpandableObjectConverter.cs
- PropertyIDSet.cs
- RecognizedWordUnit.cs
- FontDriver.cs
- Visual3D.cs
- MessageQueueKey.cs
- BypassElement.cs
- TimelineGroup.cs
- BitmapEffectCollection.cs
- WriteStateInfoBase.cs
- WindowClosedEventArgs.cs
- UnmanagedBitmapWrapper.cs
- Stacktrace.cs
- EntryWrittenEventArgs.cs
- Popup.cs
- dsa.cs
- SecurityPolicySection.cs
- WebPartConnectionsCancelEventArgs.cs
- Color.cs
- StringBuilder.cs
- DatatypeImplementation.cs
- TrackBarRenderer.cs
- RetrieveVirtualItemEventArgs.cs
- GenericWebPart.cs
- _ListenerResponseStream.cs
- HtmlTableCell.cs
- ArrangedElementCollection.cs
- WebPartConnectionsCancelVerb.cs
- BCLDebug.cs
- _Connection.cs
- Ipv6Element.cs
- SemanticTag.cs
- SlipBehavior.cs
- Compiler.cs
- RIPEMD160Managed.cs
- PathFigure.cs
- PassportAuthenticationModule.cs
- DoubleLinkList.cs
- ArraySet.cs
- ListMarkerSourceInfo.cs
- IgnoreFileBuildProvider.cs
- WsatTransactionFormatter.cs
- WebBrowserProgressChangedEventHandler.cs
- NetMsmqBindingElement.cs
- WebPartEditorCancelVerb.cs
- Soap.cs
- MailAddressCollection.cs
- ColorMap.cs
- DragEventArgs.cs
- ConfigurationValue.cs
- SamlAuthenticationClaimResource.cs
- ComAdminInterfaces.cs
- DataGridViewCellStyleChangedEventArgs.cs
- lengthconverter.cs
- OutputCacheSection.cs
- SoapObjectWriter.cs
- DispatcherHookEventArgs.cs
- DataGridViewRowCollection.cs
- ProgramPublisher.cs
- LambdaCompiler.Lambda.cs
- CallbackValidator.cs
- AppSecurityManager.cs