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
- HttpListenerException.cs
- BuildResult.cs
- XmlByteStreamReader.cs
- Transform3DGroup.cs
- SQLBytesStorage.cs
- SqlWriter.cs
- KeySplineConverter.cs
- TreeViewItem.cs
- CounterSet.cs
- TextOnlyOutput.cs
- RawStylusInput.cs
- util.cs
- EmptyReadOnlyDictionaryInternal.cs
- EqualityComparer.cs
- ToolStripItem.cs
- DiagnosticStrings.cs
- IntSecurity.cs
- ConfigurationElementCollection.cs
- ObjectComplexPropertyMapping.cs
- RangeBase.cs
- TextPatternIdentifiers.cs
- ITextView.cs
- ObjectStateManagerMetadata.cs
- HyperLink.cs
- CopyOfAction.cs
- StrokeCollection2.cs
- milexports.cs
- Rect3DConverter.cs
- MdiWindowListItemConverter.cs
- PhysicalFontFamily.cs
- UnitySerializationHolder.cs
- HostingPreferredMapPath.cs
- AudioDeviceOut.cs
- IgnoreFileBuildProvider.cs
- PenContext.cs
- DateTimeFormatInfoScanner.cs
- XmlDataContract.cs
- PrinterSettings.cs
- HttpHandlerAction.cs
- InfoCardMasterKey.cs
- CodeLabeledStatement.cs
- ThemeDirectoryCompiler.cs
- CodeGenHelper.cs
- PageAsyncTask.cs
- XmlToDatasetMap.cs
- FragmentQuery.cs
- EventSourceCreationData.cs
- EdmRelationshipRoleAttribute.cs
- ManagementClass.cs
- ButtonFieldBase.cs
- BrowserCapabilitiesFactory.cs
- UnorderedHashRepartitionStream.cs
- ActivitiesCollection.cs
- mda.cs
- ServiceNameElement.cs
- PreProcessor.cs
- SingleResultAttribute.cs
- MissingFieldException.cs
- BitmapScalingModeValidation.cs
- SliderAutomationPeer.cs
- RequestCachingSection.cs
- ExtractCollection.cs
- PtsHelper.cs
- FileChangesMonitor.cs
- GorillaCodec.cs
- Int32Rect.cs
- ArraySegment.cs
- BaseCAMarshaler.cs
- MenuDesigner.cs
- UnsafeNetInfoNativeMethods.cs
- diagnosticsswitches.cs
- Permission.cs
- SystemPens.cs
- SrgsRule.cs
- ConfigXmlAttribute.cs
- SettingsPropertyWrongTypeException.cs
- OLEDB_Util.cs
- Translator.cs
- DeferredBinaryDeserializerExtension.cs
- PointCollection.cs
- BooleanAnimationUsingKeyFrames.cs
- MultiPageTextView.cs
- StrokeCollection2.cs
- XmlSchemaRedefine.cs
- MetaForeignKeyColumn.cs
- FixedHighlight.cs
- CursorEditor.cs
- LoginView.cs
- RewritingPass.cs
- ToolStripDropDown.cs
- _AuthenticationState.cs
- FontWeights.cs
- SignatureHelper.cs
- DoubleLinkList.cs
- OdbcTransaction.cs
- MessageSecurityOverTcpElement.cs
- RuleInfoComparer.cs
- OpenTypeLayout.cs
- CacheMemory.cs
- ListenerElementsCollection.cs