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
- WebPartConnectionsEventArgs.cs
- BaseTreeIterator.cs
- BulletedList.cs
- DrawingAttributes.cs
- SoapClientProtocol.cs
- RuntimeConfigurationRecord.cs
- ClientSponsor.cs
- DataTemplateSelector.cs
- DataRowCollection.cs
- FilteredDataSetHelper.cs
- HyperLinkStyle.cs
- MembershipPasswordException.cs
- FrugalList.cs
- MulticastDelegate.cs
- AdornedElementPlaceholder.cs
- QuaternionValueSerializer.cs
- Preprocessor.cs
- RenderOptions.cs
- ModuleBuilderData.cs
- DbConnectionClosed.cs
- InstalledVoice.cs
- SessionPageStateSection.cs
- configsystem.cs
- MLangCodePageEncoding.cs
- GenericQueueSurrogate.cs
- SortExpressionBuilder.cs
- GatewayDefinition.cs
- UserPreferenceChangingEventArgs.cs
- LinqDataSourceContextData.cs
- DiagnosticTraceSource.cs
- DBDataPermissionAttribute.cs
- MessageDroppedTraceRecord.cs
- DesignerActionTextItem.cs
- AutomationElement.cs
- TreeWalker.cs
- XmlTextReaderImplHelpers.cs
- TextDecoration.cs
- ObjectDataSourceEventArgs.cs
- XmlException.cs
- OrderedDictionaryStateHelper.cs
- AudioDeviceOut.cs
- propertytag.cs
- ClientScriptItem.cs
- EntitySqlQueryCacheEntry.cs
- CalendarDateChangedEventArgs.cs
- CompilationUnit.cs
- TextTreeText.cs
- DeferredElementTreeState.cs
- Track.cs
- WebPartConnectionsCancelVerb.cs
- XPathNodeIterator.cs
- GeometryGroup.cs
- MessageQueue.cs
- ListManagerBindingsCollection.cs
- PartialTrustHelpers.cs
- TextSimpleMarkerProperties.cs
- MailWebEventProvider.cs
- ReadOnlyCollection.cs
- _DomainName.cs
- PagerSettings.cs
- HuffmanTree.cs
- ParseChildrenAsPropertiesAttribute.cs
- PtsHelper.cs
- Helpers.cs
- XmlBindingWorker.cs
- PrintPreviewControl.cs
- smtppermission.cs
- Visual3D.cs
- ExceptionTranslationTable.cs
- TemporaryBitmapFile.cs
- UInt32Converter.cs
- PermissionSetTriple.cs
- LinkTarget.cs
- FilterElement.cs
- OLEDB_Enum.cs
- Validator.cs
- SessionState.cs
- EngineSite.cs
- ReflectTypeDescriptionProvider.cs
- TypeInfo.cs
- Drawing.cs
- GridViewCommandEventArgs.cs
- CalendarTable.cs
- X509InitiatorCertificateServiceElement.cs
- ConditionedDesigner.cs
- _ContextAwareResult.cs
- DrawingBrush.cs
- XmlSchemaComplexContent.cs
- ForwardPositionQuery.cs
- DetailsViewPageEventArgs.cs
- DocumentOrderQuery.cs
- PointCollectionValueSerializer.cs
- CodeSnippetExpression.cs
- HtmlElementErrorEventArgs.cs
- ThreadSafeMessageFilterTable.cs
- Visitors.cs
- SmiSettersStream.cs
- BindUriHelper.cs
- TrackingStringDictionary.cs
- SafeRightsManagementQueryHandle.cs