Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Net / System / Net / _SSPISessionCache.cs / 1 / _SSPISessionCache.cs
/*++ Copyright (c) Microsoft Corporation Module Name: _SspiSessionCache.cs Abstract: The file implements trivial SSPI credential caching mechanism based on lru list Author: Alexei Vopilov 20-Oct-2004 Revision History: --*/ namespace System.Net.Security { using System.Net; using System.Threading; using System.Collections; // // Implements delayed SSPI handle release, like a finalizable object though the handles are kept alive until being pushed out // by the newly incoming ones. // internal static class SSPIHandleCache { private const int c_MaxCacheSize = 0x1F; // must a (power of 2) - 1 private static SafeCredentialReference[] _CacheSlots = new SafeCredentialReference[c_MaxCacheSize+1]; private static int _Current = -1; internal static void CacheCredential(SafeFreeCredentials newHandle) { try { SafeCredentialReference newRef = SafeCredentialReference.CreateReference(newHandle); if (newRef == null) return; unchecked { int index = Interlocked.Increment(ref _Current) & c_MaxCacheSize; newRef = Interlocked.Exchange(ref _CacheSlots[index], newRef); } if (newRef != null) newRef.Close(); } catch(Exception e) { if (!NclUtilities.IsFatal(e)){ GlobalLog.Assert("SSPIHandlCache", "Attempted to throw: " + e.ToString()); } } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. /*++ Copyright (c) Microsoft Corporation Module Name: _SspiSessionCache.cs Abstract: The file implements trivial SSPI credential caching mechanism based on lru list Author: Alexei Vopilov 20-Oct-2004 Revision History: --*/ namespace System.Net.Security { using System.Net; using System.Threading; using System.Collections; // // Implements delayed SSPI handle release, like a finalizable object though the handles are kept alive until being pushed out // by the newly incoming ones. // internal static class SSPIHandleCache { private const int c_MaxCacheSize = 0x1F; // must a (power of 2) - 1 private static SafeCredentialReference[] _CacheSlots = new SafeCredentialReference[c_MaxCacheSize+1]; private static int _Current = -1; internal static void CacheCredential(SafeFreeCredentials newHandle) { try { SafeCredentialReference newRef = SafeCredentialReference.CreateReference(newHandle); if (newRef == null) return; unchecked { int index = Interlocked.Increment(ref _Current) & c_MaxCacheSize; newRef = Interlocked.Exchange (ref _CacheSlots[index], newRef); } if (newRef != null) newRef.Close(); } catch(Exception e) { if (!NclUtilities.IsFatal(e)){ GlobalLog.Assert("SSPIHandlCache", "Attempted to throw: " + e.ToString()); } } } } } // 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
- CodeSnippetTypeMember.cs
- SelectorItemAutomationPeer.cs
- EntityReference.cs
- FormViewUpdateEventArgs.cs
- ObjectQueryState.cs
- SafeRightsManagementPubHandle.cs
- FileLogRecordStream.cs
- StateBag.cs
- CommentEmitter.cs
- OdbcTransaction.cs
- WebControlParameterProxy.cs
- UTF7Encoding.cs
- MemberDescriptor.cs
- ValuePatternIdentifiers.cs
- ZoneButton.cs
- DetailsViewRow.cs
- SamlAuthorizationDecisionStatement.cs
- VSDExceptions.cs
- HandledMouseEvent.cs
- CodeSnippetCompileUnit.cs
- PeerNodeTraceRecord.cs
- ContainerUtilities.cs
- PerformanceCounterPermissionAttribute.cs
- ConfigurationException.cs
- LicenseProviderAttribute.cs
- ServicePointManager.cs
- ItemCollection.cs
- Matrix3DStack.cs
- Latin1Encoding.cs
- ZipIOModeEnforcingStream.cs
- AnnotationDocumentPaginator.cs
- ExpressionSelection.cs
- ClipboardData.cs
- DodSequenceMerge.cs
- ObjectParameterCollection.cs
- Encoder.cs
- FacetChecker.cs
- COM2PropertyDescriptor.cs
- ProgressiveCrcCalculatingStream.cs
- VirtualizingStackPanel.cs
- NamespaceInfo.cs
- SafeEventLogWriteHandle.cs
- LookupBindingPropertiesAttribute.cs
- HierarchicalDataSourceControl.cs
- DefaultAsyncDataDispatcher.cs
- Win32PrintDialog.cs
- QueryContinueDragEventArgs.cs
- DataGridViewCellStyleBuilderDialog.cs
- ResourceSet.cs
- BitmapImage.cs
- IArgumentProvider.cs
- DoubleLink.cs
- DerivedKeyCachingSecurityTokenSerializer.cs
- ConfigurationManagerHelper.cs
- FileDialogCustomPlace.cs
- TemplateManager.cs
- FormViewInsertedEventArgs.cs
- FloaterBaseParaClient.cs
- RSAPKCS1SignatureFormatter.cs
- UTF32Encoding.cs
- XmlnsPrefixAttribute.cs
- ManagementObjectSearcher.cs
- Pens.cs
- HtmlSelect.cs
- DefaultClaimSet.cs
- ImportContext.cs
- PenContext.cs
- XamlTypeWithExplicitNamespace.cs
- ToolStripItemGlyph.cs
- UserPersonalizationStateInfo.cs
- SwitchAttribute.cs
- XsltOutput.cs
- DynamicFilter.cs
- Object.cs
- LabelEditEvent.cs
- HistoryEventArgs.cs
- CustomAttributeBuilder.cs
- HandlerFactoryCache.cs
- XamlParser.cs
- SQLInt64Storage.cs
- PipelineModuleStepContainer.cs
- AggregateNode.cs
- ContextMenuService.cs
- XmlCodeExporter.cs
- MetadataPropertyvalue.cs
- ProvidePropertyAttribute.cs
- DeclaredTypeValidatorAttribute.cs
- ConfigurationManagerInternalFactory.cs
- ProviderBase.cs
- PaginationProgressEventArgs.cs
- AliasExpr.cs
- AttributeData.cs
- securitymgrsite.cs
- SurrogateEncoder.cs
- KeyedByTypeCollection.cs
- CheckBoxField.cs
- ThreadSafeList.cs
- DesignSurface.cs
- SystemIPInterfaceStatistics.cs
- TabControl.cs