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
- SystemEvents.cs
- KerberosRequestorSecurityTokenAuthenticator.cs
- InternalTypeHelper.cs
- SHA512.cs
- AddInSegmentDirectoryNotFoundException.cs
- ToolStripPanelCell.cs
- XmlUnspecifiedAttribute.cs
- UserPreferenceChangingEventArgs.cs
- RegistryDataKey.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- GestureRecognizer.cs
- PriorityItem.cs
- updateconfighost.cs
- EdmProperty.cs
- WindowsTokenRoleProvider.cs
- MessagingDescriptionAttribute.cs
- MonitorWrapper.cs
- TypeAccessException.cs
- xmlglyphRunInfo.cs
- EventLog.cs
- ProcessThread.cs
- ShapingEngine.cs
- ObfuscateAssemblyAttribute.cs
- ObjectTypeMapping.cs
- SecurityPolicySection.cs
- PtsCache.cs
- FrameworkReadOnlyPropertyMetadata.cs
- XPathDocumentNavigator.cs
- XmlEntityReference.cs
- SqlErrorCollection.cs
- ObjectReferenceStack.cs
- ZipQueryOperator.cs
- ScaleTransform.cs
- WriterOutput.cs
- FontStyleConverter.cs
- FileRecordSequenceCompletedAsyncResult.cs
- CompilationAssemblyInstallComponent.cs
- ReadOnlyCollection.cs
- Component.cs
- GridViewCommandEventArgs.cs
- Repeater.cs
- CodeAttributeDeclaration.cs
- CreateUserWizard.cs
- NamedElement.cs
- NativeObjectSecurity.cs
- MessageFault.cs
- DataServiceKeyAttribute.cs
- LedgerEntry.cs
- ThousandthOfEmRealPoints.cs
- XPathAxisIterator.cs
- BufferedResponseStream.cs
- ObjectFullSpanRewriter.cs
- DeclaredTypeValidator.cs
- HttpProtocolImporter.cs
- SerializationInfoEnumerator.cs
- PtsContext.cs
- SqlRowUpdatingEvent.cs
- FixedSOMGroup.cs
- StylusEditingBehavior.cs
- URLMembershipCondition.cs
- MainMenu.cs
- MaskedTextBox.cs
- HttpListenerRequest.cs
- ZipIOFileItemStream.cs
- StringAnimationBase.cs
- PrinterSettings.cs
- SqlSupersetValidator.cs
- OutputWindow.cs
- DescendantQuery.cs
- QilUnary.cs
- DbDataReader.cs
- XsltOutput.cs
- BuildProviderCollection.cs
- EventBuilder.cs
- Profiler.cs
- ArrangedElementCollection.cs
- UrlPath.cs
- ListViewItem.cs
- LinqTreeNodeEvaluator.cs
- XmlEnumAttribute.cs
- LinkLabelLinkClickedEvent.cs
- TextElementAutomationPeer.cs
- NonBatchDirectoryCompiler.cs
- GridViewColumn.cs
- TimeoutValidationAttribute.cs
- Message.cs
- XmlChoiceIdentifierAttribute.cs
- MethodImplAttribute.cs
- DesignerAdapterAttribute.cs
- StyleSheet.cs
- HttpModuleAction.cs
- BitmapEffectDrawingContent.cs
- ZoneIdentityPermission.cs
- DataTrigger.cs
- ThicknessAnimation.cs
- LowerCaseStringConverter.cs
- LateBoundBitmapDecoder.cs
- WmpBitmapDecoder.cs
- MediaCommands.cs
- FontInfo.cs