Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / _SSPISessionCache.cs / 1305376 / _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
- TableCellAutomationPeer.cs
- KeyProperty.cs
- WindowsAltTab.cs
- ObjectDataSourceChooseTypePanel.cs
- _SafeNetHandles.cs
- Vars.cs
- Substitution.cs
- GrammarBuilder.cs
- PointLight.cs
- RegistrySecurity.cs
- QuaternionKeyFrameCollection.cs
- ActivityCodeDomSerializer.cs
- WeakReference.cs
- OdbcConnectionPoolProviderInfo.cs
- TreeWalkHelper.cs
- ProcessInputEventArgs.cs
- HtmlInputFile.cs
- PageBreakRecord.cs
- XamlSerializationHelper.cs
- EditorPartChrome.cs
- DataControlButton.cs
- Transform.cs
- ColumnReorderedEventArgs.cs
- ToolStripComboBox.cs
- NotificationContext.cs
- FormViewUpdateEventArgs.cs
- PersistChildrenAttribute.cs
- RightsManagementInformation.cs
- DefaultPrintController.cs
- AutomationPatternInfo.cs
- DataGridViewCellConverter.cs
- UndoEngine.cs
- DataSourceCollectionBase.cs
- CheckPair.cs
- HeaderCollection.cs
- DynamicDataManager.cs
- XmlSchemaSimpleTypeRestriction.cs
- SwitchCase.cs
- FontSource.cs
- _CookieModule.cs
- WsdlBuildProvider.cs
- WmlCommandAdapter.cs
- ControlPersister.cs
- EFDataModelProvider.cs
- ProtocolsSection.cs
- NativeCppClassAttribute.cs
- _IPv4Address.cs
- DataListCommandEventArgs.cs
- SearchForVirtualItemEventArgs.cs
- SpStreamWrapper.cs
- ValidationUtility.cs
- DataViewListener.cs
- FixedSOMElement.cs
- Inflater.cs
- HeaderFilter.cs
- XmlBindingWorker.cs
- RenderTargetBitmap.cs
- OperationPickerDialog.designer.cs
- JsonEncodingStreamWrapper.cs
- PictureBox.cs
- StreamInfo.cs
- GeneralTransform.cs
- WindowPatternIdentifiers.cs
- PipeConnection.cs
- DrawItemEvent.cs
- StreamResourceInfo.cs
- DataServiceQueryException.cs
- LowerCaseStringConverter.cs
- X509Certificate2.cs
- ApplicationException.cs
- TextServicesCompartmentEventSink.cs
- Model3D.cs
- SiteMapDataSource.cs
- WizardStepBase.cs
- Action.cs
- XmlComment.cs
- SecurityKeyIdentifierClause.cs
- EncryptedPackage.cs
- Quad.cs
- PromptEventArgs.cs
- RuleSetReference.cs
- WebPartAddingEventArgs.cs
- GenericsInstances.cs
- IDQuery.cs
- ColorAnimationBase.cs
- EventDescriptor.cs
- TreeViewAutomationPeer.cs
- BufferAllocator.cs
- COM2TypeInfoProcessor.cs
- DoubleLinkListEnumerator.cs
- RootCodeDomSerializer.cs
- UshortList2.cs
- ErrorItem.cs
- FrameworkTextComposition.cs
- QueryPageSettingsEventArgs.cs
- WindowsRichEdit.cs
- WrapPanel.cs
- QueryPageSettingsEventArgs.cs
- Help.cs
- PropertyEntry.cs