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
- AsyncDataRequest.cs
- DataGridState.cs
- AxDesigner.cs
- ClientSettingsSection.cs
- DataBindingExpressionBuilder.cs
- PerspectiveCamera.cs
- AsyncCodeActivity.cs
- ListCollectionView.cs
- UnmanagedMemoryStream.cs
- NullToBooleanConverter.cs
- ModuleBuilder.cs
- ListViewUpdatedEventArgs.cs
- Pair.cs
- GridItemProviderWrapper.cs
- MenuItemBindingCollection.cs
- RegisteredDisposeScript.cs
- ColumnMapCopier.cs
- XmlSchemaComplexContentExtension.cs
- RightsManagementProvider.cs
- PropertyGroupDescription.cs
- ScriptReferenceEventArgs.cs
- FloatSumAggregationOperator.cs
- PageStatePersister.cs
- EnumerableRowCollectionExtensions.cs
- PropertyChangedEventManager.cs
- ReceiveSecurityHeaderElementManager.cs
- XmlSerializerAssemblyAttribute.cs
- ConfigurationManagerHelperFactory.cs
- RowToParametersTransformer.cs
- PathFigure.cs
- DelimitedListTraceListener.cs
- RenderData.cs
- BamlReader.cs
- AppDomainAttributes.cs
- OneOfConst.cs
- SecurityContextSecurityTokenResolver.cs
- SqlGenerator.cs
- AssemblyCache.cs
- VirtualDirectoryMappingCollection.cs
- UpDownBaseDesigner.cs
- BlockExpression.cs
- WebPartConnectionCollection.cs
- ConfigXmlText.cs
- BasicKeyConstraint.cs
- RuleSettings.cs
- PersonalizationState.cs
- BoolExpression.cs
- AuthenticationModuleElementCollection.cs
- TerminatingOperationBehavior.cs
- PathNode.cs
- HttpContextWrapper.cs
- X509CertificateCollection.cs
- DateTimeUtil.cs
- GACMembershipCondition.cs
- PrintPreviewDialog.cs
- EpmContentDeSerializerBase.cs
- CompiledELinqQueryState.cs
- CellQuery.cs
- PointAnimationUsingKeyFrames.cs
- DataControlFieldsEditor.cs
- PenLineJoinValidation.cs
- EmulateRecognizeCompletedEventArgs.cs
- Transform3D.cs
- DesignerActionVerbItem.cs
- Shared.cs
- FieldReference.cs
- LinqDataSourceUpdateEventArgs.cs
- CompiledQuery.cs
- ExtensionElementCollection.cs
- XmlSerializationGeneratedCode.cs
- TrustLevel.cs
- PointCollection.cs
- DataControlField.cs
- OracleConnection.cs
- PixelFormatConverter.cs
- ToolStripSettings.cs
- LZCodec.cs
- VerticalAlignConverter.cs
- BamlTreeMap.cs
- BlockUIContainer.cs
- SpAudioStreamWrapper.cs
- TableLayoutStyle.cs
- Thickness.cs
- BinarySerializer.cs
- ThreadAbortException.cs
- FamilyTypeface.cs
- SplineKeyFrames.cs
- SpeechRecognizer.cs
- EdmEntityTypeAttribute.cs
- DbMetaDataFactory.cs
- IntegrationExceptionEventArgs.cs
- DisplayToken.cs
- WebBrowserNavigatedEventHandler.cs
- WsatRegistrationHeader.cs
- TemplatingOptionsDialog.cs
- Number.cs
- DoubleCollectionConverter.cs
- ComPlusServiceLoader.cs
- SqlProfileProvider.cs
- RSAOAEPKeyExchangeFormatter.cs