public Configuration(ProtocolState state)
 {
     DebugTrace.TraceEnter(this, "Configuration");
     this.state           = state;
     this.overrideSection = this.GetOverrideSectionConfiguration();
     using (ConfigurationProvider provider = this.GetConfigurationProvider())
     {
         this.ReadDiagnosticTracingConfiguration(provider);
         this.ReadTimeoutConfiguration(provider);
         this.ReadTimerPolicyConfiguration(provider);
         this.ReadPortConfiguration(provider);
     }
     this.TraceConfiguration();
     DebugTrace.TraceLeave(this, "Configuration");
 }
        private void ReadTimeoutConfiguration(ConfigurationProvider provider)
        {
            this.defaultTimeout = this.ReadPositiveTimeSpan(provider, "DefaultTimeout", this.defaultTimeout);
            TimeSpan span = this.ReadTimeSpan(provider, "MaxTimeout", this.maxTimeout);

            if (span <= TimeSpan.Zero)
            {
                this.maxTimeout = TimeSpan.Zero;
            }
            else
            {
                this.maxTimeout = span;
                if (this.defaultTimeout > this.maxTimeout)
                {
                    this.defaultTimeout = this.maxTimeout;
                }
            }
            this.portConfig.OperationTimeout = this.ReadPositiveTimeSpan(provider, "OperationTimeout", TimeSpan.Zero);
        }
 private X509Certificate2 ReadX509CertificateIdentity(ConfigurationProvider provider)
 {
     X509Certificate2 certificate;
     string thumbprint = provider.ReadString("X509CertificateIdentity", null);
     if (thumbprint == null)
     {
         certificate = null;
         DebugTrace.Trace(TraceLevel.Warning, "{0} value could not be read", "X509CertificateIdentity");
         return certificate;
     }
     certificate = this.FindCertificateByThumbprint(thumbprint);
     if (certificate == null)
     {
         ThumbPrintNotFoundRecord.TraceAndLog(thumbprint);
         DebugTrace.Trace(TraceLevel.Warning, "Identity certificate with thumbprint {0} could not be found", thumbprint);
         return certificate;
     }
     if (!this.ValidateIdentityCertificate(certificate))
     {
         ThumbPrintNotValidatedRecord.TraceAndLog(thumbprint);
         DebugTrace.Trace(TraceLevel.Warning, "Identity certificate with thumbprint {0} could not be validated", thumbprint);
         certificate = null;
     }
     return certificate;
 }
 private ushort ReadUShort(ConfigurationProvider provider, string value, ushort defaultValue)
 {
     int num = provider.ReadInteger(value, defaultValue);
     if ((num < 0) || (num > 0xffff))
     {
         num = defaultValue;
     }
     return (ushort) num;
 }
        private SourceLevels ReadTraceSourceLevel(ConfigurationProvider provider, string value, SourceLevels defaultValue)
        {
            SourceLevels levels = (SourceLevels) provider.ReadInteger(value, (int) defaultValue);
            SourceLevels levels2 = levels;
            if (levels2 <= SourceLevels.Warning)
            {
                switch (levels2)
                {
                    case SourceLevels.Off:
                    case SourceLevels.Critical:
                    case SourceLevels.Error:
                        return levels;

                    case 2:
                        return defaultValue;

                    case SourceLevels.Warning:
                        return levels;
                }
                return defaultValue;
            }
            if ((levels2 != SourceLevels.Information) && (levels2 != SourceLevels.Verbose))
            {
                return defaultValue;
            }
            return levels;
        }
 private TimeSpan ReadTimeSpan(ConfigurationProvider provider, string value, TimeSpan defaultValue)
 {
     return new TimeSpan(0, 0, provider.ReadInteger(value, (int) defaultValue.TotalSeconds));
 }
 private void ReadTimerPolicyConfiguration(ConfigurationProvider rootProvider)
 {
     ConfigurationProvider provider = rootProvider.OpenKey("Timers");
     using (provider)
     {
         this.preparePolicy.InitialDelay = this.ReadPositiveTimeSpan(provider, "PrepareInitialDelay", new TimeSpan(0, 0, 15));
         this.preparePolicy.NotificationInterval = this.ReadPositiveTimeSpan(provider, "PrepareNotificationInterval", new TimeSpan(0, 0, 15));
         this.preparePolicy.IntervalIncreasePercentage = this.ReadUShort(provider, "PrepareIntervalIncreasePercentage", 0);
         this.preparePolicy.MaxNotificationInterval = this.ReadPositiveTimeSpan(provider, "PrepareMaxNotificationInterval", new TimeSpan(0, 0, 15));
         this.preparePolicy.MaxNotifications = (uint) provider.ReadInteger("PrepareMaxNotifications", 0);
         this.commitPolicy.InitialDelay = this.ReadPositiveTimeSpan(provider, "CommitInitialDelay", new TimeSpan(0, 1, 0));
         this.commitPolicy.NotificationInterval = this.ReadPositiveTimeSpan(provider, "CommitNotificationInterval", new TimeSpan(0, 0, 30));
         this.commitPolicy.IntervalIncreasePercentage = this.ReadUShort(provider, "CommitIntervalIncreasePercentage", 50);
         this.commitPolicy.MaxNotificationInterval = this.ReadPositiveTimeSpan(provider, "CommitMaxNotificationInterval", new TimeSpan(0, 5, 0));
         this.commitPolicy.MaxNotifications = (uint) provider.ReadInteger("CommitMaxNotifications", 0x19);
         this.preparedPolicy.InitialDelay = this.ReadPositiveTimeSpan(provider, "PreparedInitialDelay", new TimeSpan(0, 0, 20));
         this.preparedPolicy.NotificationInterval = this.ReadPositiveTimeSpan(provider, "PreparedNotificationInterval", new TimeSpan(0, 0, 20));
         this.preparedPolicy.IntervalIncreasePercentage = this.ReadUShort(provider, "PreparedIntervalIncreasePercentage", 50);
         this.preparedPolicy.MaxNotificationInterval = this.ReadPositiveTimeSpan(provider, "PreparedMaxNotificationInterval", new TimeSpan(0, 5, 0));
         this.preparedPolicy.MaxNotifications = (uint) provider.ReadInteger("PreparedMaxNotifications", 0);
         this.replayPolicy.InitialDelay = this.ReadPositiveTimeSpan(provider, "ReplayInitialDelay", new TimeSpan(0, 1, 0));
         this.replayPolicy.NotificationInterval = this.ReadPositiveTimeSpan(provider, "ReplayNotificationInterval", new TimeSpan(0, 0, 30));
         this.replayPolicy.IntervalIncreasePercentage = this.ReadUShort(provider, "ReplayIntervalIncreasePercentage", 50);
         this.replayPolicy.MaxNotificationInterval = this.ReadPositiveTimeSpan(provider, "ReplayMaxNotificationInterval", new TimeSpan(0, 5, 0));
         this.replayPolicy.MaxNotifications = (uint) provider.ReadInteger("ReplayMaxNotifications", 0);
         this.volatileOutcomePolicy.InitialDelay = this.ReadPositiveTimeSpan(provider, "VolatileOutcomeDelay", new TimeSpan(0, 3, 0));
         this.volatileOutcomePolicy.NotificationInterval = TimeSpan.Zero;
         this.volatileOutcomePolicy.IntervalIncreasePercentage = 0;
         this.volatileOutcomePolicy.MaxNotificationInterval = TimeSpan.Zero;
         this.volatileOutcomePolicy.MaxNotifications = 1;
     }
 }
 private void ReadTimeoutConfiguration(ConfigurationProvider provider)
 {
     this.defaultTimeout = this.ReadPositiveTimeSpan(provider, "DefaultTimeout", this.defaultTimeout);
     TimeSpan span = this.ReadTimeSpan(provider, "MaxTimeout", this.maxTimeout);
     if (span <= TimeSpan.Zero)
     {
         this.maxTimeout = TimeSpan.Zero;
     }
     else
     {
         this.maxTimeout = span;
         if (this.defaultTimeout > this.maxTimeout)
         {
             this.defaultTimeout = this.maxTimeout;
         }
     }
     this.portConfig.OperationTimeout = this.ReadPositiveTimeSpan(provider, "OperationTimeout", TimeSpan.Zero);
 }
 private TimeSpan ReadPositiveTimeSpan(ConfigurationProvider provider, string value, TimeSpan defaultValue)
 {
     TimeSpan span = this.ReadTimeSpan(provider, value, defaultValue);
     if (span <= TimeSpan.Zero)
     {
         span = defaultValue;
     }
     return span;
 }
 private void ReadPortConfiguration(ConfigurationProvider provider)
 {
     if (this.state.TransactionManager.Settings.AnyNetworkAccess && this.state.TransactionManager.Settings.NetworkTransactionAccess)
     {
         this.portConfig.X509Certificate = this.ReadX509CertificateIdentity(provider);
         if (this.portConfig.X509Certificate != null)
         {
             this.portConfig.Mode = CoordinationServiceMode.ProtocolService;
             this.portConfig.BasePath = this.GetBasePath();
             this.portConfig.SupportingTokensEnabled = provider.ReadInteger("IssuedTokensEnabled", 0) != 0;
             this.portConfig.HttpsPort = provider.ReadInteger("HttpsPort", 0x944);
             this.portConfig.RemoteClientsEnabled = this.state.TransactionManager.Settings.NetworkClientAccess || this.state.TransactionManager.Settings.IsClustered;
             this.portConfig.HostName = this.GetHostName();
             string[] collection = provider.ReadMultiString("X509GlobalAcl", null);
             if (collection != null)
             {
                 this.portConfig.GlobalAclX509CertificateThumbprints = new List<string>(collection);
             }
             string[] strArray2 = provider.ReadMultiString("KerberosGlobalAcl", null);
             if (strArray2 == null)
             {
                 SecurityIdentifier identifier = new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null);
                 NTAccount account = (NTAccount) identifier.Translate(typeof(NTAccount));
                 strArray2 = new string[] { account.Value };
             }
             this.portConfig.GlobalAclWindowsIdentities = new List<string>(strArray2);
         }
     }
 }
 private void ReadDiagnosticTracingConfiguration(ConfigurationProvider provider)
 {
     this.tracePii = provider.ReadInteger("DiagnosticTracingTracePII", 0) != 0;
     DebugTrace.Pii = this.tracePii;
     this.diagnosticTraceLevel = this.ReadTraceSourceLevel(provider, "DiagnosticTracing", this.diagnosticTraceLevel);
     if (this.diagnosticTraceLevel != SourceLevels.Off)
     {
         bool flag = provider.ReadInteger("DiagnosticTracingActivityTracing", 0) != 0;
         if (flag)
         {
             this.diagnosticTraceLevel |= SourceLevels.ActivityTracing;
         }
         try
         {
             Microsoft.Transactions.Bridge.DiagnosticUtility.InitializeTransactionSource(this.diagnosticTraceLevel);
         }
         catch (SystemException exception)
         {
             Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning);
             if (DebugTrace.Warning)
             {
                 DebugTrace.Trace(TraceLevel.Warning, "WS-AT diagnostic tracing will be disabled : {0}", exception.Message);
             }
             this.diagnosticTraceLevel = SourceLevels.Off;
         }
         Microsoft.Transactions.Bridge.DiagnosticUtility.Level = this.diagnosticTraceLevel;
         this.serviceModelDiagnosticTraceLevel = this.ReadTraceSourceLevel(provider, "ServiceModelDiagnosticTracing", this.serviceModelDiagnosticTraceLevel);
         if (this.serviceModelDiagnosticTraceLevel != SourceLevels.Off)
         {
             bool propagateActivity = provider.ReadInteger("DiagnosticTracingPropagateActivity", 0) != 0;
             if (flag)
             {
                 this.serviceModelDiagnosticTraceLevel |= SourceLevels.ActivityTracing;
             }
             try
             {
                 Microsoft.Transactions.Bridge.DiagnosticUtility.InitializeServiceModelSource(this.serviceModelDiagnosticTraceLevel, propagateActivity, this.tracePii);
             }
             catch (SystemException exception2)
             {
                 Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Warning);
                 if (DebugTrace.Warning)
                 {
                     DebugTrace.Trace(TraceLevel.Warning, "ServiceModel diagnostic tracing will be disabled : {0}", exception2.Message);
                 }
                 this.serviceModelDiagnosticTraceLevel = SourceLevels.Off;
             }
             System.ServiceModel.DiagnosticUtility.Level = this.serviceModelDiagnosticTraceLevel;
         }
     }
 }
 private TimeSpan ReadTimeSpan(ConfigurationProvider provider, string value, TimeSpan defaultValue)
 {
     return(new TimeSpan(0, 0, provider.ReadInteger(value, (int)defaultValue.TotalSeconds)));
 }