Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / InfocardInteractiveChannelInitializer.cs / 1 / InfocardInteractiveChannelInitializer.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Security { using System.Collections.Generic; using System.ServiceModel.Channels; using System.ServiceModel.Dispatcher; using System.ServiceModel.Description; using System.IdentityModel.Selectors; using System.IdentityModel.Tokens; using System.Runtime.Serialization; using System.ServiceModel.Security; public class InfocardInteractiveChannelInitializer : IInteractiveChannelInitializer { ClientCredentials credentials; Binding binding; public InfocardInteractiveChannelInitializer( ClientCredentials credentials, Binding binding ) { this.credentials = credentials; this.binding = binding; } public Binding Binding { get { return binding; } } public virtual IAsyncResult BeginDisplayInitializationUI(IClientChannel channel, AsyncCallback callback, object state) { return new GetTokenUIAsyncResult(binding, channel, this.credentials, callback, state); } public virtual void EndDisplayInitializationUI(IAsyncResult result) { GetTokenUIAsyncResult.End(result); } } internal class GetTokenUIAsyncResult :AsyncResult { IClientChannel proxy; ClientCredentials credentials; Uri relyingPartyIssuer; bool requiresInfoCard; Binding binding; static AsyncCallback callback = DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(GetTokenUIAsyncResult.Callback)); internal GetTokenUIAsyncResult(Binding binding, IClientChannel channel, ClientCredentials credentials, AsyncCallback callback, object state) : base(callback, state) { this.credentials = credentials; this.proxy = channel; this.binding = binding; this.CallBegin(true); } void CallBegin(bool completedSynchronously) { IAsyncResult result = null; Exception exception = null; try { CardSpacePolicyElement[ ] chain; SecurityTokenManager tokenManager = credentials.CreateSecurityTokenManager(); requiresInfoCard = InfoCardHelper.IsInfocardRequired(binding, credentials, tokenManager, proxy.RemoteAddress, out chain, out relyingPartyIssuer); MessageSecurityVersion bindingSecurityVersion = InfoCardHelper.GetBindingSecurityVersionOrDefault(binding); WSSecurityTokenSerializer tokenSerializer = WSSecurityTokenSerializer.DefaultInstance; result = credentials.GetInfoCardTokenCallback.BeginInvoke(requiresInfoCard, chain, tokenManager.CreateSecurityTokenSerializer(bindingSecurityVersion.SecurityTokenVersion), callback, this); } catch (Exception e) { if (DiagnosticUtility.IsFatal(e)) { throw; } exception = e; } if (exception == null) { if (!result.CompletedSynchronously) { return; } this.CallEnd(result, out exception); } if (exception != null) { return; } this.CallComplete(completedSynchronously, null); } static void Callback(IAsyncResult result) { if (result.CompletedSynchronously) { return; } GetTokenUIAsyncResult outer = (GetTokenUIAsyncResult)result.AsyncState; Exception exception = null; outer.CallEnd(result, out exception); outer.CallComplete(false, exception); } void CallEnd(IAsyncResult result, out Exception exception) { try { SecurityToken token = credentials.GetInfoCardTokenCallback.EndInvoke(result); ChannelParameterCollection channelParameters = proxy.GetProperty(); if( null != channelParameters ) { channelParameters.Add( new InfoCardChannelParameter( token, relyingPartyIssuer, requiresInfoCard ) ); } exception = null; } catch (Exception e) { if (DiagnosticUtility.IsFatal(e)) { throw; } exception = e; } } void CallComplete(bool completedSynchronously, Exception exception) { this.Complete(completedSynchronously, exception); } internal static void End(IAsyncResult result) { AsyncResult.End (result); } } } // 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
- SqlRowUpdatingEvent.cs
- TrackingSection.cs
- TabControl.cs
- StrongNamePublicKeyBlob.cs
- FileSystemInfo.cs
- SqlConnectionString.cs
- ContextMenuStrip.cs
- ContainerAction.cs
- TableDesigner.cs
- ProjectionPruner.cs
- RightsManagementEncryptionTransform.cs
- QuotedStringWriteStateInfo.cs
- LocalizableResourceBuilder.cs
- SafeNativeMethods.cs
- ResetableIterator.cs
- DbConnectionStringBuilder.cs
- FrameworkElementFactory.cs
- BuildResultCache.cs
- PageParser.cs
- RegexRunnerFactory.cs
- TextLineBreak.cs
- DrawingImage.cs
- CodeGenerator.cs
- RenamedEventArgs.cs
- securitycriticaldataformultiplegetandset.cs
- ToolStripContainerDesigner.cs
- MetaModel.cs
- UnsafeMethods.cs
- CompiledRegexRunner.cs
- XmlEncoding.cs
- StreamAsIStream.cs
- CodeVariableReferenceExpression.cs
- ReachSerializer.cs
- OleDbError.cs
- ContextActivityUtils.cs
- PropertyChangedEventArgs.cs
- WebPartPersonalization.cs
- WorkBatch.cs
- ToolStripOverflow.cs
- DescendantQuery.cs
- Polygon.cs
- BamlTreeNode.cs
- InvalidPrinterException.cs
- IdnElement.cs
- TimeZoneNotFoundException.cs
- AnnotationResource.cs
- ToolStripLocationCancelEventArgs.cs
- StateDesigner.cs
- DrawingBrush.cs
- XmlCDATASection.cs
- mediaclock.cs
- ColumnResizeUndoUnit.cs
- StrongName.cs
- ProgressBarHighlightConverter.cs
- Localizer.cs
- AppDomainProtocolHandler.cs
- ExtensionFile.cs
- ApplicationFileCodeDomTreeGenerator.cs
- UserControlParser.cs
- COM2ComponentEditor.cs
- CommentAction.cs
- Typography.cs
- TreeNodeConverter.cs
- SubstitutionList.cs
- Stackframe.cs
- MemberAccessException.cs
- StringDictionaryCodeDomSerializer.cs
- ScalarConstant.cs
- PackagePartCollection.cs
- WSDualHttpSecurityMode.cs
- TextTreeTextNode.cs
- ScriptManager.cs
- SafeNativeMethodsCLR.cs
- OdbcEnvironmentHandle.cs
- AccessText.cs
- ObjectHandle.cs
- ConsoleTraceListener.cs
- BitmapEditor.cs
- DataGridItemCollection.cs
- ImpersonateTokenRef.cs
- ExpressionBinding.cs
- FieldBuilder.cs
- LockCookie.cs
- HttpCookieCollection.cs
- ReferenceTypeElement.cs
- WebContext.cs
- ExpressionBuilder.cs
- TypeElementCollection.cs
- ExpressionDumper.cs
- DocumentSchemaValidator.cs
- XPathChildIterator.cs
- ConfigurationException.cs
- MDIWindowDialog.cs
- WebSysDefaultValueAttribute.cs
- ValidatedControlConverter.cs
- LinearGradientBrush.cs
- PkcsUtils.cs
- filewebrequest.cs
- XmlSchemaAttributeGroup.cs
- XmlSerializationGeneratedCode.cs