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
- ManualResetEvent.cs
- Assert.cs
- CodeDirectiveCollection.cs
- ReceiveActivity.cs
- DesignerDataSourceView.cs
- UriParserTemplates.cs
- FieldInfo.cs
- Highlights.cs
- DynamicMetaObjectBinder.cs
- ConnectionsZoneAutoFormat.cs
- XPathDescendantIterator.cs
- HttpRuntime.cs
- UrlMapping.cs
- ToolStripLocationCancelEventArgs.cs
- BitmapDownload.cs
- mediaeventshelper.cs
- PasswordDeriveBytes.cs
- SmiTypedGetterSetter.cs
- TabPage.cs
- xmlglyphRunInfo.cs
- BaseAppDomainProtocolHandler.cs
- ExecutorLocksHeldException.cs
- SqlBuilder.cs
- TextCollapsingProperties.cs
- ReadOnlyDictionary.cs
- IImplicitResourceProvider.cs
- XmlIgnoreAttribute.cs
- ImageIndexConverter.cs
- SqlDataSource.cs
- DbDeleteCommandTree.cs
- DispatchWrapper.cs
- DrawListViewSubItemEventArgs.cs
- VirtualDirectoryMapping.cs
- ValueOfAction.cs
- NativeMethods.cs
- AppDomainAttributes.cs
- OleDbEnumerator.cs
- HeaderPanel.cs
- FormsAuthenticationUserCollection.cs
- DataGridViewTextBoxEditingControl.cs
- Model3D.cs
- CompModSwitches.cs
- RuntimeHandles.cs
- MetabaseReader.cs
- ByteConverter.cs
- InkCanvasFeedbackAdorner.cs
- MetafileEditor.cs
- Bits.cs
- CodeArrayCreateExpression.cs
- PropertyInfoSet.cs
- RadioButtonStandardAdapter.cs
- SqlTopReducer.cs
- FromRequest.cs
- RepeatButtonAutomationPeer.cs
- StateManagedCollection.cs
- CheckBoxField.cs
- MemberProjectedSlot.cs
- InitializationEventAttribute.cs
- NullRuntimeConfig.cs
- CheckedListBox.cs
- versioninfo.cs
- TypeConstant.cs
- ToolStripMenuItem.cs
- JavaScriptString.cs
- TextBoxBase.cs
- PnrpPermission.cs
- ColumnPropertiesGroup.cs
- ItemCheckEvent.cs
- PrimarySelectionGlyph.cs
- ConnectionManagementElementCollection.cs
- ZipIOExtraFieldZip64Element.cs
- SectionInformation.cs
- ComponentTray.cs
- ObjectQuery_EntitySqlExtensions.cs
- Base64Encoder.cs
- FlowDocumentPageViewerAutomationPeer.cs
- XappLauncher.cs
- ProxyAttribute.cs
- oledbconnectionstring.cs
- TrackingMemoryStream.cs
- PropertyItemInternal.cs
- RepeaterCommandEventArgs.cs
- GridProviderWrapper.cs
- ThicknessConverter.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- QuestionEventArgs.cs
- WorkflowNamespace.cs
- SQLUtility.cs
- HtmlTableCell.cs
- SectionUpdates.cs
- DesignerActionList.cs
- Metadata.cs
- ResXResourceWriter.cs
- GridViewHeaderRowPresenter.cs
- DependencyPropertyKind.cs
- BitmapEffectDrawing.cs
- FileStream.cs
- InkCanvasFeedbackAdorner.cs
- GrammarBuilderBase.cs
- TextDecoration.cs