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
- externdll.cs
- CompiledQuery.cs
- ObjectAnimationUsingKeyFrames.cs
- Identity.cs
- HttpRequestContext.cs
- InvokeProviderWrapper.cs
- DynamicFilter.cs
- BypassElementCollection.cs
- SlotInfo.cs
- RefreshEventArgs.cs
- JulianCalendar.cs
- DeploymentSectionCache.cs
- BasePropertyDescriptor.cs
- QilInvokeLateBound.cs
- DbDataSourceEnumerator.cs
- InvokeGenerator.cs
- XmlBinaryWriter.cs
- GlobalItem.cs
- HybridDictionary.cs
- QuadraticBezierSegment.cs
- DbProviderFactories.cs
- ProcessModuleCollection.cs
- RadioButton.cs
- StatusBar.cs
- IISMapPath.cs
- AuthenticationModulesSection.cs
- SqlWebEventProvider.cs
- GraphicsState.cs
- MetaForeignKeyColumn.cs
- FeatureManager.cs
- SelectedDatesCollection.cs
- BindingExpressionBase.cs
- TabletCollection.cs
- SqlCommand.cs
- ObjectItemConventionAssemblyLoader.cs
- DataGridViewTextBoxEditingControl.cs
- PartDesigner.cs
- Binding.cs
- X509ScopedServiceCertificateElementCollection.cs
- translator.cs
- IncrementalHitTester.cs
- Timer.cs
- ResourceExpression.cs
- CompressionTransform.cs
- CodeAttachEventStatement.cs
- StrongTypingException.cs
- ClientTarget.cs
- FontFamilyValueSerializer.cs
- SimpleMailWebEventProvider.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- XmlDocument.cs
- StrokeIntersection.cs
- DataTableNewRowEvent.cs
- KoreanLunisolarCalendar.cs
- SafeNativeMethods.cs
- odbcmetadatacollectionnames.cs
- IdentitySection.cs
- SafeSecurityHelper.cs
- Trace.cs
- COM2TypeInfoProcessor.cs
- PolyBezierSegment.cs
- CodeFieldReferenceExpression.cs
- Panel.cs
- MobileControlDesigner.cs
- ProjectedSlot.cs
- UIElementHelper.cs
- PageThemeParser.cs
- SqlEnums.cs
- SamlNameIdentifierClaimResource.cs
- ToolBarButtonClickEvent.cs
- QilNode.cs
- FixedSOMImage.cs
- ItemsPresenter.cs
- DataColumnChangeEvent.cs
- TextElementEditingBehaviorAttribute.cs
- EntityTransaction.cs
- TemplateKey.cs
- PerformanceCounterManager.cs
- StatusBarPanel.cs
- XmlLanguageConverter.cs
- DelayedRegex.cs
- ConstantExpression.cs
- CodeSubDirectoriesCollection.cs
- InputMethodStateTypeInfo.cs
- FixedTextSelectionProcessor.cs
- CodeDOMProvider.cs
- RegexGroup.cs
- DocumentApplication.cs
- DependentList.cs
- XmlNamespaceMapping.cs
- MachineKeyConverter.cs
- ContextMenu.cs
- Int32AnimationBase.cs
- SoapBinding.cs
- ButtonRenderer.cs
- FontCollection.cs
- RemoteWebConfigurationHost.cs
- cache.cs
- DataPager.cs
- MatrixCamera.cs