Пример #1
0
 // Token: 0x060012EA RID: 4842 RVA: 0x0003D9DC File Offset: 0x0003BBDC
 private static T HandleExceptionAndRetry <T>(string methodName, Func <T> func, bool throwException, T defaultReturnValue)
 {
     for (int i = 0; i < 2; i++)
     {
         try
         {
             Microsoft.Exchange.Diagnostics.Components.Authorization.ExTraceGlobals.PublicPluginAPITracer.TraceDebug <string, int>(0L, "Retry function {0} the {1} times.", methodName, i);
             return(func());
         }
         catch (Exception ex)
         {
             bool flag  = ex is TransientException;
             bool flag2 = AuthZPluginHelper.IsFatalException(ex);
             bool flag3 = flag2 || AuthZLogHelper.ExceptionNoNeedToRetry(ex);
             Microsoft.Exchange.Diagnostics.Components.Authorization.ExTraceGlobals.PublicPluginAPITracer.TraceDebug(0L, "{0} caught Exception {1}. IsTransientException = {2}. IsFatalException = {3}. NoNeedToRetry = {4}.", new object[]
             {
                 methodName,
                 ex,
                 flag,
                 flag2,
                 flag3
             });
             ExEventLog.EventTuple eventInfo = Microsoft.Exchange.Configuration.ObjectModel.EventLog.TaskEventLogConstants.Tuple_RBACUnavailable_UnknownError;
             if (flag)
             {
                 eventInfo = Microsoft.Exchange.Configuration.ObjectModel.EventLog.TaskEventLogConstants.Tuple_RBACUnavailable_TransientError;
             }
             else if (flag2)
             {
                 eventInfo = Microsoft.Exchange.Configuration.ObjectModel.EventLog.TaskEventLogConstants.Tuple_RBACUnavailable_FatalError;
             }
             TaskLogger.LogRbacEvent(eventInfo, null, new object[]
             {
                 methodName,
                 ex
             });
             if (flag3 || i == 1)
             {
                 if (!(ex is ADTransientException) && (flag2 || throwException))
                 {
                     throw;
                 }
                 AuthZLogHelper.LogException(ex, methodName, false);
                 break;
             }
             else
             {
                 AuthZLogger.SafeAppendGenericInfo(methodName + "-" + ex.GetType().Name + "-Retried", ex.Message);
             }
         }
     }
     Microsoft.Exchange.Diagnostics.Components.Authorization.ExTraceGlobals.PublicPluginAPITracer.TraceError <string, T>(0L, "{0} returns default value {1}.", methodName, defaultReturnValue);
     return(defaultReturnValue);
 }
Пример #2
0
 // Token: 0x060012E1 RID: 4833 RVA: 0x0003D75C File Offset: 0x0003B95C
 internal static void EndLogging(bool shouldCommit)
 {
     Microsoft.Exchange.Diagnostics.Components.Configuration.Core.ExTraceGlobals.InstrumentationTracer.TraceDebug(0L, "[AuthZLogHelper.EndLogging] End logging.");
     try
     {
         if (AuthZLogHelper.latencyTracker != null)
         {
             long num = Diagnostics.ExecuteAndLog <long>("AuthZLogHelper.StopLatencyTracker", false, null, Constants.CoreEventLogger, Microsoft.Exchange.Configuration.Core.EventLog.TaskEventLogConstants.Tuple_NonCrashingException, Microsoft.Exchange.Diagnostics.Components.Configuration.Core.ExTraceGlobals.InstrumentationTracer, null, delegate(Exception ex)
             {
                 AuthZLogHelper.LogException(ex, "AuthZLogHelper.StopLatencyTracker", false);
             }, -1L, new Func <long>(AuthZLogHelper.StopLatencyTracker));
             AuthZLogger.SafeSetLogger(ConfigurationCoreMetadata.TotalTime, num);
             AuthZLogHelper.latencyTracker.PushLatencyDetailsToLog(AuthZLogHelper.funcNameToLogMetadataDic, new Action <Enum, double>(AuthZLogger.UpdateLatency), delegate(string funcName, string totalLatency)
             {
                 AuthZLogger.SafeAppendColumn(RpsCommonMetadata.GenericLatency, funcName, totalLatency);
             });
         }
         else
         {
             AuthZLogger.SafeAppendColumn(RpsCommonMetadata.GenericLatency, "LatencyMissed", "AuthZLogHelper.latencyTracker is null");
         }
     }
     finally
     {
         try
         {
             if (shouldCommit)
             {
                 AuthZLogger.AsyncCommit(true);
             }
         }
         finally
         {
             AuthZLogHelper.latencyTracker = null;
         }
     }
 }
