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
- EventPrivateKey.cs
- DataSourceXmlAttributeAttribute.cs
- XmlArrayItemAttributes.cs
- SqlDataReaderSmi.cs
- FaultDesigner.cs
- ILGenerator.cs
- DataGridViewRowPrePaintEventArgs.cs
- DBBindings.cs
- ObjectManager.cs
- DynamicDataRoute.cs
- ListViewUpdatedEventArgs.cs
- ConsumerConnectionPoint.cs
- AbstractDataSvcMapFileLoader.cs
- DayRenderEvent.cs
- PropertyGeneratedEventArgs.cs
- OrthographicCamera.cs
- AxisAngleRotation3D.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- Binding.cs
- SourceItem.cs
- XmlILStorageConverter.cs
- SiteOfOriginPart.cs
- CapiHashAlgorithm.cs
- XamlStyleSerializer.cs
- HuffmanTree.cs
- TimeSpanStorage.cs
- LabelLiteral.cs
- Page.cs
- DecimalAnimation.cs
- OraclePermission.cs
- ScriptingJsonSerializationSection.cs
- ServiceDescriptionImporter.cs
- XmlTypeMapping.cs
- SiteMembershipCondition.cs
- TimeSpanValidatorAttribute.cs
- WebExceptionStatus.cs
- _NegotiateClient.cs
- MetadataSource.cs
- MonthChangedEventArgs.cs
- WinCategoryAttribute.cs
- AsyncPostBackTrigger.cs
- XmlBinaryReaderSession.cs
- Duration.cs
- ArcSegment.cs
- TypeBuilderInstantiation.cs
- WsatStrings.cs
- DocComment.cs
- CDSCollectionETWBCLProvider.cs
- SchemaContext.cs
- DbgUtil.cs
- Triplet.cs
- NonClientArea.cs
- GridViewEditEventArgs.cs
- SecurityChannelFactory.cs
- TableLayoutPanelCodeDomSerializer.cs
- RsaSecurityToken.cs
- IntSecurity.cs
- EventMappingSettings.cs
- RoutedEventValueSerializer.cs
- GetWinFXPath.cs
- ObjectReferenceStack.cs
- AnimationClockResource.cs
- StyleCollectionEditor.cs
- SqlConnectionManager.cs
- WebPartCloseVerb.cs
- DecimalConverter.cs
- QueryableFilterRepeater.cs
- InstanceKey.cs
- RightNameExpirationInfoPair.cs
- TextChangedEventArgs.cs
- AssociationProvider.cs
- NamespaceInfo.cs
- WebPartConnectionsCancelVerb.cs
- CompilerCollection.cs
- GridViewUpdateEventArgs.cs
- MDIControlStrip.cs
- RuntimeEnvironment.cs
- VideoDrawing.cs
- RootAction.cs
- DictionaryBase.cs
- XmlArrayItemAttribute.cs
- ListViewDeletedEventArgs.cs
- FileAuthorizationModule.cs
- OleDbPropertySetGuid.cs
- SessionEndingEventArgs.cs
- DistributedTransactionPermission.cs
- COM2IPerPropertyBrowsingHandler.cs
- _NetRes.cs
- DataGridViewCellEventArgs.cs
- ListChangedEventArgs.cs
- HttpException.cs
- SoapEnumAttribute.cs
- PrimitiveOperationFormatter.cs
- SortKey.cs
- WebPartMenuStyle.cs
- RequestCachingSection.cs
- JsonUriDataContract.cs
- X509Extension.cs
- BitmapFrameEncode.cs
- CursorInteropHelper.cs