Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / TransactionBridge / Microsoft / Transactions / Wsat / Messaging / Binding.cs / 1 / Binding.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- // Define the bindings used for WS-Coor / WS-AT / .NET-AT port types using System; using System.Collections.Generic; using System.Net; using System.Net.Security; using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Security; using System.Text; using Microsoft.Transactions.Wsat.Protocol; using Microsoft.Transactions.Bridge; namespace Microsoft.Transactions.Wsat.Messaging { abstract class CoordinationBinding : Binding { ProtocolVersion protocolVersion; // Calling CreateFault on an incoming message can expose some DoS-related security // vulnerabilities when a service is in streaming mode. See MB 47592 for more details. // The WS-AT protocol service does not use streaming mode on any of its bindings, so the // message we have in hand has already passed the binding�s MaxReceivedMessageSize check. // int.MaxValue may be a safe value, but it will require a formal review. internal const int MaxFaultSize = (int)TransportDefaults.MaxReceivedMessageSize; protected CoordinationBinding(string name, string ns, ProtocolVersion protocolVersion) : base(name, ns) { this.protocolVersion = protocolVersion; } public override string Scheme { get { return Uri.UriSchemeHttps; } } protected void AddTransactionFlowBindingElement(BindingElementCollection bindingElements) { // The TransactionFlowBindingElement is only used for IssuedTokens and IssuedTokens // require a TransactionProtocol in order to function correctly... TransactionProtocol protocol = (protocolVersion == ProtocolVersion.Version10) ? TransactionProtocol.WSAtomicTransactionOctober2004 : TransactionProtocol.WSAtomicTransaction11; TransactionFlowBindingElement txFlowBE = new TransactionFlowBindingElement(protocol); txFlowBE.Transactions = false; txFlowBE.IssuedTokens = TransactionFlowOption.Allowed; bindingElements.Add(txFlowBE); } protected void AddTransportSecurityBindingElement(BindingElementCollection bindingElements) { TransportSecurityBindingElement transportSecurity = new TransportSecurityBindingElement(); transportSecurity.MessageSecurityVersion = MessagingVersionHelper.SecurityVersion(this.protocolVersion); bindingElements.Add(transportSecurity); } protected void AddTextEncodingBindingElement(BindingElementCollection bindingElements) { TextMessageEncodingBindingElement encoding = new TextMessageEncodingBindingElement(); encoding.WriteEncoding = Encoding.UTF8; encoding.MessageVersion = MessagingVersionHelper.MessageVersion(this.protocolVersion); bindingElements.Add(encoding); } protected void AddCompositeDuplexBindingElement(BindingElementCollection bindingElements, Uri clientBaseAddress) { bindingElements.Add(new DuplexCorrelationBindingElement()); InternalDuplexBindingElement internalBE = new InternalDuplexBindingElement(true); bindingElements.Add(internalBE); CompositeDuplexBindingElement duplexBE = new CompositeDuplexBindingElement(); duplexBE.ClientBaseAddress = clientBaseAddress; bindingElements.Add(duplexBE); } protected void AddOneWayBindingElement(BindingElementCollection bindingElements) { bindingElements.Add(new OneWayBindingElement()); } protected void AddInteropHttpsTransportBindingElement(BindingElementCollection bindingElements) { HttpsTransportBindingElement httpsBE = new HttpsTransportBindingElement(); httpsBE.RequireClientCertificate = true; httpsBE.UseDefaultWebProxy = false; bindingElements.Add(httpsBE); } protected void AddNamedPipeBindingElement(BindingElementCollection bindingElements) { NamedPipeTransportBindingElement pipeTransportBE = new NamedPipeTransportBindingElement(); // See MB 32913 for details on how these numbers were chosen pipeTransportBE.MaxPendingConnections = 50; pipeTransportBE.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint = 25; pipeTransportBE.MaxPendingAccepts = 25; bindingElements.Add(pipeTransportBE); } protected void AddWindowsStreamSecurityBindingElement(BindingElementCollection bindingElements) { WindowsStreamSecurityBindingElement windowsSecurityBE = new WindowsStreamSecurityBindingElement(); windowsSecurityBE.ProtectionLevel = ProtectionLevel.EncryptAndSign; bindingElements.Add(windowsSecurityBE); } public override BindingElementCollection CreateBindingElements() { BindingElementCollection bindingElements = new BindingElementCollection(); AddBindingElements(bindingElements); return bindingElements; } protected abstract void AddBindingElements(BindingElementCollection bindingElements); // class DuplexCorrelationBindingElement : BindingElement { public override BindingElement Clone() { return this; } public override T GetProperty(BindingContext context) { if (typeof(T) == typeof(ISecurityCapabilities)) { ISecurityCapabilities lowerCapabilities = context.GetInnerProperty (); if (lowerCapabilities != null) { // this binding can do server auth even over composite duplex return (T)(object)(new SecurityCapabilities(lowerCapabilities.SupportsClientAuthentication, true, lowerCapabilities.SupportsClientWindowsIdentity, lowerCapabilities.SupportedRequestProtectionLevel, lowerCapabilities.SupportedRequestProtectionLevel)); } else { return null; } } else { return context.GetInnerProperty (); } } } } class InteropRequestReplyBinding : CoordinationBinding { Uri clientBaseAddress; public InteropRequestReplyBinding(Uri clientBaseAddress, ProtocolVersion protocolVersion) : base(BindingStrings.InteropBindingName, AtomicTransactionStrings.Version(protocolVersion).Namespace, protocolVersion) { this.clientBaseAddress = clientBaseAddress; } protected override void AddBindingElements(BindingElementCollection bindingElements) { AddCompositeDuplexBindingElement(bindingElements, this.clientBaseAddress); AddOneWayBindingElement(bindingElements); AddTextEncodingBindingElement(bindingElements); AddInteropHttpsTransportBindingElement(bindingElements); } } class InteropRegistrationBinding : InteropRequestReplyBinding { SupportingTokenBindingElement supportingTokenBE; public InteropRegistrationBinding(Uri clientBaseAddress, bool acceptSupportingTokens, ProtocolVersion protocolVersion) : base(clientBaseAddress, protocolVersion) { if (acceptSupportingTokens) { this.supportingTokenBE = new SupportingTokenBindingElement(protocolVersion); } } public SupportingTokenBindingElement SupportingTokenBindingElement { get { return this.supportingTokenBE; } } protected override void AddBindingElements(BindingElementCollection bindingElements) { if (this.supportingTokenBE != null) { AddTransportSecurityBindingElement(bindingElements); bindingElements.Add(this.supportingTokenBE); } base.AddBindingElements(bindingElements); } } class InteropActivationBinding: InteropRequestReplyBinding { public InteropActivationBinding(Uri clientBaseAddress, ProtocolVersion protocolVersion) : base(clientBaseAddress, protocolVersion) { } protected override void AddBindingElements(BindingElementCollection bindingElements) { AddTransactionFlowBindingElement(bindingElements); base.AddBindingElements(bindingElements); } } class InteropDatagramBinding : CoordinationBinding { public InteropDatagramBinding(ProtocolVersion protocolVersion) : base(BindingStrings.InteropBindingName, AtomicTransactionStrings.Version(protocolVersion).Namespace, protocolVersion) { } protected override void AddBindingElements(BindingElementCollection bindingElements) { AddTextEncodingBindingElement(bindingElements); AddInteropHttpsTransportBindingElement(bindingElements); } } class NamedPipeBinding : CoordinationBinding { public NamedPipeBinding(ProtocolVersion protocolVersion) : base(BindingStrings.NamedPipeBindingName, DotNetAtomicTransactionExternalStrings.Namespace, protocolVersion) { } public override string Scheme { get { return Uri.UriSchemeNetPipe; } } protected override void AddBindingElements(BindingElementCollection bindingElements) { bindingElements.Add(new BinaryMessageEncodingBindingElement()); AddTransactionFlowBindingElement(bindingElements); AddWindowsStreamSecurityBindingElement(bindingElements); AddNamedPipeBindingElement(bindingElements); } } class WindowsRequestReplyBinding : CoordinationBinding { public WindowsRequestReplyBinding(ProtocolVersion protocolVersion) : base(BindingStrings.WindowsBindingName, DotNetAtomicTransactionExternalStrings.Namespace, protocolVersion) { } void AddWindowsHttpsTransportBindingElement(BindingElementCollection bindingElements) { HttpsTransportBindingElement httpsBE = new HttpsTransportBindingElement(); httpsBE.RequireClientCertificate = false; httpsBE.UseDefaultWebProxy = false; httpsBE.AuthenticationScheme = AuthenticationSchemes.Negotiate; bindingElements.Add(httpsBE); } protected override void AddBindingElements(BindingElementCollection bindingElements) { AddTransactionFlowBindingElement(bindingElements); AddTextEncodingBindingElement(bindingElements); AddWindowsHttpsTransportBindingElement(bindingElements); } } } // 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
- AutomationFocusChangedEventArgs.cs
- PrintDialog.cs
- MetadataException.cs
- MailBnfHelper.cs
- CodeLabeledStatement.cs
- TypeUtil.cs
- XmlSchemaComplexContentRestriction.cs
- ProviderSettings.cs
- XPathItem.cs
- Missing.cs
- InvalidAsynchronousStateException.cs
- SelectionPatternIdentifiers.cs
- DeferrableContent.cs
- SinglePageViewer.cs
- CompiledQuery.cs
- ExtractedStateEntry.cs
- PointLightBase.cs
- ClassImporter.cs
- MethodInfo.cs
- AutomationElement.cs
- SchemeSettingElementCollection.cs
- InstanceCompleteException.cs
- AnnotationAuthorChangedEventArgs.cs
- RightsManagementUser.cs
- BlurBitmapEffect.cs
- InvokeGenerator.cs
- RootBrowserWindow.cs
- RoamingStoreFileUtility.cs
- IpcManager.cs
- RequestResizeEvent.cs
- SimpleBitVector32.cs
- CellCreator.cs
- FunctionImportMapping.cs
- GraphicsContext.cs
- DataFieldConverter.cs
- XmlILOptimizerVisitor.cs
- ComponentResourceKey.cs
- Array.cs
- TextServicesCompartmentEventSink.cs
- DataGridViewCheckBoxColumn.cs
- BinaryConverter.cs
- XmlSerializerNamespaces.cs
- _HTTPDateParse.cs
- XmlSchemaSimpleContentRestriction.cs
- Point4DValueSerializer.cs
- GetPageCompletedEventArgs.cs
- MethodToken.cs
- GeometryModel3D.cs
- TransformerTypeCollection.cs
- DiscoveryClientProtocol.cs
- NavigationPropertyEmitter.cs
- InvalidPrinterException.cs
- DbReferenceCollection.cs
- Column.cs
- CacheDependency.cs
- IItemProperties.cs
- XComponentModel.cs
- NullableBoolConverter.cs
- XappLauncher.cs
- Math.cs
- BinaryParser.cs
- WindowsGraphicsWrapper.cs
- HostedTransportConfigurationManager.cs
- _NetworkingPerfCounters.cs
- SafeNativeMethods.cs
- ReachUIElementCollectionSerializer.cs
- SmtpException.cs
- COM2IPerPropertyBrowsingHandler.cs
- ButtonChrome.cs
- documentsequencetextcontainer.cs
- GlyphCollection.cs
- DataGridViewButtonColumn.cs
- OperationCanceledException.cs
- HashSet.cs
- FontNamesConverter.cs
- BitStack.cs
- AttributeExtensions.cs
- XmlChildEnumerator.cs
- DataPager.cs
- ImportFileRequest.cs
- Ipv6Element.cs
- SelectedGridItemChangedEvent.cs
- TypeElement.cs
- Margins.cs
- DataReaderContainer.cs
- KernelTypeValidation.cs
- InternalCache.cs
- ProcessRequestArgs.cs
- DataRelation.cs
- METAHEADER.cs
- HtmlShimManager.cs
- DesignerUtility.cs
- Tracking.cs
- HuffmanTree.cs
- RuntimeTransactionHandle.cs
- AuthenticationManager.cs
- DataGridViewBand.cs
- VirtualPathUtility.cs
- RichTextBoxContextMenu.cs
- ColorInterpolationModeValidation.cs