public bool TryAddTokenCache(string userName, string password, ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies)
 {
     byte[] salt = new byte[saltSize];
     this.random.GetBytes(salt);
     LogonToken token = new LogonToken(userName, password, salt, authorizationPolicies);
     DateTime expirationTime = DateTime.UtcNow.Add(this.cachedLogonTokenLifetime);
     return TryAddItem(userName, token, expirationTime, true);
 }
 public bool TryAddTokenCache(string userName, string password, ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies)
 {
     byte[] data = new byte[4];
     this.random.GetBytes(data);
     LogonToken item = new LogonToken(userName, password, data, authorizationPolicies);
     DateTime expirationTime = DateTime.UtcNow.Add(this.cachedLogonTokenLifetime);
     return base.TryAddItem(userName, item, expirationTime, true);
 }
        public bool TryAddTokenCache(string userName, string password, ReadOnlyCollection <IAuthorizationPolicy> authorizationPolicies)
        {
            byte[] salt = new byte[saltSize];
            this.random.GetBytes(salt);
            LogonToken token          = new LogonToken(userName, password, salt, authorizationPolicies);
            DateTime   expirationTime = DateTime.UtcNow.Add(this.cachedLogonTokenLifetime);

            return(TryAddItem(userName, token, expirationTime, true));
        }
        public bool TryAddTokenCache(string userName, string password, ReadOnlyCollection <IAuthorizationPolicy> authorizationPolicies)
        {
            byte[] data = new byte[4];
            this.random.GetBytes(data);
            LogonToken item           = new LogonToken(userName, password, data, authorizationPolicies);
            DateTime   expirationTime = DateTime.UtcNow.Add(this.cachedLogonTokenLifetime);

            return(base.TryAddItem(userName, item, expirationTime, true));
        }
        protected override ArrayList OnQuotaReached(Hashtable cacheTable)
        {
            List <TimeBoundedCache.IExpirableItem> list = new List <TimeBoundedCache.IExpirableItem>(cacheTable.Count);

            foreach (TimeBoundedCache.IExpirableItem item in cacheTable.Values)
            {
                list.Add(item);
            }
            list.Sort(TimeBoundedCache.ExpirableItemComparer.Default);
            int capacity = (list.Count * 0x19) / 100;

            capacity = (capacity <= 0) ? list.Count : capacity;
            ArrayList list2 = new ArrayList(capacity);

            for (int i = 0; i < capacity; i++)
            {
                LogonToken token = (LogonToken)base.ExtractItem(list[i]);
                list2.Add(token.UserName);
                this.OnRemove(token);
            }
            return(list2);
        }
        // Remove those about to expire
        protected override ArrayList OnQuotaReached(Hashtable cacheTable)
        {
            List <IExpirableItem> items = new List <IExpirableItem>(cacheTable.Count);

            foreach (IExpirableItem value in cacheTable.Values)
            {
                items.Add(value);
            }
            // Those expired soon in front
            items.Sort(ExpirableItemComparer.Default);
            int pruningAmount = (items.Count * (100 - lowWaterMarkFactor)) / 100;

            // edge case
            pruningAmount = pruningAmount <= 0 ? items.Count : pruningAmount;
            ArrayList keys = new ArrayList(pruningAmount);

            for (int i = 0; i < pruningAmount; ++i)
            {
                LogonToken token = (LogonToken)ExtractItem(items[i]);
                keys.Add(token.UserName);
                OnRemove(token);
            }
            return(keys);
        }
 public bool TryGetTokenCache(string userName, out LogonToken token)
 {
     token = (LogonToken) base.GetItem(userName);
     return (token != null);
 }
 public bool TryGetTokenCache(string userName, out LogonToken token)
 {
     token = (LogonToken)GetItem(userName);
     return(token != null);
 }