Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / RSATokenProvider.cs / 1 / RSATokenProvider.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
//
// Presharp uses the c# pragma mechanism to supress its warnings.
// These are not recognised by the base compiler so we need to explictly
// disable the following warnings. See http://winweb/cse/Tools/PREsharp/userguide/default.asp
// for details.
//
#pragma warning disable 1634, 1691 // unknown message, unknown pragma
namespace Microsoft.InfoCards
{
using System;
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using System.ServiceModel;
using System.ServiceModel.Security;
using System.ServiceModel.Security.Tokens;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.IdentityModel;
using System.Security.Cryptography.Xml;
using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace;
using System.Collections.ObjectModel;
using System.Collections.Generic;
//
// This class is used to provide a custom token provider for adding an endorsing signature token to the RST
// message sent to a managed card STS. The endorsing signature must be added if the UseKey field is present
// in the RST.
//
internal class RSATokenProvider : SecurityTokenProvider, IDisposable
{
InfoCardPolicy m_policy;
InfoCard m_card;
SelfIssuedAuthProofToken m_RSAToken;
public RSATokenProvider( InfoCardPolicy policy, InfoCard card )
{
IDT.ThrowInvalidArgumentConditional( null == policy, "policy" );
IDT.ThrowInvalidArgumentConditional( null == card, "card" );
m_policy = policy;
m_card = card;
}
public void Dispose()
{
//
// We must dispose this token explicitly.
//
if ( null != m_RSAToken )
{
m_RSAToken.Dispose();
m_RSAToken = null;
}
}
//
// Summary
// Retrieves a token from the system
//
// Parameters
// timeout - The time span till the call times out
//
// Returns
// The security token.
//
protected override SecurityToken GetTokenCore(TimeSpan timeout)
{
if( null == m_RSAToken )
{
//
// The SelfIssuedAuthProofToken should be renamed. In this case it's just acting as a generic
// wrapper for an RSA key.
//
m_RSAToken = new SelfIssuedAuthProofToken( m_card.GetPrivateCryptography( m_policy.Recipient.GetIdentifier() ),
DateTime.UtcNow + timeout );
}
return m_RSAToken;
}
}
}
// 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
- StorageMappingFragment.cs
- TreeViewItem.cs
- CssStyleCollection.cs
- ExtendedProtectionPolicyElement.cs
- CultureMapper.cs
- HwndAppCommandInputProvider.cs
- CommandEventArgs.cs
- KeyboardEventArgs.cs
- CacheMemory.cs
- SqlDataSourceSelectingEventArgs.cs
- SqlCharStream.cs
- FormViewUpdatedEventArgs.cs
- MatrixTransform3D.cs
- NamedPipeProcessProtocolHandler.cs
- LoginAutoFormat.cs
- DataGridViewRowCollection.cs
- DeviceContext2.cs
- ZipIOFileItemStream.cs
- ReadOnlyAttribute.cs
- BehaviorEditorPart.cs
- PasswordPropertyTextAttribute.cs
- BrowserCapabilitiesFactoryBase.cs
- PersonalizationProviderHelper.cs
- _UriTypeConverter.cs
- TemplateControlBuildProvider.cs
- TemplateField.cs
- SelectedCellsCollection.cs
- ThreadStartException.cs
- Sentence.cs
- CounterCreationDataCollection.cs
- DataGridViewRowsRemovedEventArgs.cs
- MethodCallTranslator.cs
- CodeGotoStatement.cs
- PathFigureCollection.cs
- WasNotInstalledException.cs
- DbException.cs
- DEREncoding.cs
- InkCanvasAutomationPeer.cs
- TPLETWProvider.cs
- AutomationProperties.cs
- SqlException.cs
- VisualBasicDesignerHelper.cs
- CollectionViewGroupInternal.cs
- LayoutEditorPart.cs
- ApplicationProxyInternal.cs
- AnnotationObservableCollection.cs
- TextServicesPropertyRanges.cs
- StylusPlugin.cs
- PersonalizationStateInfoCollection.cs
- PasswordDeriveBytes.cs
- CollaborationHelperFunctions.cs
- Grant.cs
- AppPool.cs
- EncryptedData.cs
- NavigationHelper.cs
- TextDecorationCollectionConverter.cs
- PageContentCollection.cs
- BooleanFacetDescriptionElement.cs
- ParserStack.cs
- CuspData.cs
- PlainXmlSerializer.cs
- PolyLineSegmentFigureLogic.cs
- WindowsButton.cs
- TcpConnectionPoolSettings.cs
- TimeSpanOrInfiniteConverter.cs
- SqlEnums.cs
- ThreadNeutralSemaphore.cs
- WebServiceMethodData.cs
- MessageProperties.cs
- SystemNetHelpers.cs
- DTCTransactionManager.cs
- GenericIdentity.cs
- UnsafeNativeMethods.cs
- ImageDrawing.cs
- WinInet.cs
- ValidationRule.cs
- RelationHandler.cs
- BamlTreeNode.cs
- ZoneButton.cs
- TextEditorSelection.cs
- CommandExpr.cs
- SslStream.cs
- ValidatorCompatibilityHelper.cs
- BypassElement.cs
- ColumnResizeAdorner.cs
- HtmlEmptyTagControlBuilder.cs
- VisualTreeHelper.cs
- StdValidatorsAndConverters.cs
- DynamicVirtualDiscoSearcher.cs
- AnnotationResourceChangedEventArgs.cs
- ProjectionPruner.cs
- PaintEvent.cs
- FontStyles.cs
- Control.cs
- MappingModelBuildProvider.cs
- RMEnrollmentPage2.cs
- SiteMapPath.cs
- LineServices.cs
- ParameterCollectionEditor.cs
- StorageComplexTypeMapping.cs