Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / StreamSecurityUpgradeAcceptorAsyncResult.cs / 1 / StreamSecurityUpgradeAcceptorAsyncResult.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Channels { using System.IO; using System.Security.Authentication; using System.ServiceModel.Security; using System.ServiceModel.Diagnostics; abstract class StreamSecurityUpgradeAcceptorAsyncResult : TraceAsyncResult { SecurityMessageProperty remoteSecurity; Stream upgradedStream; static AsyncCallback onAuthenticateAsServer = DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(OnAuthenticateAsServer)); protected StreamSecurityUpgradeAcceptorAsyncResult(AsyncCallback callback, object state) : base(callback, state) { } public void Begin(Stream stream) { IAsyncResult result; try { result = this.OnBegin(stream, onAuthenticateAsServer); } 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; } CompleteAuthenticateAsServer(result); base.Complete(true); } void CompleteAuthenticateAsServer(IAsyncResult result) { try { this.upgradedStream = this.OnCompleteAuthenticateAsServer(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) { StreamSecurityUpgradeAcceptorAsyncResult thisPtr = AsyncResult.End(result); remoteSecurity = thisPtr.remoteSecurity; return thisPtr.upgradedStream; } static void OnAuthenticateAsServer(IAsyncResult result) { if (result.CompletedSynchronously) { return; } StreamSecurityUpgradeAcceptorAsyncResult acceptUpgradeAsyncResult = (StreamSecurityUpgradeAcceptorAsyncResult)result.AsyncState; Exception completionException = null; try { acceptUpgradeAsyncResult.CompleteAuthenticateAsServer(result); } #pragma warning suppress 56500 // [....], transferring exception to another thread catch (Exception e) { if (DiagnosticUtility.IsFatal(e)) { throw; } completionException = e; } acceptUpgradeAsyncResult.Complete(false, completionException); } protected abstract IAsyncResult OnBegin(Stream stream, AsyncCallback callback); protected abstract Stream OnCompleteAuthenticateAsServer(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
- ProcessingInstructionAction.cs
- MsmqHostedTransportManager.cs
- LoginUtil.cs
- Publisher.cs
- ScriptControl.cs
- DataFieldEditor.cs
- DispatcherTimer.cs
- GridItemPatternIdentifiers.cs
- MessageDesigner.cs
- EdmProperty.cs
- WebPartPersonalization.cs
- Viewport2DVisual3D.cs
- HttpApplicationFactory.cs
- Keywords.cs
- PageHandlerFactory.cs
- FontStyles.cs
- PointKeyFrameCollection.cs
- DropDownButton.cs
- CodePrimitiveExpression.cs
- CompressionTransform.cs
- ChangePassword.cs
- EntityClassGenerator.cs
- RenderContext.cs
- ResourceType.cs
- TaiwanLunisolarCalendar.cs
- OverlappedAsyncResult.cs
- WindowsHyperlink.cs
- DashStyle.cs
- DecimalMinMaxAggregationOperator.cs
- MimeWriter.cs
- DispatcherProcessingDisabled.cs
- ScriptBehaviorDescriptor.cs
- MethodBuilder.cs
- FileInfo.cs
- TextEditorTyping.cs
- SmiEventSink_Default.cs
- CommonGetThemePartSize.cs
- XmlSchemaSequence.cs
- XmlDataImplementation.cs
- Knowncolors.cs
- DataReaderContainer.cs
- DependencyObjectType.cs
- TextEffect.cs
- SignatureToken.cs
- Geometry.cs
- MSAAWinEventWrap.cs
- CompositeCollection.cs
- _Connection.cs
- PostBackTrigger.cs
- WebPartActionVerb.cs
- KeyedCollection.cs
- ProcessHost.cs
- BindableTemplateBuilder.cs
- CheckedListBox.cs
- AutomationElementCollection.cs
- QuaternionAnimationUsingKeyFrames.cs
- PropVariant.cs
- RSACryptoServiceProvider.cs
- CmsInterop.cs
- QueryComponents.cs
- CodeTypeMember.cs
- IsolatedStorage.cs
- PropertyPath.cs
- TemplatedWizardStep.cs
- ResourceProviderFactory.cs
- ClientTargetSection.cs
- PublisherMembershipCondition.cs
- TrackPoint.cs
- DependencyPropertyAttribute.cs
- PassportIdentity.cs
- manifestimages.cs
- BamlLocalizer.cs
- DataServiceKeyAttribute.cs
- UIElement.cs
- ScriptingJsonSerializationSection.cs
- NativeCppClassAttribute.cs
- AutoScrollHelper.cs
- storepermission.cs
- RecordManager.cs
- TemplateApplicationHelper.cs
- OletxResourceManager.cs
- SaveFileDialog.cs
- peernodestatemanager.cs
- EntityDataSourceConfigureObjectContextPanel.cs
- HTMLTextWriter.cs
- SerializationException.cs
- Stroke2.cs
- ParentQuery.cs
- ItemContainerGenerator.cs
- ServiceOperationViewControl.cs
- XslUrlEditor.cs
- ProcessThread.cs
- PageAdapter.cs
- XmlSchemaSimpleType.cs
- ViewValidator.cs
- MeshGeometry3D.cs
- DataRelationPropertyDescriptor.cs
- ThousandthOfEmRealDoubles.cs
- PrincipalPermissionMode.cs
- SoapAttributeAttribute.cs