Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / WSHttpSecurity.cs / 1 / WSHttpSecurity.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel { using System.Diagnostics; using System.Net.Security; using System.ServiceModel.Channels; using System.ServiceModel.Security; public sealed class WSHttpSecurity { internal const SecurityMode DefaultMode = SecurityMode.Message; SecurityMode mode; HttpTransportSecurity transportSecurity; NonDualMessageSecurityOverHttp messageSecurity; internal WSHttpSecurity() : this(DefaultMode, GetDefaultHttpTransportSecurity(), new NonDualMessageSecurityOverHttp()) { } internal WSHttpSecurity(SecurityMode mode, HttpTransportSecurity transportSecurity, NonDualMessageSecurityOverHttp messageSecurity) { this.mode = mode; this.transportSecurity = transportSecurity == null ? GetDefaultHttpTransportSecurity() : transportSecurity; this.messageSecurity = messageSecurity == null ? new NonDualMessageSecurityOverHttp() : messageSecurity; } internal static HttpTransportSecurity GetDefaultHttpTransportSecurity() { HttpTransportSecurity transportSecurity = new HttpTransportSecurity(); transportSecurity.ClientCredentialType = HttpClientCredentialType.Windows; return transportSecurity; } public SecurityMode Mode { get { return this.mode; } set { if (!SecurityModeHelper.IsDefined(value)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value")); } this.mode = value; } } public HttpTransportSecurity Transport { get { return this.transportSecurity; } } public NonDualMessageSecurityOverHttp Message { get { return this.messageSecurity; } } internal void ApplyTransportSecurity(HttpsTransportBindingElement https) { if (this.mode == SecurityMode.TransportWithMessageCredential) { this.transportSecurity.ConfigureTransportProtectionOnly(https); } else { this.transportSecurity.ConfigureTransportProtectionAndAuthentication(https); } } internal static void ApplyTransportSecurity(HttpsTransportBindingElement transport, HttpTransportSecurity transportSecurity) { HttpTransportSecurity.ConfigureTransportProtectionAndAuthentication(transport, transportSecurity); } internal SecurityBindingElement CreateMessageSecurity(bool isReliableSessionEnabled, MessageSecurityVersion version) { if (this.mode == SecurityMode.Message || this.mode == SecurityMode.TransportWithMessageCredential) { return this.messageSecurity.CreateSecurityBindingElement(this.Mode == SecurityMode.TransportWithMessageCredential, isReliableSessionEnabled, version); } else { return null; } } internal static bool TryCreate(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, bool isReliableSessionEnabled, out WSHttpSecurity security) { security = null; NonDualMessageSecurityOverHttp messageSecurity = null; SecurityMode securityMode = SecurityMode.None; if (sbe != null) { mode &= UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential; securityMode = SecurityModeHelper.ToSecurityMode(mode); DiagnosticUtility.DebugAssert(SecurityModeHelper.IsDefined(securityMode), string.Format("Invalid SecurityMode value: {0}.", mode.ToString())); if (!MessageSecurityOverHttp.TryCreate(sbe, securityMode == SecurityMode.TransportWithMessageCredential, isReliableSessionEnabled, out messageSecurity)) { return false; } } else { mode &= ~(UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential); securityMode = SecurityModeHelper.ToSecurityMode(mode); } DiagnosticUtility.DebugAssert(SecurityModeHelper.IsDefined(securityMode), string.Format("Invalid SecurityMode value: {0}.", securityMode.ToString())); security = new WSHttpSecurity(securityMode, transportSecurity, messageSecurity); return true; } } } // 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
- TableCellAutomationPeer.cs
- Internal.cs
- WeakEventTable.cs
- ArgumentDirectionHelper.cs
- WindowsToolbar.cs
- XmlSchemaSet.cs
- Walker.cs
- CodeGenerator.cs
- StylusPointProperties.cs
- EntityDataSourceMemberPath.cs
- CodeAttributeDeclarationCollection.cs
- BaseParser.cs
- NodeLabelEditEvent.cs
- IIS7WorkerRequest.cs
- AppDomainFactory.cs
- _AutoWebProxyScriptEngine.cs
- HtmlInputRadioButton.cs
- TextLineBreak.cs
- Transaction.cs
- ManualWorkflowSchedulerService.cs
- RequestCacheValidator.cs
- KeyGestureConverter.cs
- FileFormatException.cs
- ValidatedControlConverter.cs
- TransactionTraceIdentifier.cs
- InstancePersistenceException.cs
- ReaderWriterLock.cs
- PerspectiveCamera.cs
- HideDisabledControlAdapter.cs
- BufferManager.cs
- UDPClient.cs
- lengthconverter.cs
- RequestCachePolicy.cs
- EditBehavior.cs
- AttributedMetaModel.cs
- TableItemPatternIdentifiers.cs
- DateTimeFormatInfo.cs
- HttpListenerTimeoutManager.cs
- SiteMap.cs
- TwoPhaseCommit.cs
- ItemsControlAutomationPeer.cs
- ZoomPercentageConverter.cs
- PackagePartCollection.cs
- WebScriptClientGenerator.cs
- OdbcException.cs
- EntityModelSchemaGenerator.cs
- TextElementAutomationPeer.cs
- MultiPageTextView.cs
- Sql8ConformanceChecker.cs
- FtpRequestCacheValidator.cs
- WinFormsUtils.cs
- ListSortDescriptionCollection.cs
- RoutedUICommand.cs
- BaseProcessor.cs
- GeometryDrawing.cs
- AutomationPeer.cs
- WinFormsUtils.cs
- XmlBindingWorker.cs
- DoubleKeyFrameCollection.cs
- CallbackHandler.cs
- MultiSelector.cs
- HorizontalAlignConverter.cs
- UnsafeNativeMethods.cs
- ToolZone.cs
- ThreadNeutralSemaphore.cs
- EnterpriseServicesHelper.cs
- mansign.cs
- TrackingDataItemValue.cs
- XmlUTF8TextReader.cs
- KeyToListMap.cs
- PeerApplication.cs
- TreeNodeCollection.cs
- HttpRuntimeSection.cs
- WebMessageEncodingElement.cs
- XmlMembersMapping.cs
- SspiHelper.cs
- formatter.cs
- ZipIOFileItemStream.cs
- CatalogPartCollection.cs
- DataGridViewComboBoxColumnDesigner.cs
- figurelengthconverter.cs
- SecureConversationSecurityTokenParameters.cs
- WinEventQueueItem.cs
- Mappings.cs
- OptimisticConcurrencyException.cs
- DependencyProperty.cs
- HttpStreamMessage.cs
- DashStyles.cs
- ConnectionStringSettingsCollection.cs
- CookielessHelper.cs
- SerialErrors.cs
- Geometry3D.cs
- ActivityExecutor.cs
- NameTable.cs
- mediaeventargs.cs
- Touch.cs
- CodeParameterDeclarationExpression.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- ServiceControllerDesigner.cs
- AppDomainAttributes.cs