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
- QueryContinueDragEvent.cs
- NavigationHelper.cs
- TextRangeEditTables.cs
- LateBoundBitmapDecoder.cs
- PermissionRequestEvidence.cs
- ServiceOperation.cs
- IResourceProvider.cs
- Relationship.cs
- DescriptionAttribute.cs
- DataGridViewLayoutData.cs
- BufferedReadStream.cs
- Composition.cs
- ProgramPublisher.cs
- Expressions.cs
- ConfigurationCollectionAttribute.cs
- SamlSubjectStatement.cs
- COAUTHIDENTITY.cs
- FormViewRow.cs
- DataControlCommands.cs
- UnsafeNativeMethodsTablet.cs
- StylusButtonCollection.cs
- EntitySetDataBindingList.cs
- BinaryNegotiation.cs
- TypeConverterValueSerializer.cs
- BamlMapTable.cs
- PathSegmentCollection.cs
- Publisher.cs
- WorkItem.cs
- DataPagerFieldCommandEventArgs.cs
- PropertyNames.cs
- mediaeventargs.cs
- ActionFrame.cs
- GridEntryCollection.cs
- WorkflowMarkupElementEventArgs.cs
- DoubleLinkListEnumerator.cs
- XmlSchemaComplexType.cs
- Pkcs7Recipient.cs
- Trace.cs
- UserPreferenceChangingEventArgs.cs
- UpdateRecord.cs
- NotifyIcon.cs
- UshortList2.cs
- figurelength.cs
- CngUIPolicy.cs
- RecordsAffectedEventArgs.cs
- ToggleButtonAutomationPeer.cs
- DefaultAsyncDataDispatcher.cs
- WindowsListViewItemCheckBox.cs
- SchemaConstraints.cs
- ListItemCollection.cs
- VerificationException.cs
- ColumnWidthChangingEvent.cs
- MsmqChannelFactoryBase.cs
- MediaContextNotificationWindow.cs
- LocationInfo.cs
- XmlSerializerAssemblyAttribute.cs
- EntityDataSourceQueryBuilder.cs
- XmlReflectionImporter.cs
- DashStyle.cs
- CodeStatementCollection.cs
- AdRotator.cs
- QuaternionAnimationBase.cs
- SmtpCommands.cs
- DataGridViewCellMouseEventArgs.cs
- DateTimeParse.cs
- RadioButton.cs
- listitem.cs
- WebScriptMetadataMessageEncoderFactory.cs
- UITypeEditor.cs
- TextRunCacheImp.cs
- InputScopeNameConverter.cs
- AssociationSetMetadata.cs
- Symbol.cs
- FillErrorEventArgs.cs
- CollectionBase.cs
- TreeNodeSelectionProcessor.cs
- ByValueEqualityComparer.cs
- RecipientInfo.cs
- EntityClientCacheEntry.cs
- UIntPtr.cs
- ObjectDataSourceView.cs
- OptimizerPatterns.cs
- ValueTable.cs
- ThemeDirectoryCompiler.cs
- BitmapImage.cs
- SHA1CryptoServiceProvider.cs
- DataGridViewTextBoxEditingControl.cs
- CornerRadius.cs
- GlobalizationAssembly.cs
- ListViewGroupItemCollection.cs
- _AutoWebProxyScriptHelper.cs
- VerticalAlignConverter.cs
- Documentation.cs
- SoapHttpTransportImporter.cs
- ScrollContentPresenter.cs
- StringComparer.cs
- SymLanguageType.cs
- GenericPrincipal.cs
- PermissionListSet.cs
- cache.cs