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
- Token.cs
- UnmanagedHandle.cs
- CryptographicAttribute.cs
- Camera.cs
- Debug.cs
- ProfileElement.cs
- DataColumnCollection.cs
- IndentTextWriter.cs
- WindowsListViewSubItem.cs
- FileDataSourceCache.cs
- HMACSHA512.cs
- DataRowView.cs
- ListItem.cs
- TextWriter.cs
- QueryTaskGroupState.cs
- UIElementParagraph.cs
- CapabilitiesSection.cs
- MessageDispatch.cs
- Binding.cs
- PlatformCulture.cs
- HasCopySemanticsAttribute.cs
- Directory.cs
- FlowNode.cs
- Identity.cs
- MembershipSection.cs
- ImageBrush.cs
- DbConnectionStringBuilder.cs
- WindowsIdentity.cs
- ListItemCollection.cs
- StaticResourceExtension.cs
- ListViewDesigner.cs
- TreeViewEvent.cs
- Utility.cs
- StateBag.cs
- MonthChangedEventArgs.cs
- ISAPIApplicationHost.cs
- HtmlHead.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- XmlArrayAttribute.cs
- CompressionTransform.cs
- XamlClipboardData.cs
- ImageSource.cs
- XmlElementAttributes.cs
- ReaderContextStackData.cs
- BulletedList.cs
- DbConnectionPoolCounters.cs
- DbParameterCollectionHelper.cs
- ColorAnimation.cs
- HScrollProperties.cs
- ResourceBinder.cs
- MsmqMessageSerializationFormat.cs
- EngineSite.cs
- AsyncInvokeOperation.cs
- BridgeDataRecord.cs
- Lazy.cs
- HtmlInputRadioButton.cs
- ObjectResult.cs
- TableLayoutStyle.cs
- HttpNamespaceReservationInstallComponent.cs
- Base64Stream.cs
- TextBoxBase.cs
- SearchExpression.cs
- MemoryRecordBuffer.cs
- QilInvokeEarlyBound.cs
- HelpHtmlBuilder.cs
- DataReceivedEventArgs.cs
- Nodes.cs
- TransformerTypeCollection.cs
- ExtractCollection.cs
- MarkupExtensionReturnTypeAttribute.cs
- OleDbConnectionInternal.cs
- WebPageTraceListener.cs
- RegexWriter.cs
- ToolTip.cs
- SetterBaseCollection.cs
- BindingContext.cs
- FrugalMap.cs
- SizeKeyFrameCollection.cs
- CodeObjectCreateExpression.cs
- HeaderedContentControl.cs
- TextBox.cs
- PerformanceCounterPermissionAttribute.cs
- CompositeScriptReference.cs
- XmlValueConverter.cs
- QuaternionKeyFrameCollection.cs
- WmlObjectListAdapter.cs
- PolicyException.cs
- FeatureAttribute.cs
- ResourceIDHelper.cs
- MarkupCompilePass2.cs
- CodeIdentifiers.cs
- ReceiveActivityDesignerTheme.cs
- COMException.cs
- DataContractSerializerFaultFormatter.cs
- RegistrationServices.cs
- NativeMethods.cs
- EventProvider.cs
- DataGrid.cs
- AssociatedControlConverter.cs
- StylusButtonEventArgs.cs