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
- PopupControlService.cs
- ServiceDocumentFormatter.cs
- SmtpFailedRecipientException.cs
- ObjectAssociationEndMapping.cs
- ListCommandEventArgs.cs
- HttpCookiesSection.cs
- WindowsTooltip.cs
- UrlAuthFailedErrorFormatter.cs
- EntityDataSourceContextCreatedEventArgs.cs
- EncryptedData.cs
- ChtmlImageAdapter.cs
- XmlNodeReader.cs
- AdPostCacheSubstitution.cs
- OdbcDataReader.cs
- MobilePage.cs
- HeaderedContentControl.cs
- Pair.cs
- WebPageTraceListener.cs
- wgx_sdk_version.cs
- Point.cs
- _TimerThread.cs
- SecurityToken.cs
- AuthenticationModulesSection.cs
- IndexedGlyphRun.cs
- AssemblyBuilder.cs
- KeySpline.cs
- CompareInfo.cs
- FlowDocumentFormatter.cs
- TypeConverterHelper.cs
- AssemblyResourceLoader.cs
- XmlSubtreeReader.cs
- HotSpot.cs
- FormsAuthenticationTicket.cs
- _ProxyChain.cs
- BooleanStorage.cs
- SignatureResourceHelper.cs
- TextEndOfLine.cs
- PlainXmlSerializer.cs
- UrlMapping.cs
- AssemblyBuilderData.cs
- XmlSchemaCollection.cs
- AccessibleObject.cs
- UseLicense.cs
- SqlConnectionPoolProviderInfo.cs
- DbModificationClause.cs
- wmiprovider.cs
- ServiceInstanceProvider.cs
- SqlConnection.cs
- XhtmlBasicPhoneCallAdapter.cs
- ResXFileRef.cs
- JsonQNameDataContract.cs
- TypeConverterAttribute.cs
- AuthenticateEventArgs.cs
- Int16AnimationUsingKeyFrames.cs
- DataSourceGroupCollection.cs
- HttpHeaderCollection.cs
- TableMethodGenerator.cs
- TextParagraphCache.cs
- COM2FontConverter.cs
- CommandPlan.cs
- LinqDataSourceValidationException.cs
- PathGeometry.cs
- FileClassifier.cs
- AnnotationResourceChangedEventArgs.cs
- XmlArrayItemAttribute.cs
- FtpWebRequest.cs
- SocketInformation.cs
- MustUnderstandSoapException.cs
- WmfPlaceableFileHeader.cs
- GroupQuery.cs
- AppDomainUnloadedException.cs
- EntityType.cs
- WhileDesigner.cs
- ImportCatalogPart.cs
- HeaderedItemsControl.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- HandlerBase.cs
- XPathExpr.cs
- Floater.cs
- UnknownMessageReceivedEventArgs.cs
- ZipArchive.cs
- StringHelper.cs
- TextBoxAutoCompleteSourceConverter.cs
- login.cs
- Pkcs7Recipient.cs
- StoreAnnotationsMap.cs
- ScaleTransform.cs
- MappingModelBuildProvider.cs
- WindowsListViewItemCheckBox.cs
- BamlLocalizer.cs
- RelationalExpressions.cs
- ReadOnlyHierarchicalDataSourceView.cs
- InstanceLockTracking.cs
- ConstraintStruct.cs
- FlowDocumentView.cs
- PkcsUtils.cs
- CodeChecksumPragma.cs
- IDataContractSurrogate.cs
- ControlUtil.cs
- GridViewCommandEventArgs.cs