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
- PrimitiveXmlSerializers.cs
- PopOutPanel.cs
- BindingWorker.cs
- DependentList.cs
- ContentElementAutomationPeer.cs
- EventHandlers.cs
- SettingsSection.cs
- ReadOnlyAttribute.cs
- DataPointer.cs
- ExpressionVisitorHelpers.cs
- _Events.cs
- AccessKeyManager.cs
- DictionaryTraceRecord.cs
- ValueType.cs
- SurrogateDataContract.cs
- DataGridTablesFactory.cs
- JavaScriptString.cs
- HttpCookieCollection.cs
- InteropExecutor.cs
- FixedPageProcessor.cs
- Stopwatch.cs
- DebugView.cs
- XMLSyntaxException.cs
- SqlServices.cs
- ItemsChangedEventArgs.cs
- Rect3DConverter.cs
- FormsIdentity.cs
- XsltSettings.cs
- PartBasedPackageProperties.cs
- InlineUIContainer.cs
- EntityCollection.cs
- DoubleLink.cs
- Int64.cs
- DbUpdateCommandTree.cs
- FrameworkName.cs
- Rule.cs
- SystemTcpStatistics.cs
- FloaterBaseParagraph.cs
- GraphicsContainer.cs
- PrimitiveType.cs
- CodeNamespaceCollection.cs
- METAHEADER.cs
- SmiGettersStream.cs
- ProcessInputEventArgs.cs
- MetadataHelper.cs
- ActionMessageFilterTable.cs
- NullableLongMinMaxAggregationOperator.cs
- RSAOAEPKeyExchangeFormatter.cs
- ElementsClipboardData.cs
- SqlNodeAnnotations.cs
- OracleRowUpdatingEventArgs.cs
- TableDetailsCollection.cs
- UriTemplateMatch.cs
- FormsAuthenticationTicket.cs
- AndCondition.cs
- CellIdBoolean.cs
- FastEncoderWindow.cs
- TemplateControl.cs
- SocketInformation.cs
- MeshGeometry3D.cs
- CLRBindingWorker.cs
- XPathNodeList.cs
- OutputCacheSection.cs
- SmiEventSink_Default.cs
- SqlDataSourceQueryEditor.cs
- NetworkCredential.cs
- WebPartCatalogAddVerb.cs
- SqlConnectionPoolGroupProviderInfo.cs
- ContainerUtilities.cs
- ExtenderProviderService.cs
- BitmapEffectDrawingContextWalker.cs
- ExeContext.cs
- sqlpipe.cs
- DesignerActionGlyph.cs
- EFAssociationProvider.cs
- ColumnMapProcessor.cs
- RequestValidator.cs
- WorkflowElementDialog.cs
- connectionpool.cs
- ErasingStroke.cs
- OneToOneMappingSerializer.cs
- TextEditorTyping.cs
- TypeLoadException.cs
- DetailsViewDeletedEventArgs.cs
- NoResizeHandleGlyph.cs
- XmlDataSourceNodeDescriptor.cs
- AppearanceEditorPart.cs
- SchemaImporterExtensionElementCollection.cs
- ToolboxComponentsCreatingEventArgs.cs
- TagMapCollection.cs
- EdgeProfileValidation.cs
- DateBoldEvent.cs
- ScopelessEnumAttribute.cs
- SqlConnectionString.cs
- CookieParameter.cs
- ListViewAutomationPeer.cs
- FilterException.cs
- StatusBarItemAutomationPeer.cs
- Identity.cs
- PersistenceContext.cs