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
- PostBackTrigger.cs
- Separator.cs
- ISO2022Encoding.cs
- Binding.cs
- LambdaCompiler.Binary.cs
- DiagnosticsConfigurationHandler.cs
- TransformCollection.cs
- SortedSet.cs
- DBPropSet.cs
- AccessedThroughPropertyAttribute.cs
- ConfigurationLoader.cs
- XmlWrappingReader.cs
- ServiceProviders.cs
- ParallelTimeline.cs
- SecurityAlgorithmSuite.cs
- CounterCreationDataCollection.cs
- CommandDevice.cs
- PrinterUnitConvert.cs
- Rect.cs
- TraceShell.cs
- SweepDirectionValidation.cs
- DataReaderContainer.cs
- RuntimeHelpers.cs
- GraphicsContainer.cs
- KnownTypeHelper.cs
- TriggerAction.cs
- Variant.cs
- GridViewCommandEventArgs.cs
- GridViewSortEventArgs.cs
- SecurityState.cs
- DataColumnCollection.cs
- DetailsViewModeEventArgs.cs
- NodeInfo.cs
- HtmlTextBoxAdapter.cs
- Adorner.cs
- NativeMethods.cs
- TriggerActionCollection.cs
- mediapermission.cs
- BindUriHelper.cs
- Configuration.cs
- EventMap.cs
- MeshGeometry3D.cs
- TextSpanModifier.cs
- DesignTimeParseData.cs
- UpdateCompiler.cs
- CompiledXpathExpr.cs
- NavigationPropertyAccessor.cs
- FilterFactory.cs
- DispatcherProcessingDisabled.cs
- unsafenativemethodstextservices.cs
- _ContextAwareResult.cs
- DBBindings.cs
- FunctionParameter.cs
- UnicastIPAddressInformationCollection.cs
- ConversionValidationRule.cs
- IdentitySection.cs
- RegistryDataKey.cs
- RepeaterItemEventArgs.cs
- DataBoundLiteralControl.cs
- ConfigXmlReader.cs
- DocumentPage.cs
- Transactions.cs
- Boolean.cs
- XmlSerializationReader.cs
- QilName.cs
- WaitHandle.cs
- PublisherMembershipCondition.cs
- ToolStripCustomTypeDescriptor.cs
- LoadGrammarCompletedEventArgs.cs
- srgsitem.cs
- XmlSchemaSearchPattern.cs
- CodeParameterDeclarationExpression.cs
- List.cs
- DrawingGroup.cs
- _AutoWebProxyScriptEngine.cs
- XmlQueryOutput.cs
- FontSource.cs
- CacheOutputQuery.cs
- PartBasedPackageProperties.cs
- HMAC.cs
- WindowsListViewScroll.cs
- AccessDataSourceView.cs
- UnionCodeGroup.cs
- ParameterCollection.cs
- UnsafeNativeMethods.cs
- DropTarget.cs
- CapabilitiesSection.cs
- TextReader.cs
- TabControlAutomationPeer.cs
- XmlReaderSettings.cs
- FontStretchConverter.cs
- FileRecordSequence.cs
- MatrixAnimationUsingKeyFrames.cs
- PresentationSource.cs
- StrongNameMembershipCondition.cs
- AdornerLayer.cs
- NumericUpDownAccelerationCollection.cs
- LoginView.cs
- StrongName.cs
- SubtreeProcessor.cs