mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Adding reference source for System.Data System.Data.DataSetExtensions System.Data.Entity System.Data.Entity.Design System.Data.Linq System.Data.SqlXml System.ServiceModel System.ServiceModel.Activation System.ServiceModel.Activities System.ServiceModel.Channels System.ServiceModel.Discovery System.ServiceModel.Internals System.ServiceModel.Routing System.ServiceModel.WasHosting System.ServiceModel.Web System.Web System.Web.ApplicationServices System.Web.DynamicData System.Web.Entity System.Web.Entity.Design System.Web.Extensions System.Web.Mobile System.Web.Routing System.Web.Services System.Xml System.Xml.Linq
71 lines
2.7 KiB
C#
71 lines
2.7 KiB
C#
//-----------------------------------------------------------------------------
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
//-----------------------------------------------------------------------------
|
|
|
|
namespace System.ServiceModel.Security
|
|
{
|
|
using System;
|
|
using System.Collections;
|
|
using System.Runtime;
|
|
using System.ServiceModel;
|
|
using System.ServiceModel.Diagnostics.Application;
|
|
|
|
sealed class NegotiationTokenAuthenticatorStateCache<T> : TimeBoundedCache
|
|
where T : NegotiationTokenAuthenticatorState
|
|
{
|
|
static int lowWaterMark = 50;
|
|
static TimeSpan purgingInterval = TimeSpan.FromMinutes(10);
|
|
TimeSpan cachingSpan;
|
|
|
|
public NegotiationTokenAuthenticatorStateCache(TimeSpan cachingSpan, int maximumCachedState)
|
|
: base(lowWaterMark, maximumCachedState, null, PurgingMode.TimerBasedPurge, TimeSpan.FromTicks(cachingSpan.Ticks >> 2), true)
|
|
{
|
|
this.cachingSpan = cachingSpan;
|
|
}
|
|
|
|
public void AddState(string context, T state)
|
|
{
|
|
DateTime expirationTime = TimeoutHelper.Add(DateTime.UtcNow, this.cachingSpan);
|
|
bool wasStateAdded = base.TryAddItem(context, state, expirationTime, false);
|
|
if (!wasStateAdded)
|
|
{
|
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperWarning(new SecurityNegotiationException(SR.GetString(SR.NegotiationStateAlreadyPresent, context)));
|
|
}
|
|
if (TD.NegotiateTokenAuthenticatorStateCacheRatioIsEnabled())
|
|
{
|
|
TD.NegotiateTokenAuthenticatorStateCacheRatio(base.Count, base.Capacity);
|
|
}
|
|
}
|
|
|
|
public T GetState(string context)
|
|
{
|
|
return (this.GetItem(context) as T);
|
|
}
|
|
|
|
public void RemoveState(string context)
|
|
{
|
|
this.TryRemoveItem(context);
|
|
if (TD.NegotiateTokenAuthenticatorStateCacheRatioIsEnabled())
|
|
{
|
|
TD.NegotiateTokenAuthenticatorStateCacheRatio(base.Count, base.Capacity);
|
|
}
|
|
}
|
|
|
|
|
|
protected override ArrayList OnQuotaReached(Hashtable cacheTable)
|
|
{
|
|
if (TD.NegotiateTokenAuthenticatorStateCacheExceededIsEnabled())
|
|
{
|
|
TD.NegotiateTokenAuthenticatorStateCacheExceeded(SR.GetString(SR.CachedNegotiationStateQuotaReached, this.Capacity));
|
|
}
|
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QuotaExceededException(SR.GetString(SR.CachedNegotiationStateQuotaReached, this.Capacity)));
|
|
}
|
|
|
|
protected override void OnRemove(object item)
|
|
{
|
|
((IDisposable)item).Dispose();
|
|
base.OnRemove(item);
|
|
}
|
|
}
|
|
}
|