Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / StreamSecurityUpgradeAcceptorAsyncResult.cs / 1 / StreamSecurityUpgradeAcceptorAsyncResult.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Channels { using System.IO; using System.Security.Authentication; using System.ServiceModel.Security; using System.ServiceModel.Diagnostics; abstract class StreamSecurityUpgradeAcceptorAsyncResult : TraceAsyncResult { SecurityMessageProperty remoteSecurity; Stream upgradedStream; static AsyncCallback onAuthenticateAsServer = DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(OnAuthenticateAsServer)); protected StreamSecurityUpgradeAcceptorAsyncResult(AsyncCallback callback, object state) : base(callback, state) { } public void Begin(Stream stream) { IAsyncResult result; try { result = this.OnBegin(stream, onAuthenticateAsServer); } catch (AuthenticationException exception) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityNegotiationException(exception.Message, exception)); } catch (IOException ioException) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityNegotiationException( SR.GetString(SR.NegotiationFailedIO, ioException.Message), ioException)); } if (!result.CompletedSynchronously) { return; } CompleteAuthenticateAsServer(result); base.Complete(true); } void CompleteAuthenticateAsServer(IAsyncResult result) { try { this.upgradedStream = this.OnCompleteAuthenticateAsServer(result); } catch (AuthenticationException exception) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityNegotiationException(exception.Message, exception)); } catch (IOException ioException) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityNegotiationException( SR.GetString(SR.NegotiationFailedIO, ioException.Message), ioException)); } this.remoteSecurity = this.ValidateCreateSecurity(); } public static Stream End(IAsyncResult result, out SecurityMessageProperty remoteSecurity) { StreamSecurityUpgradeAcceptorAsyncResult thisPtr = AsyncResult.End(result); remoteSecurity = thisPtr.remoteSecurity; return thisPtr.upgradedStream; } static void OnAuthenticateAsServer(IAsyncResult result) { if (result.CompletedSynchronously) { return; } StreamSecurityUpgradeAcceptorAsyncResult acceptUpgradeAsyncResult = (StreamSecurityUpgradeAcceptorAsyncResult)result.AsyncState; Exception completionException = null; try { acceptUpgradeAsyncResult.CompleteAuthenticateAsServer(result); } #pragma warning suppress 56500 // [....], transferring exception to another thread catch (Exception e) { if (DiagnosticUtility.IsFatal(e)) { throw; } completionException = e; } acceptUpgradeAsyncResult.Complete(false, completionException); } protected abstract IAsyncResult OnBegin(Stream stream, AsyncCallback callback); protected abstract Stream OnCompleteAuthenticateAsServer(IAsyncResult result); protected abstract SecurityMessageProperty ValidateCreateSecurity(); } } // 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
- SoapExtensionStream.cs
- BoolExpr.cs
- RayHitTestParameters.cs
- SQLInt32.cs
- EndpointPerformanceCounters.cs
- HandlerWithFactory.cs
- GeneratedCodeAttribute.cs
- DrawingState.cs
- ImageListImage.cs
- PerfProviderCollection.cs
- Int64Storage.cs
- AutomationEvent.cs
- GeometryHitTestResult.cs
- CardSpaceSelector.cs
- GeneratedCodeAttribute.cs
- XPathBinder.cs
- GcHandle.cs
- TimerTable.cs
- IConvertible.cs
- XmlCompatibilityReader.cs
- WebBrowserHelper.cs
- SqlUserDefinedTypeAttribute.cs
- RadioButtonPopupAdapter.cs
- ErrorInfoXmlDocument.cs
- DataServiceHost.cs
- UIElement3D.cs
- __ConsoleStream.cs
- HttpModuleAction.cs
- BeginStoryboard.cs
- ExceptionHandlerDesigner.cs
- InkPresenter.cs
- CodeMemberEvent.cs
- Relationship.cs
- x509store.cs
- GuidConverter.cs
- XmlSchemaSimpleContentExtension.cs
- VarInfo.cs
- SiteMapDataSource.cs
- SimpleApplicationHost.cs
- RowToParametersTransformer.cs
- SplitContainer.cs
- BamlResourceContent.cs
- AndCondition.cs
- SafeFindHandle.cs
- ImageMap.cs
- CryptoConfig.cs
- dbdatarecord.cs
- SelectionItemProviderWrapper.cs
- MarkupExtensionParser.cs
- ExpanderAutomationPeer.cs
- ResourceBinder.cs
- TextTrailingCharacterEllipsis.cs
- FrameworkElementAutomationPeer.cs
- ProxyHelper.cs
- Throw.cs
- WebPageTraceListener.cs
- VBIdentifierTrimConverter.cs
- OracleColumn.cs
- DrawingAttributes.cs
- webbrowsersite.cs
- util.cs
- cookiecollection.cs
- RefreshPropertiesAttribute.cs
- ToolBarOverflowPanel.cs
- WebRequestModuleElement.cs
- OutOfProcStateClientManager.cs
- TriggerAction.cs
- PersistenceTask.cs
- SQLBytes.cs
- OrderPreservingPipeliningMergeHelper.cs
- ClientSettingsSection.cs
- MessageBodyMemberAttribute.cs
- BinaryUtilClasses.cs
- StackSpiller.Temps.cs
- BindingManagerDataErrorEventArgs.cs
- RelatedImageListAttribute.cs
- FileSystemInfo.cs
- Vector3DCollectionValueSerializer.cs
- ReceiveContext.cs
- SignedXml.cs
- ResourcePermissionBaseEntry.cs
- TabletCollection.cs
- CopyNamespacesAction.cs
- SqlDataSourceEnumerator.cs
- ComplexBindingPropertiesAttribute.cs
- MediaElementAutomationPeer.cs
- AnnouncementInnerClientCD1.cs
- BamlCollectionHolder.cs
- BaseInfoTable.cs
- DataGridColumn.cs
- CorrelationManager.cs
- FileSecurity.cs
- InputLanguageProfileNotifySink.cs
- XPathNavigatorReader.cs
- IncrementalCompileAnalyzer.cs
- XsltInput.cs
- TreeNodeSelectionProcessor.cs
- RuntimeConfig.cs
- AttachInfo.cs
- JoinSymbol.cs