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
- RoleServiceManager.cs
- ResourceAttributes.cs
- OleDbException.cs
- RIPEMD160.cs
- ProgramNode.cs
- Variable.cs
- Normalization.cs
- DrawingAttributes.cs
- DataObjectMethodAttribute.cs
- SchemaImporter.cs
- _Win32.cs
- ObjectNavigationPropertyMapping.cs
- EditorPart.cs
- TextRunTypographyProperties.cs
- SpecialNameAttribute.cs
- BaseCAMarshaler.cs
- DataRelation.cs
- XmlSchemaNotation.cs
- Types.cs
- CreatingCookieEventArgs.cs
- OleDbConnectionInternal.cs
- SqlUdtInfo.cs
- DataGridViewCell.cs
- SerialPinChanges.cs
- XmlAutoDetectWriter.cs
- Point3DAnimationUsingKeyFrames.cs
- PermissionAttributes.cs
- DataTableExtensions.cs
- ThicknessAnimationBase.cs
- ProfileManager.cs
- CodeObject.cs
- RichTextBoxConstants.cs
- ReferentialConstraint.cs
- ImageEditor.cs
- TextTreeUndoUnit.cs
- pingexception.cs
- regiisutil.cs
- DateTimeUtil.cs
- TextLineResult.cs
- ObjectItemConventionAssemblyLoader.cs
- Marshal.cs
- GeneralTransform3DTo2DTo3D.cs
- TemporaryBitmapFile.cs
- SecurityAppliedMessage.cs
- RecipientInfo.cs
- HighlightOverlayGlyph.cs
- EventSinkHelperWriter.cs
- RegexCode.cs
- GcSettings.cs
- ListViewItemEventArgs.cs
- PageParser.cs
- StatusBarItemAutomationPeer.cs
- ArgumentFixer.cs
- UiaCoreProviderApi.cs
- ServiceDescriptionReflector.cs
- StoreAnnotationsMap.cs
- SuppressIldasmAttribute.cs
- TimeIntervalCollection.cs
- TraceFilter.cs
- StackBuilderSink.cs
- MetadataPropertyAttribute.cs
- SapiRecognizer.cs
- FrameworkObject.cs
- SelectionGlyphBase.cs
- PreviousTrackingServiceAttribute.cs
- ExpressionBinding.cs
- HtmlHead.cs
- xmlformatgeneratorstatics.cs
- QuotedPairReader.cs
- CapabilitiesSection.cs
- ObjectKeyFrameCollection.cs
- SqlNodeAnnotation.cs
- AttachedPropertyBrowsableAttribute.cs
- Ops.cs
- TraceUtils.cs
- XamlClipboardData.cs
- Semaphore.cs
- TargetPerspective.cs
- Line.cs
- SequenceDesigner.cs
- WorkingDirectoryEditor.cs
- ColorAnimationUsingKeyFrames.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- StateInitialization.cs
- ButtonBase.cs
- TdsParameterSetter.cs
- SpanIndex.cs
- HtmlControlPersistable.cs
- ResourceContainer.cs
- ReadingWritingEntityEventArgs.cs
- XmlSignificantWhitespace.cs
- OleDbReferenceCollection.cs
- CalendarBlackoutDatesCollection.cs
- loginstatus.cs
- DataContractJsonSerializerOperationBehavior.cs
- MarshalDirectiveException.cs
- MasterPageBuildProvider.cs
- SchemaMerger.cs
- _NestedMultipleAsyncResult.cs
- UnaryExpression.cs