Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / StreamSecurityUpgradeInitiatorAsyncResult.cs / 1 / StreamSecurityUpgradeInitiatorAsyncResult.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Channels { using System.IO; using System.Security.Authentication; using System.ServiceModel.Security; abstract class StreamSecurityUpgradeInitiatorAsyncResult : AsyncResult { Stream originalStream; SecurityMessageProperty remoteSecurity; Stream upgradedStream; static AsyncCallback onAuthenticateAsClient = DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(OnAuthenticateAsClient)); public StreamSecurityUpgradeInitiatorAsyncResult(AsyncCallback callback, object state) : base(callback, state) { // empty } public void Begin(Stream stream) { this.originalStream = stream; IAsyncResult result; try { result = this.OnBeginAuthenticateAsClient(this.originalStream, onAuthenticateAsClient); } 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; } CompleteAuthenticateAsClient(result); base.Complete(true); } void CompleteAuthenticateAsClient(IAsyncResult result) { try { this.upgradedStream = this.OnCompleteAuthenticateAsClient(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) { StreamSecurityUpgradeInitiatorAsyncResult thisPtr = AsyncResult.End(result); remoteSecurity = thisPtr.remoteSecurity; return thisPtr.upgradedStream; } static void OnAuthenticateAsClient(IAsyncResult result) { if (result.CompletedSynchronously) { return; } StreamSecurityUpgradeInitiatorAsyncResult thisPtr = (StreamSecurityUpgradeInitiatorAsyncResult)result.AsyncState; Exception completionException = null; try { thisPtr.CompleteAuthenticateAsClient(result); } #pragma warning suppress 56500 // [....], transferring exception to another thread catch (Exception e) { if (DiagnosticUtility.IsFatal(e)) { throw; } completionException = e; } thisPtr.Complete(false, completionException); } protected abstract IAsyncResult OnBeginAuthenticateAsClient(Stream stream, AsyncCallback callback); protected abstract Stream OnCompleteAuthenticateAsClient(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
- MoveSizeWinEventHandler.cs
- LineInfo.cs
- MouseBinding.cs
- Config.cs
- DataRow.cs
- SessionStateUtil.cs
- ToolStripGripRenderEventArgs.cs
- XmlEncodedRawTextWriter.cs
- KoreanCalendar.cs
- WebMessageBodyStyleHelper.cs
- Set.cs
- ToolStripContainerDesigner.cs
- ExpressionVisitorHelpers.cs
- Converter.cs
- activationcontext.cs
- EncoderFallback.cs
- CollectionChangedEventManager.cs
- DbCommandTree.cs
- GroupBoxAutomationPeer.cs
- SessionState.cs
- SelectManyQueryOperator.cs
- SimpleMailWebEventProvider.cs
- PageAdapter.cs
- DrawTreeNodeEventArgs.cs
- PtsContext.cs
- LinkClickEvent.cs
- Mutex.cs
- TextEditorSpelling.cs
- ContentFilePart.cs
- TextEmbeddedObject.cs
- TypeDescriptionProvider.cs
- HttpValueCollection.cs
- RoutingExtension.cs
- Volatile.cs
- MeshGeometry3D.cs
- Ref.cs
- TargetParameterCountException.cs
- BitmapDownload.cs
- GridViewHeaderRowPresenter.cs
- TreeNode.cs
- SmtpClient.cs
- HtmlTableRowCollection.cs
- PersonalizationStateQuery.cs
- Base64Stream.cs
- DataError.cs
- CustomAttributeFormatException.cs
- FindCompletedEventArgs.cs
- ManipulationBoundaryFeedbackEventArgs.cs
- Component.cs
- ProtocolImporter.cs
- XmlWriter.cs
- EntityWrapper.cs
- Translator.cs
- CompositeCollection.cs
- VectorAnimation.cs
- ChangePassword.cs
- MailSettingsSection.cs
- CustomLineCap.cs
- ContentPosition.cs
- SqlStream.cs
- PropertySegmentSerializer.cs
- GenericQueueSurrogate.cs
- Base64Decoder.cs
- MessageHeaderException.cs
- SystemIcmpV4Statistics.cs
- CqlParser.cs
- ExecutionProperties.cs
- PolyLineSegment.cs
- BinHexDecoder.cs
- HttpStreamFormatter.cs
- RelationshipDetailsRow.cs
- CodeSubDirectory.cs
- HttpCacheVaryByContentEncodings.cs
- AQNBuilder.cs
- ConfigurationManager.cs
- EncoderFallback.cs
- OdbcConnectionOpen.cs
- NameValueConfigurationCollection.cs
- PanelStyle.cs
- HtmlValidationSummaryAdapter.cs
- SourceItem.cs
- DataGridViewColumnHeaderCell.cs
- SecurityToken.cs
- EntityStoreSchemaGenerator.cs
- SizeAnimationClockResource.cs
- SoapExtension.cs
- CommandDesigner.cs
- Array.cs
- RequestedSignatureDialog.cs
- ServiceDiscoveryElement.cs
- CookieParameter.cs
- TextElementAutomationPeer.cs
- EventListener.cs
- DeviceContext2.cs
- GotoExpression.cs
- ObjectManager.cs
- ChooseAction.cs
- Compilation.cs
- DataGridColumnHeaderAutomationPeer.cs
- ApplicationInterop.cs