Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / TransactionBridge / Microsoft / Transactions / Wsat / Messaging / SupportingTokenChannel.cs / 1 / SupportingTokenChannel.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- // Defines the SupportingTokenChannel, with the only interesting code in these parts using System; using System.Diagnostics; using System.ServiceModel; using System.ServiceModel.Description; using System.ServiceModel.Channels; using System.ServiceModel.Security; using Microsoft.Transactions.Wsat.Protocol; namespace Microsoft.Transactions.Wsat.Messaging { abstract class SupportingTokenChannel: ChannelBase where TChannel : IChannel { SupportingTokenSecurityTokenResolver tokenResolver; protected TChannel innerChannel; static SecurityStandardsManager securityStandardsManager; ProtocolVersion protocolVersion; static SecurityStandardsManager SecurityStandardsManager { get { if (securityStandardsManager == null) { securityStandardsManager = new SecurityStandardsManager(MessageSecurityVersion.Default, WSSecurityTokenSerializer.DefaultInstance); } return securityStandardsManager; } } public SupportingTokenChannel(ChannelManagerBase manager, TChannel innerChannel, SupportingTokenSecurityTokenResolver tokenResolver, ProtocolVersion protocolVersion) : base(manager) { this.innerChannel = innerChannel; this.tokenResolver = tokenResolver; this.protocolVersion = protocolVersion; } protected override void OnAbort() { this.innerChannel.Abort(); } protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { return this.innerChannel.BeginClose(timeout, callback, state); } protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state) { return this.innerChannel.BeginOpen(timeout, callback, state); } protected override void OnClose(TimeSpan timeout) { this.innerChannel.Close(timeout); } protected override void OnEndClose(IAsyncResult result) { this.innerChannel.EndClose(result); } protected override void OnEndOpen(IAsyncResult result) { this.innerChannel.EndOpen(result); } protected override void OnOpen(TimeSpan timeout) { this.innerChannel.Open(timeout); } protected void OnReceive(Message message) { DebugTrace.TraceEnter(this, "OnReceive"); // This is the big payoff for all this SupportingToken* work if (message != null && !this.tokenResolver.FaultInSupportingToken(message)) { if (DebugTrace.Verbose) DebugTrace.Trace(TraceLevel.Verbose, "Failed to fault in SCT for supporting token signature"); // Send a fault Fault fault = Faults.Version(this.protocolVersion).InvalidParameters; if (message.Headers.MessageId != null) { if (DebugTrace.Verbose) DebugTrace.Trace(TraceLevel.Verbose, "Attempting to send {0} fault", fault.Code.Name); Message faultMessage = Library.CreateFaultMessage(message.Headers.MessageId, message.Version, fault); // Note that we already have a RelatesTo on the message, so there's no need // to call RequestReplyCorrelator.PrepareReply RequestReplyCorrelator.AddressReply(faultMessage, new RequestReplyCorrelator.ReplyToInfo(message)); SendSecurityHeader securityHeader = SecurityStandardsManager.CreateSendSecurityHeader( faultMessage, string.Empty, true, false, SecurityAlgorithmSuite.Default, MessageDirection.Output); securityHeader.RequireMessageProtection = false; securityHeader.AddTimestamp(SecurityProtocolFactory.defaultTimestampValidityDuration); faultMessage = securityHeader.SetupExecution(); TrySendFaultReply(faultMessage); } // Reject the message throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new CommunicationException(SR.GetString(SR.SupportingTokenSignatureExpected))); } DebugTrace.TraceLeave(this, "OnReceive"); } public override T GetProperty () { return this.innerChannel.GetProperty (); } protected abstract void TrySendFaultReply(Message faultMessage); } } // 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
- WindowsListViewGroup.cs
- CqlGenerator.cs
- GeneralTransform2DTo3D.cs
- DateTimeValueSerializer.cs
- InvalidComObjectException.cs
- DrawingCollection.cs
- BuildManagerHost.cs
- FixedHighlight.cs
- HoistedLocals.cs
- DataGridViewRowsAddedEventArgs.cs
- DesignSurfaceEvent.cs
- StylusSystemGestureEventArgs.cs
- TraceLevelStore.cs
- Keywords.cs
- Privilege.cs
- IItemContainerGenerator.cs
- PeerContact.cs
- EmbeddedMailObjectCollectionEditor.cs
- ContentFilePart.cs
- SqlClientFactory.cs
- Selection.cs
- SupportingTokenAuthenticatorSpecification.cs
- SingleTagSectionHandler.cs
- SqlDataReaderSmi.cs
- SendingRequestEventArgs.cs
- InstanceKeyCompleteException.cs
- SecurityCriticalDataForSet.cs
- EncodingFallbackAwareXmlTextWriter.cs
- CustomAttributeSerializer.cs
- AssociativeAggregationOperator.cs
- CurrentChangingEventArgs.cs
- FamilyTypefaceCollection.cs
- SessionStateItemCollection.cs
- InvalidPrinterException.cs
- ProtocolViolationException.cs
- SQLDateTime.cs
- Registry.cs
- GenericWebPart.cs
- RSAPKCS1SignatureFormatter.cs
- CleanUpVirtualizedItemEventArgs.cs
- _ListenerRequestStream.cs
- InternalDuplexChannelFactory.cs
- Classification.cs
- LifetimeServices.cs
- LoginName.cs
- UInt32Converter.cs
- DataTable.cs
- BindStream.cs
- PersonalizationStateQuery.cs
- XmlArrayItemAttributes.cs
- WorkflowTransactionService.cs
- InkCanvasSelectionAdorner.cs
- QuadraticBezierSegment.cs
- HttpFileCollection.cs
- WsatTransactionInfo.cs
- ChannelManager.cs
- CompleteWizardStep.cs
- DefaultSection.cs
- HttpHandler.cs
- AutomationProperties.cs
- EntityWrapper.cs
- MutexSecurity.cs
- KnownTypesProvider.cs
- UserPersonalizationStateInfo.cs
- ProfileGroupSettingsCollection.cs
- CellTreeNodeVisitors.cs
- EntityTransaction.cs
- BaseComponentEditor.cs
- Utility.cs
- VideoDrawing.cs
- TagNameToTypeMapper.cs
- ClosableStream.cs
- PointCollectionConverter.cs
- HttpCookiesSection.cs
- FactoryGenerator.cs
- PropertyChangedEventArgs.cs
- Expr.cs
- SqlLiftIndependentRowExpressions.cs
- _SslState.cs
- CqlLexerHelpers.cs
- Part.cs
- SqlRowUpdatedEvent.cs
- XNameTypeConverter.cs
- GeometryHitTestParameters.cs
- RuntimeWrappedException.cs
- DoubleAnimationBase.cs
- WebPartConnectionsCancelVerb.cs
- PngBitmapDecoder.cs
- xmlglyphRunInfo.cs
- TextReader.cs
- WebPartCancelEventArgs.cs
- IncrementalReadDecoders.cs
- SystemWebCachingSectionGroup.cs
- XhtmlBasicCalendarAdapter.cs
- EntityTransaction.cs
- DescendantOverDescendantQuery.cs
- compensatingcollection.cs
- Span.cs
- ContextBase.cs
- GridViewSelectEventArgs.cs