Пример #1
0
 // 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");
 }
Пример #2
0
        // 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);
        }
Пример #3
0
        // 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);
        }