Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / Tokens / SecurityContextSecurityTokenResolver.cs / 1 / SecurityContextSecurityTokenResolver.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Security.Tokens { using System.Xml; using System.ServiceModel; using System.Collections.ObjectModel; using System.IdentityModel.Selectors; using System.IdentityModel.Tokens; public class SecurityContextSecurityTokenResolver : SecurityTokenResolver, ISecurityContextSecurityTokenCache { SecurityContextTokenCache tokenCache; bool removeOldestTokensOnCacheFull; int capacity; public SecurityContextSecurityTokenResolver(int securityContextCacheCapacity, bool removeOldestTokensOnCacheFull) { if (securityContextCacheCapacity <= 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("securityContextCacheCapacity", SR.GetString(SR.ValueMustBeGreaterThanZero))); } this.capacity = securityContextCacheCapacity; this.removeOldestTokensOnCacheFull = removeOldestTokensOnCacheFull; this.tokenCache = new SecurityContextTokenCache(this.capacity, this.removeOldestTokensOnCacheFull); } public int SecurityContextTokenCacheCapacity { get { return this.capacity; } } public bool RemoveOldestTokensOnCacheFull { get { return this.removeOldestTokensOnCacheFull; } } public void AddContext(SecurityContextSecurityToken token) { this.tokenCache.AddContext(token); } public bool TryAddContext(SecurityContextSecurityToken token) { return this.tokenCache.TryAddContext(token); } public void ClearContexts() { this.tokenCache.ClearContexts(); } public void RemoveContext(UniqueId contextId, UniqueId generation) { this.tokenCache.RemoveContext(contextId, generation, false); } public void RemoveAllContexts(UniqueId contextId) { this.tokenCache.RemoveAllContexts(contextId); } public SecurityContextSecurityToken GetContext(UniqueId contextId, UniqueId generation) { return this.tokenCache.GetContext(contextId, generation); } public CollectionGetAllContexts(UniqueId contextId) { return this.tokenCache.GetAllContexts(contextId); } public void UpdateContextCachingTime(SecurityContextSecurityToken context, DateTime expirationTime) { this.tokenCache.UpdateContextCachingTime(context, expirationTime); } protected override bool TryResolveTokenCore(SecurityKeyIdentifierClause keyIdentifierClause, out SecurityToken token) { SecurityContextKeyIdentifierClause sctSkiClause = keyIdentifierClause as SecurityContextKeyIdentifierClause; if (sctSkiClause != null) { token = this.tokenCache.GetContext(sctSkiClause.ContextId, sctSkiClause.Generation); } else { token = null; } return (token != null); } protected override bool TryResolveSecurityKeyCore(SecurityKeyIdentifierClause keyIdentifierClause, out SecurityKey key) { SecurityToken sct; if (TryResolveTokenCore(keyIdentifierClause, out sct)) { key = ((SecurityContextSecurityToken)sct).SecurityKeys[0]; return true; } else { key = null; return false; } } protected override bool TryResolveTokenCore(SecurityKeyIdentifier keyIdentifier, out SecurityToken token) { SecurityContextKeyIdentifierClause sctSkiClause; if (keyIdentifier.TryFind (out sctSkiClause)) { return TryResolveToken(sctSkiClause, out token); } else { token = null; return false; } } } } // 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
- OleDbStruct.cs
- FieldInfo.cs
- SessionStateContainer.cs
- GeometryCombineModeValidation.cs
- HtmlElementCollection.cs
- RepeaterCommandEventArgs.cs
- Helpers.cs
- DocumentPageViewAutomationPeer.cs
- Activity.cs
- ValidationManager.cs
- FormatConvertedBitmap.cs
- ExpressionBinding.cs
- InputLanguageSource.cs
- TextTreeObjectNode.cs
- DeferredTextReference.cs
- ProcessRequestAsyncResult.cs
- ToolStripContentPanelRenderEventArgs.cs
- WindowsFormsSectionHandler.cs
- TypePresenter.xaml.cs
- XmlSchemaAll.cs
- SimpleLine.cs
- WindowsScroll.cs
- XPathParser.cs
- CompilationRelaxations.cs
- Splitter.cs
- EditorPartChrome.cs
- XmlStringTable.cs
- XmlSchemaDocumentation.cs
- DataTableTypeConverter.cs
- EncodingTable.cs
- DomainConstraint.cs
- SecurityState.cs
- ProviderConnectionPointCollection.cs
- WriteableBitmap.cs
- PixelFormats.cs
- IpcClientManager.cs
- BinaryNode.cs
- GacUtil.cs
- OperationResponse.cs
- TdsValueSetter.cs
- Cloud.cs
- SafeLocalMemHandle.cs
- SafeNativeMethodsOther.cs
- DeferredSelectedIndexReference.cs
- HebrewCalendar.cs
- SmiEventStream.cs
- ExternalException.cs
- ManualResetEvent.cs
- DnsEndpointIdentity.cs
- FeatureSupport.cs
- ObjectListTitleAttribute.cs
- AnimationException.cs
- VirtualizingStackPanel.cs
- XmlSerializerAssemblyAttribute.cs
- ContentTextAutomationPeer.cs
- MsmqIntegrationOutputChannel.cs
- NavigationHelper.cs
- WindowsProgressbar.cs
- Int16Storage.cs
- WebConfigurationManager.cs
- SecurityContext.cs
- CorruptingExceptionCommon.cs
- LazyTextWriterCreator.cs
- HwndMouseInputProvider.cs
- BitmapCacheBrush.cs
- WebPartZoneCollection.cs
- BinaryCommonClasses.cs
- DataConnectionHelper.cs
- SystemThemeKey.cs
- ServicePoint.cs
- FunctionUpdateCommand.cs
- HttpModuleAction.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- UpdateDelegates.Generated.cs
- SqlWebEventProvider.cs
- SettingsProperty.cs
- IgnoreFileBuildProvider.cs
- LinqDataSourceHelper.cs
- MultiSelector.cs
- OdbcTransaction.cs
- NameNode.cs
- DataPagerFieldCommandEventArgs.cs
- TemplateGroupCollection.cs
- FloaterParaClient.cs
- PlanCompilerUtil.cs
- DispatcherFrame.cs
- GlyphCache.cs
- MetafileHeaderWmf.cs
- XomlDesignerLoader.cs
- PageHandlerFactory.cs
- TemplateControl.cs
- RecordsAffectedEventArgs.cs
- BypassElement.cs
- EditingCoordinator.cs
- ReaderWriterLockSlim.cs
- CommonObjectSecurity.cs
- ServiceDescriptions.cs
- KeyGestureConverter.cs
- QilExpression.cs
- PublisherIdentityPermission.cs