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
- RuntimeHandles.cs
- AvTraceFormat.cs
- BitmapSource.cs
- MethodAccessException.cs
- ColumnMapCopier.cs
- Parameter.cs
- WebPart.cs
- WebPartCatalogAddVerb.cs
- RedirectionProxy.cs
- HtmlInputControl.cs
- Adorner.cs
- UnsafeNativeMethods.cs
- StrokeIntersection.cs
- Perspective.cs
- PropertyNames.cs
- SymbolEqualComparer.cs
- ObjectAnimationBase.cs
- SqlCharStream.cs
- RowUpdatingEventArgs.cs
- DocumentSequence.cs
- SqlDataSourceCache.cs
- GeometryDrawing.cs
- KeySpline.cs
- CodeIterationStatement.cs
- PageAsyncTask.cs
- PrimarySelectionGlyph.cs
- GeometryDrawing.cs
- DataControlLinkButton.cs
- SqlNotificationEventArgs.cs
- EditorZoneBase.cs
- TextElementEditingBehaviorAttribute.cs
- VirtualizedCellInfoCollection.cs
- SmiContext.cs
- UrlPath.cs
- PrintPreviewControl.cs
- ExtensionWindowResizeGrip.cs
- KoreanLunisolarCalendar.cs
- WinEventHandler.cs
- TreeViewItem.cs
- SystemKeyConverter.cs
- ObjectToIdCache.cs
- FileDataSourceCache.cs
- Int32Rect.cs
- Transactions.cs
- FileStream.cs
- RequestCacheEntry.cs
- ImageButton.cs
- TrustManagerPromptUI.cs
- CustomTrackingRecord.cs
- MsmqIntegrationMessagePool.cs
- FontNameConverter.cs
- QuotedStringWriteStateInfo.cs
- WebHttpBehavior.cs
- ColorBlend.cs
- ProtocolViolationException.cs
- SafeCertificateStore.cs
- ProcessStartInfo.cs
- ForwardPositionQuery.cs
- PopupEventArgs.cs
- SessionStateModule.cs
- AttributeEmitter.cs
- TextBoxLine.cs
- StatusBarAutomationPeer.cs
- LogSwitch.cs
- SqlFunctionAttribute.cs
- WebEncodingValidatorAttribute.cs
- XPathDocumentNavigator.cs
- ControlBindingsCollection.cs
- sqlcontext.cs
- XamlBuildProvider.cs
- SqlProviderUtilities.cs
- Fx.cs
- InstanceHandleConflictException.cs
- MemberRestriction.cs
- RoutedEventArgs.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- CreateSequence.cs
- CookielessHelper.cs
- ResourceIDHelper.cs
- WebPartDescriptionCollection.cs
- ServiceDiscoveryElement.cs
- SortedList.cs
- SpAudioStreamWrapper.cs
- HostProtectionPermission.cs
- ResourceManagerWrapper.cs
- SecureUICommand.cs
- AssemblyResourceLoader.cs
- CheckBox.cs
- ServiceOperationParameter.cs
- LinkedList.cs
- ReaderWriterLockWrapper.cs
- CategoryValueConverter.cs
- ContainerParagraph.cs
- Wildcard.cs
- LogLogRecord.cs
- EdmType.cs
- CustomError.cs
- SqlBuilder.cs
- FixUp.cs
- GregorianCalendar.cs