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
- TemplateBaseAction.cs
- Tuple.cs
- XmlHelper.cs
- PersonalizationProviderCollection.cs
- TextElement.cs
- MemberHolder.cs
- FixedPage.cs
- PartitionResolver.cs
- MailDefinition.cs
- SymDocumentType.cs
- DataServiceProcessingPipeline.cs
- DictionaryManager.cs
- FacetValueContainer.cs
- InstanceContextManager.cs
- safePerfProviderHandle.cs
- DeviceContext.cs
- RouteCollection.cs
- SmiContext.cs
- CodeVariableDeclarationStatement.cs
- TimeSpan.cs
- BrowserCapabilitiesCodeGenerator.cs
- ImageField.cs
- SerializationTrace.cs
- EmptyElement.cs
- PrivilegedConfigurationManager.cs
- NetCodeGroup.cs
- UrlMapping.cs
- BitSet.cs
- listitem.cs
- Boolean.cs
- MergablePropertyAttribute.cs
- DataFormat.cs
- DispatcherExceptionFilterEventArgs.cs
- DependencyPropertyValueSerializer.cs
- MailSettingsSection.cs
- TabControlAutomationPeer.cs
- PrintDialog.cs
- ForeignKeyFactory.cs
- TraceListener.cs
- sqlpipe.cs
- DataSet.cs
- ThrowOnMultipleAssignment.cs
- RequiredArgumentAttribute.cs
- WindowsComboBox.cs
- CodeDOMUtility.cs
- _UriTypeConverter.cs
- DoubleLinkList.cs
- TypeGeneratedEventArgs.cs
- ToolboxItemLoader.cs
- KeyProperty.cs
- RangeValidator.cs
- SqlEnums.cs
- InputReport.cs
- RuntimeCompatibilityAttribute.cs
- SqlConnection.cs
- PostBackOptions.cs
- WebMessageFormatHelper.cs
- GenericIdentity.cs
- NumberSubstitution.cs
- EventLogSession.cs
- RuntimeComponentFilter.cs
- InvalidOperationException.cs
- TextEvent.cs
- AttributeEmitter.cs
- BlurEffect.cs
- SymLanguageType.cs
- SiteMapNodeItemEventArgs.cs
- SiteMapDesignerDataSourceView.cs
- SubtreeProcessor.cs
- AttachInfo.cs
- SamlAudienceRestrictionCondition.cs
- SafeLibraryHandle.cs
- EnvelopedSignatureTransform.cs
- ListViewItem.cs
- SessionStateSection.cs
- HttpWebResponse.cs
- Knowncolors.cs
- GlyphRunDrawing.cs
- CodeChecksumPragma.cs
- SizeAnimation.cs
- Tokenizer.cs
- HtmlInputImage.cs
- AuthorizationContext.cs
- CodeBlockBuilder.cs
- ProfilePropertyNameValidator.cs
- DescendentsWalker.cs
- DataBinder.cs
- AppSettingsReader.cs
- Win32SafeHandles.cs
- Int32CollectionConverter.cs
- MultipleViewProviderWrapper.cs
- FixedTextBuilder.cs
- VirtualPathProvider.cs
- AssemblyCollection.cs
- DataControlField.cs
- StrongTypingException.cs
- MetabaseServerConfig.cs
- ZoneMembershipCondition.cs
- GiveFeedbackEvent.cs
- StatusStrip.cs