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
- ReflectEventDescriptor.cs
- TransformationRules.cs
- TreeNodeStyleCollection.cs
- ErrorProvider.cs
- IdentityHolder.cs
- HtmlInputSubmit.cs
- PageCodeDomTreeGenerator.cs
- TraceContextRecord.cs
- SystemIPv4InterfaceProperties.cs
- ScrollContentPresenter.cs
- TransactionChannelListener.cs
- XsdDuration.cs
- ObjectAnimationBase.cs
- HttpHandlerActionCollection.cs
- PenCursorManager.cs
- DataSourceSelectArguments.cs
- SqlGatherConsumedAliases.cs
- PaperSource.cs
- DataColumnChangeEvent.cs
- LinqDataSourceHelper.cs
- XmlSchemaAny.cs
- TextAdaptor.cs
- PrinterSettings.cs
- Token.cs
- SqlConnectionHelper.cs
- ExpressionEditorAttribute.cs
- CodeTypeMemberCollection.cs
- FloaterBaseParagraph.cs
- ClickablePoint.cs
- SerializationInfoEnumerator.cs
- QuotedPrintableStream.cs
- BatchParser.cs
- XmlWriterSettings.cs
- Size.cs
- SelectQueryOperator.cs
- ChannelServices.cs
- ListViewGroupCollectionEditor.cs
- NestPullup.cs
- HttpListenerException.cs
- HttpServerVarsCollection.cs
- PageCache.cs
- Queue.cs
- GridProviderWrapper.cs
- ToolStripPanelRow.cs
- ScriptControlDescriptor.cs
- InstanceOwnerQueryResult.cs
- CompilationRelaxations.cs
- ReadContentAsBinaryHelper.cs
- DataError.cs
- TextDecorationLocationValidation.cs
- CodeBinaryOperatorExpression.cs
- SafeEventLogReadHandle.cs
- ViewCellSlot.cs
- PolicyManager.cs
- SettingsPropertyValue.cs
- BulletedList.cs
- Message.cs
- RequestCacheManager.cs
- TemplatedEditableDesignerRegion.cs
- SessionStateItemCollection.cs
- SettingsAttributes.cs
- RoleService.cs
- IntSecurity.cs
- KeyFrames.cs
- MemberListBinding.cs
- GridPatternIdentifiers.cs
- SplitterCancelEvent.cs
- LogWriteRestartAreaAsyncResult.cs
- Compiler.cs
- Process.cs
- TraceUtility.cs
- FileEnumerator.cs
- EditCommandColumn.cs
- ConfigXmlSignificantWhitespace.cs
- XmlSchemaParticle.cs
- RemotingConfiguration.cs
- OperatorExpressions.cs
- Validator.cs
- CustomErrorsSectionWrapper.cs
- OdbcDataReader.cs
- NullableIntAverageAggregationOperator.cs
- ColumnMapCopier.cs
- AtomParser.cs
- SqlBuilder.cs
- CheckBoxField.cs
- VirtualizedItemProviderWrapper.cs
- SafeEventHandle.cs
- FileInfo.cs
- WebResourceAttribute.cs
- DoubleUtil.cs
- WebBrowserHelper.cs
- WindowVisualStateTracker.cs
- XpsPackagingException.cs
- SplineKeyFrames.cs
- ListItemCollection.cs
- SmiXetterAccessMap.cs
- TemplateManager.cs
- MailMessageEventArgs.cs
- TransactionFilter.cs
- Misc.cs