// Token: 0x06000556 RID: 1366 RVA: 0x0001EDD0 File Offset: 0x0001CFD0 public static DeviceBehavior GetDeviceBehavior(Guid userGuid, DeviceIdentity deviceIdentity, GlobalInfo globalInfo, object traceObject, ProtocolLogger protocolLogger) { string token = DeviceBehaviorCache.GetToken(userGuid, deviceIdentity); globalInfo.DeviceBehavior.ProtocolLogger = protocolLogger; globalInfo.DeviceBehavior.CacheToken = token; DeviceBehavior deviceBehavior; if (globalInfo.DeviceADObjectId == null || !DeviceBehaviorCache.TryGetAndRemoveValue(userGuid, deviceIdentity, out deviceBehavior)) { if (protocolLogger != null) { protocolLogger.SetValue(ProtocolLoggerData.DeviceBehaviorLoaded, 7); } AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, traceObject, "No device in cache, return GlobalInfo.DeviceBehavior"); return(globalInfo.DeviceBehavior); } if (deviceBehavior.AutoBlockReason != globalInfo.DeviceBehavior.AutoBlockReason) { if (protocolLogger != null) { protocolLogger.SetValue(ProtocolLoggerData.DeviceBehaviorLoaded, 1); } AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, traceObject, "AutoBlockReason changed, return GlobalInfo.DeviceBehavior"); return(globalInfo.DeviceBehavior); } int num = globalInfo.DeviceBehavior.IsNewerThan(deviceBehavior.WhenLoaded); if (num > -1) { string arg = DeviceBehavior.dateCollections[num]; if (protocolLogger != null) { protocolLogger.SetValue(ProtocolLoggerData.DeviceBehaviorLoaded, num + 2); } AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, traceObject, "{0} is newer, return GlobalInfo.DeviceBehavior", arg); return(globalInfo.DeviceBehavior); } AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, traceObject, "Return cached DeviceBehavior"); deviceBehavior.Owner = globalInfo; deviceBehavior.ProtocolLogger = protocolLogger; return(deviceBehavior); }
// Token: 0x0600056C RID: 1388 RVA: 0x00020334 File Offset: 0x0001E534 private void SaveDeviceBehavior(bool forceSave) { AirSyncDiagnostics.TraceInfo <bool>(ExTraceGlobals.RequestsTracer, this, "SaveDeviceBehavior forceSave:{0}", forceSave); if (this.Owner != null && !this.Owner.IsDisposed) { if (this.CacheToken == null) { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "CacheToken is null, skip caching"); forceSave = true; } else { forceSave = (forceSave || DeviceBehaviorCache.ContainsKey(this.CacheToken)); DeviceBehaviorCache.AddOrReplace(this.CacheToken, this); } if (!forceSave) { return; } if (this.ProtocolLogger != null) { this.ProtocolLogger.SetValue(ProtocolLoggerData.DeviceBehaviorSaved, 1); } try { this.Owner.DeviceBehavior = this; this.Owner.IsDirty = true; return; } catch (ObjectDisposedException) { AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, this, "SaveDeviceBehavior owner is disposed"); return; } } AirSyncDiagnostics.TraceInfo <string>(ExTraceGlobals.RequestsTracer, this, "SaveDeviceBehavior owner {0}", (this.Owner == null) ? "not set" : "disposed"); }
// Token: 0x06000285 RID: 645 RVA: 0x0000E88C File Offset: 0x0000CA8C private bool TarpitErrorResponse(int httpStatusCode) { if (httpStatusCode != 441 && httpStatusCode != 449) { return(true); } if (httpStatusCode == 451) { return(!DeviceCapability.DeviceCanHandleRedirect(this.context)); } if (ADNotificationManager.GetAutoBlockThreshold(AutoblockThresholdType.RecentCommands).BehaviorTypeIncidenceDuration == EnhancedTimeSpan.Zero) { return(false); } DeviceBehavior deviceBehavior = this.context.DeviceBehavior; if (deviceBehavior == null) { Guid userGuid = AirSyncResponse.UnknownUserGuid; if (httpStatusCode != 441) { switch (httpStatusCode) { case 449: if (Command.CurrentCommand != null && Command.CurrentCommand.GlobalInfo != null && Command.CurrentCommand.GlobalInfo.DeviceADObjectId != null) { userGuid = Command.CurrentCommand.GlobalInfo.DeviceADObjectId.ObjectGuid; goto IL_136; } goto IL_136; case 451: if (this.context.User != null && this.context.User.ADUser != null && this.context.User.ADUser.Id != null) { userGuid = this.context.User.ADUser.Id.ObjectGuid; goto IL_136; } goto IL_136; } throw new ApplicationException("Unexpected HTTP status code " + httpStatusCode); } IL_136: if (!DeviceBehaviorCache.TryGetValue(userGuid, this.context.DeviceIdentity, out deviceBehavior)) { deviceBehavior = new DeviceBehavior(true); DeviceBehaviorCache.AddOrReplace(userGuid, this.context.DeviceIdentity, deviceBehavior); } } if (deviceBehavior != null) { lock (deviceBehavior) { if (deviceBehavior.IsDeviceAutoBlocked(null) != DeviceAccessStateReason.Unknown) { return(true); } deviceBehavior.RecordCommand(httpStatusCode); if (deviceBehavior.IsDeviceAutoBlocked(null) != DeviceAccessStateReason.Unknown) { return(true); } } return(false); } return(false); }
// Token: 0x06000574 RID: 1396 RVA: 0x000208C4 File Offset: 0x0001EAC4 public static bool TryGetValue(Guid userGuid, DeviceIdentity deviceIdentity, out DeviceBehavior data) { string token = DeviceBehaviorCache.GetToken(userGuid, deviceIdentity); return(DeviceBehaviorCache.TryGetValue(token, out data)); }
// Token: 0x06000578 RID: 1400 RVA: 0x000209A8 File Offset: 0x0001EBA8 public static void AddOrReplace(Guid userGuid, DeviceIdentity deviceIdentity, DeviceBehavior data) { string token = DeviceBehaviorCache.GetToken(userGuid, deviceIdentity); DeviceBehaviorCache.AddOrReplace(token, data); }
// Token: 0x06000576 RID: 1398 RVA: 0x00020938 File Offset: 0x0001EB38 public static bool ContainsKey(Guid userGuid, DeviceIdentity deviceIdentity) { string token = DeviceBehaviorCache.GetToken(userGuid, deviceIdentity); return(DeviceBehaviorCache.ContainsKey(token)); }