private static void LoadAutoBlockThresholds() { bool flag = false; try { object obj; Monitor.Enter(obj = ADNotificationManager.startLock, ref flag); DeviceAutoBlockThreshold[] newValues = new DeviceAutoBlockThreshold[Enum.GetValues(typeof(AutoblockThresholdType)).Length]; bool flag2 = false; ActiveSyncDeviceAutoblockThreshold[] thresholds = null; try { ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { thresholds = ADNotificationManager.topoSession.Find <ActiveSyncDeviceAutoblockThreshold>(ADNotificationManager.topoSession.GetOrgContainerId().GetDescendantId(new ADObjectId("CN=Mobile Mailbox Policies")), QueryScope.OneLevel, null, ADNotificationManager.thresholdSortBy, newValues.Length); }); if (!adoperationResult.Succeeded) { AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "Exception occurred during AD Operation during LoadAutoBlockThresholds. Exception Message -{0}", adoperationResult.Exception.Message); throw adoperationResult.Exception; } foreach (ActiveSyncDeviceAutoblockThreshold activeSyncDeviceAutoblockThreshold in thresholds) { if (activeSyncDeviceAutoblockThreshold.BehaviorType < (AutoblockThresholdType)newValues.Length) { newValues[(int)activeSyncDeviceAutoblockThreshold.BehaviorType] = new DeviceAutoBlockThreshold(activeSyncDeviceAutoblockThreshold); } } flag2 = true; } finally { if (ADNotificationManager.autoBlockThresholds == null || flag2) { for (int j = 0; j < newValues.Length; j++) { if (newValues[j] == null) { newValues[j] = new DeviceAutoBlockThreshold((AutoblockThresholdType)j); } } ADNotificationManager.autoBlockThresholds = new ADNotificationManager.DeviceAutoblockThresholdInfo(newValues, ExDateTime.UtcNow); } } } finally { if (flag) { object obj; Monitor.Exit(obj); } } }
// Token: 0x0600055D RID: 1373 RVA: 0x0001F608 File Offset: 0x0001D808 public void AddSyncKey(ExDateTime syncAttemptTime, string collectionId, uint syncKey) { AirSyncDiagnostics.TraceInfo <string, uint>(ExTraceGlobals.RequestsTracer, this, "AddSyncKey collectionId:{0} syncKey:{1}", collectionId, syncKey); DeviceAutoBlockThreshold autoBlockThreshold = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.SyncCommands); lock (this.instanceLock) { int num = this.syncTimes.Count - 1; while (num > -1 && !(this.syncTimes[num] == syncAttemptTime)) { num--; } if (num == -1) { this.RecordSyncCommand(syncAttemptTime); num = this.syncTimes.Count - 1; if (this.syncTimes[num] != syncAttemptTime) { throw new InvalidOperationException("Recently added sync record is not the last one!"); } if (this.BlockOnFrequency()) { return; } } int num2 = this.syncKeys[num] ^ ((collectionId != null) ? collectionId.GetHashCode() : 0) ^ syncKey.GetHashCode(); this.syncKeys[num] = num2; AirSyncDiagnostics.TraceInfo <int>(ExTraceGlobals.RequestsTracer, this, "AddSyncKey new hashcode {0}", num2); if (this.ProtocolLogger != null) { this.ProtocolLogger.SetValue(ProtocolLoggerData.SyncHashCode, num2); } int num3 = 0; ExDateTime t = syncAttemptTime - autoBlockThreshold.BehaviorTypeIncidenceDuration; for (int i = 0; i < this.syncTimes.Count; i++) { if (!(this.syncTimes[i] < t) && this.syncKeys[i] == num2) { num3++; } } int behaviorTypeIncidenceLimit = autoBlockThreshold.BehaviorTypeIncidenceLimit; if (behaviorTypeIncidenceLimit > 0 && num3 >= behaviorTypeIncidenceLimit) { this.BlockDevice(AutoblockThresholdType.SyncCommands); } else if (this.AutoBlockReason != DeviceAccessStateReason.Unknown) { this.UnblockDevice(); } } }
// Token: 0x0600055C RID: 1372 RVA: 0x0001F55C File Offset: 0x0001D75C public void RecordOutOfBudget() { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "RecordOutOfBudget"); ExDateTime utcNow = ExDateTime.UtcNow; DeviceAutoBlockThreshold autoBlockThreshold = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.OutOfBudgets); ExDateTime windowStartTime = utcNow - autoBlockThreshold.BehaviorTypeIncidenceDuration; lock (this.instanceLock) { DeviceBehavior.ClearOldRecords(windowStartTime, this.outOfBudgets); this.outOfBudgets.Add(utcNow); this.SaveDeviceBehavior(false); int behaviorTypeIncidenceLimit = autoBlockThreshold.BehaviorTypeIncidenceLimit; if (behaviorTypeIncidenceLimit > 0 && this.outOfBudgets.Count > behaviorTypeIncidenceLimit) { this.BlockDevice(AutoblockThresholdType.OutOfBudgets); } } }
// Token: 0x0600055A RID: 1370 RVA: 0x0001F358 File Offset: 0x0001D558 public void RecordCommand(int commandHashcode) { AirSyncDiagnostics.TraceInfo <int>(ExTraceGlobals.RequestsTracer, this, "RecordCommand HC:{0}", commandHashcode); ExDateTime utcNow = ExDateTime.UtcNow; DeviceAutoBlockThreshold autoBlockThreshold = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.RecentCommands); EnhancedTimeSpan behaviorTypeIncidenceDuration = autoBlockThreshold.BehaviorTypeIncidenceDuration; if (behaviorTypeIncidenceDuration < ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceDuration) { behaviorTypeIncidenceDuration = ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.CommandFrequency).BehaviorTypeIncidenceDuration; } ExDateTime exDateTime = utcNow - behaviorTypeIncidenceDuration; lock (this.instanceLock) { DeviceBehavior.ClearOldRecords(exDateTime, this.recentCommandTimes, this.recentCommandHashCodes); this.recentCommandTimes.Add(utcNow); this.recentCommandHashCodes.Add(commandHashcode); this.SaveDeviceBehavior(false); if (this.ProtocolLogger != null) { this.ProtocolLogger.SetValue(ProtocolLoggerData.CommandHashCode, commandHashcode); } if (!this.BlockOnFrequency()) { exDateTime = utcNow - autoBlockThreshold.BehaviorTypeIncidenceDuration; int num = 0; for (int i = 0; i < this.recentCommandTimes.Count; i++) { if (!(this.recentCommandTimes[i] < exDateTime) && this.recentCommandHashCodes[i] == commandHashcode) { num++; } } int behaviorTypeIncidenceLimit = autoBlockThreshold.BehaviorTypeIncidenceLimit; if (behaviorTypeIncidenceLimit > 0 && num > behaviorTypeIncidenceLimit) { this.BlockDevice(AutoblockThresholdType.RecentCommands); } } } }