internal FailFastUserCacheValue(BlockedType blockedType, TimeSpan blockedTime)
 {
     this.BlockedType = blockedType;
     this.AddedTime   = DateTime.UtcNow;
     this.BlockedTime = blockedTime;
     this.HitCount    = 1;
 }
        // Token: 0x06000045 RID: 69 RVA: 0x00003118 File Offset: 0x00001318
        protected override void InsertValueToCache(string key, BlockedType blockedType, TimeSpan blockedTime)
        {
            if (!FailFastUserCache.FailFastEnabled)
            {
                return;
            }
            Logger.EnterFunction(ExTraceGlobals.FailFastCacheTracer, "PassiveFailFastUserCache.InsertValueToCache");
            long num = blockedTime.Ticks;

            if (num < 0L)
            {
                Logger.TraceDebug(ExTraceGlobals.FailFastCacheTracer, "Blocked time ticks {0} < 0", new object[]
                {
                    num
                });
                num = 0L;
            }
            string text = string.Concat(new object[]
            {
                key,
                ';',
                blockedType,
                ';',
                num
            });

            byte[] bytes = FailFastUserCache.Encoding.GetBytes(text);
            Logger.TraceInformation(ExTraceGlobals.FailFastCacheTracer, "Send the blocked user info {0} to server stream.", new object[]
            {
                text
            });
            this.passiveObjectBehavior.SendMessage(bytes);
            Logger.ExitFunction(ExTraceGlobals.FailFastCacheTracer, "PassiveFailFastUserCache.InsertValueToCache");
        }
 // Token: 0x06000021 RID: 33 RVA: 0x00002B65 File Offset: 0x00000D65
 internal void AddUserToCache(string userToken, BlockedType blockedType, TimeSpan blockedTime)
 {
     if (!FailFastUserCache.FailFastEnabled)
     {
         return;
     }
     Logger.EnterFunction(ExTraceGlobals.FailFastCacheTracer, "FailFastUserCache.BlockUser");
     this.InsertValueToCache(userToken, blockedType, blockedTime);
     Logger.ExitFunction(ExTraceGlobals.FailFastCacheTracer, "FailFastUserCache.BlockUser");
 }
 // Token: 0x06000023 RID: 35 RVA: 0x00002BD1 File Offset: 0x00000DD1
 internal void AddAllUsersToCache(BlockedType blockedType, TimeSpan blockedTime)
 {
     if (!FailFastUserCache.FailFastEnabled)
     {
         return;
     }
     Logger.EnterFunction(ExTraceGlobals.FailFastCacheTracer, "FailFastUserCache.BlockAllUsers");
     this.InsertValueToCache("AllUsers:D3511BCA-379C-4a38-97E5-0FDA0C231C33", blockedType, blockedTime);
     Logger.ExitFunction(ExTraceGlobals.FailFastCacheTracer, "FailFastUserCache.BlockAllUsers");
 }
 // Token: 0x06000022 RID: 34 RVA: 0x00002B96 File Offset: 0x00000D96
 internal void AddTenantToCache(string tenant, BlockedType blockedType, TimeSpan blockedTime)
 {
     if (!FailFastUserCache.FailFastEnabled)
     {
         return;
     }
     Logger.EnterFunction(ExTraceGlobals.FailFastCacheTracer, "FailFastUserCache.BlockTenant");
     this.InsertValueToCache("Tenant:C8E2A9F6-0E7A-4bcc-95A0-9CE1BCA7EE68:" + tenant, blockedType, blockedTime);
     Logger.ExitFunction(ExTraceGlobals.FailFastCacheTracer, "FailFastUserCache.BlockTenant");
 }
        // Token: 0x060012F2 RID: 4850 RVA: 0x0003DC08 File Offset: 0x0003BE08
        internal static LocalizedString HandleUserOverBudgetException(OverBudgetException exception, AuthZPluginUserToken userToken)
        {
            string policyPart    = exception.PolicyPart;
            string userName      = userToken.UserName;
            string windowsLiveId = userToken.WindowsLiveId;

            ExTraceGlobals.PublicPluginAPITracer.TraceError <string, string>(0L, "Get User OverBudgetException for user {0}. Message: {1}", userName, exception.ToString());
            AuthZLogger.SafeAppendGenericError("User_OverBudgetException", exception.ToString(), false);
            if (!string.IsNullOrEmpty(windowsLiveId))
            {
                BlockedType blockedType = (policyPart == "PowerShellMaxCmdlets") ? BlockedType.NewRequest : BlockedType.NewSession;
                FailFastUserCache.Instance.AddUserToCache(userToken.WindowsLiveId, blockedType, TimeSpan.Zero);
                AuthZLogger.SafeAppendColumn(RpsCommonMetadata.ContributeToFailFast, "AuthZ-UserSelf", LoggerHelper.GetContributeToFailFastValue("User", userToken.WindowsLiveId, blockedType.ToString(), -1.0));
            }
            IThrottlingPolicy throttlingPolicy = userToken.GetThrottlingPolicy();
            LocalizedString   value;

            if (policyPart == "MaxConcurrency")
            {
                value = Strings.ErrorMaxRunspacesLimit(throttlingPolicy.PowerShellMaxConcurrency.ToString(), policyPart);
                TaskLogger.LogRbacEvent(TaskEventLogConstants.Tuple_ReachedMaxUserPSConnectionLimit, null, new object[]
                {
                    userName,
                    throttlingPolicy.PowerShellMaxConcurrency
                });
            }
            else if (policyPart == "MaxRunspacesTimePeriod")
            {
                value = Strings.ErrorMaxRunspacesTarpitting(exception.BackoffTime / 1000);
                TaskLogger.LogRbacEvent(TaskEventLogConstants.Tuple_ReachedMaxPSRunspaceInTimePeriodLimit, null, new object[]
                {
                    userName,
                    throttlingPolicy.PowerShellMaxRunspaces,
                    throttlingPolicy.PowerShellMaxRunspacesTimePeriod,
                    exception.BackoffTime
                });
            }
            else
            {
                if (!(policyPart == "PowerShellMaxCmdlets"))
                {
                    throw new NotSupportedException(string.Format("DEV bug. The exception policy part {0} is not expected.", policyPart));
                }
                value = Strings.ErrorOperationTarpitting(exception.BackoffTime / 1000);
                TaskLogger.LogRbacEvent(TaskEventLogConstants.Tuple_ReachedMaxPowershellCmdletLimit, null, new object[]
                {
                    userName,
                    throttlingPolicy.PowerShellMaxCmdlets,
                    throttlingPolicy.PowerShellMaxCmdletsTimePeriod,
                    exception.BackoffTime
                });
            }
            return(new LocalizedString(value + string.Format("{2}Policy: {0}; {2}Snapshot: {1}", exception.ThrottlingPolicyDN, exception.Snapshot, Environment.NewLine)));
        }
        protected override void InsertValueToCache(string key, BlockedType blockedType, TimeSpan blockedTime)
        {
            if (!FailFastUserCache.FailFastEnabled)
            {
                return;
            }
            Logger.EnterFunction(ExTraceGlobals.FailFastCacheTracer, "PrimaryFailFastUserCache.InsertValueToCache");
            blockedTime = PrimaryFailFastUserCache.GetValidBlockedTime(blockedTime);
            Logger.TraceDebug(ExTraceGlobals.FailFastCacheTracer, "Try to insert value to the cache. Key: {0}. BlockedType: {1}. BlockedTime: {2}.", new object[]
            {
                key,
                blockedType,
                blockedTime
            });
            FailFastUserCacheValue failFastUserCacheValue;

            if (base.TryGetValue(key, out failFastUserCacheValue) && failFastUserCacheValue.IsValid && failFastUserCacheValue.BlockedType > blockedType)
            {
                Logger.TraceDebug(ExTraceGlobals.FailFastCacheTracer, "Adding blocked type {0} that has smaller scope than existing one {1}.", new object[]
                {
                    blockedType,
                    failFastUserCacheValue.BlockedType
                });
                return;
            }
            if (failFastUserCacheValue == null || !failFastUserCacheValue.IsValid)
            {
                failFastUserCacheValue = new FailFastUserCacheValue(blockedType, blockedTime);
            }
            else
            {
                failFastUserCacheValue.BlockedTime = blockedTime;
                failFastUserCacheValue.BlockedType = blockedType;
                failFastUserCacheValue.AddedTime   = DateTime.UtcNow;
                failFastUserCacheValue.HitCount++;
            }
            Logger.LogEvent(TaskEventLogConstants.Tuple_LogUserAddedToFailFastUserCached, "UserAddedToFailFastCache:" + key, new object[]
            {
                key,
                failFastUserCacheValue.ToString()
            });
            Logger.TraceInformation(ExTraceGlobals.FailFastCacheTracer, "Insert value to the cache. Key: {0}. CacheValue: {1}.", new object[]
            {
                key,
                failFastUserCacheValue.ToString()
            });
            base.InsertAbsolute(key, failFastUserCacheValue, blockedTime, new RemoveItemDelegate <string, FailFastUserCacheValue>(this.OnCacheValueBeRemoved));
            FailFastModule.RemotePowershellPerfCounter.FailFastUserCacheSize.RawValue = (long)base.Count;
            Logger.ExitFunction(ExTraceGlobals.FailFastCacheTracer, "PrimaryFailFastUserCache.InsertValueToCache");
        }
        private void OnBlockedUserInfoReceived(byte[] message, int receivedSize)
        {
            Logger.EnterFunction(ExTraceGlobals.FailFastCacheTracer, "PrimaryFailFastUserCache.OnBlockedUserInfoReceived");
            string @string = FailFastUserCache.Encoding.GetString(message, 0, receivedSize);

            Logger.TraceDebug(ExTraceGlobals.FailFastCacheTracer, "Blocked user info \"{0}\" received.", new object[]
            {
                @string
            });
            if (string.IsNullOrWhiteSpace(@string))
            {
                Logger.TraceDebug(ExTraceGlobals.FailFastCacheTracer, "Null/Empty/Whitespace info is ignored.", new object[0]);
                return;
            }
            BlockedType blockedType = BlockedType.None;
            long        ticks       = 0L;
            bool        flag        = true;

            string[] array = @string.Split(PrimaryFailFastUserCache.blockedInfoSeparatorArray, StringSplitOptions.RemoveEmptyEntries);
            if (array.Length != 3)
            {
                flag = false;
            }
            if (flag && !Enum.TryParse <BlockedType>(array[1], out blockedType))
            {
                flag = false;
            }
            if (flag && !long.TryParse(array[2], out ticks))
            {
                flag = false;
            }
            if (flag)
            {
                string key = array[0];
                this.InsertValueToCache(key, blockedType, new TimeSpan(ticks));
                Logger.ExitFunction(ExTraceGlobals.FailFastCacheTracer, "PrimaryFailFastUserCache.OnBlockedUserInfoReceived");
                return;
            }
            string text = string.Format("The received value {0} is invalid.", @string);

            Logger.LogEvent(TaskEventLogConstants.Tuple_LogIncorrectUserInfoReceivedOnServerStream, null, new object[]
            {
                @string,
                text
            });
            Logger.TraceError(ExTraceGlobals.FailFastCacheTracer, text, new object[0]);
            throw new InvalidOperationException(text);
        }
 // Token: 0x06000025 RID: 37
 protected abstract void InsertValueToCache(string key, BlockedType blockedType, TimeSpan blockedTime);