Пример #3
0
        // Token: 0x060012DD RID: 4829 RVA: 0x0003D4C8 File Offset: 0x0003B6C8
        internal static T ExecuteWSManPluginAPI <T>(string funcName, bool throwException, bool trackLatency, T defaultReturnValue, Func <T> func)
        {
            ExWatson.IsExceptionInteresting isExceptionInteresting = null;
            T result;

            try
            {
                AuthZLogger.SafeAppendColumn(RpsCommonMetadata.GenericLatency, funcName, DateTime.UtcNow.ToString());
                string                funcName2       = funcName;
                bool                  throwException2 = throwException;
                LatencyTracker        latencyTracker  = trackLatency ? AuthZLogHelper.latencyTracker : null;
                ExEventLog            rbacEventLogger = AuthZLogHelper.RbacEventLogger;
                ExEventLog.EventTuple tuple_RemotePSPublicAPIFailed = Microsoft.Exchange.Configuration.ObjectModel.EventLog.TaskEventLogConstants.Tuple_RemotePSPublicAPIFailed;
                Trace                 publicPluginAPITracer         = Microsoft.Exchange.Diagnostics.Components.Authorization.ExTraceGlobals.PublicPluginAPITracer;
                if (isExceptionInteresting == null)
                {
                    isExceptionInteresting = ((object ex) => AuthZPluginHelper.IsFatalException(ex as Exception));
                }
                result = Diagnostics.ExecuteAndLog <T>(funcName2, throwException2, latencyTracker, rbacEventLogger, tuple_RemotePSPublicAPIFailed, publicPluginAPITracer, isExceptionInteresting, delegate(Exception ex)
                {
                    AuthZLogHelper.LogException(ex, funcName, throwException);
                }, defaultReturnValue, () => AuthZLogHelper.HandleExceptionAndRetry <T>(funcName, func, throwException, defaultReturnValue));
            }
            catch (Exception ex)
            {
                string arg = (AuthZLogger.ActivityScope != null) ? AuthZLogger.ActivityScope.ActivityId.ToString() : null;
                AuthZLogHelper.EndLogging(true);
                Exception              ex3;
                string                 str     = string.Format("[FailureCategory={0}] ", FailureCategory.AuthZ + "-" + ex3.GetType().Name);
                string                 str2    = string.Format("[AuthZRequestId={0}]", arg);
                LocalizedString        message = new LocalizedString(str2 + str + ex3.Message);
                AuthorizationException ex2     = new AuthorizationException(message, ex3);
                throw ex2;
            }
            return(result);
        }
Пример #4
0
 // Token: 0x060012DF RID: 4831 RVA: 0x0003D670 File Offset: 0x0003B870
 internal static bool StartLogging(string funcName, out bool latencyTrackerStartedByMe)
 {
     AuthZLogger.SafeAppendColumn(RpsCommonMetadata.GenericLatency, funcName, DateTime.UtcNow.ToString());
     latencyTrackerStartedByMe = false;
     if (AuthZLogHelper.latencyTracker == null)
     {
         Diagnostics.ExecuteAndLog("AuthZLogHelper.StartLatencyTracker", false, null, Constants.CoreEventLogger, Microsoft.Exchange.Configuration.Core.EventLog.TaskEventLogConstants.Tuple_NonCrashingException, Microsoft.Exchange.Diagnostics.Components.Configuration.Core.ExTraceGlobals.InstrumentationTracer, null, delegate(Exception ex)
         {
             AuthZLogHelper.LogException(ex, "AuthZLogHelper.StartLatencyTracker", false);
         }, delegate()
         {
             AuthZLogHelper.StartLatencyTracker(funcName);
         });
         latencyTrackerStartedByMe = (AuthZLogHelper.latencyTracker != null);
     }
     if (AuthZLogger.LoggerNotDisposed)
     {
         return(false);
     }
     InitializeLoggerSettingsHelper.InitLoggerSettings();
     AuthZLogger.InitializeRequestLogger();
     AuthZLogger.SafeSetLogger(RpsAuthZMetadata.Function, funcName);
     return(true);
 }