private static string GetReplicatorAddress()
        {
            NativeConfigStore configStore       = System.Fabric.Common.NativeConfigStore.FabricGetConfigStore();
            string            replicatorAddress = configStore.ReadUnencryptedString("FabricNode", "UpgradeServiceReplicatorAddress");

            return(replicatorAddress);
        }
Esempio n. 2
0
        private SecuritySetting()
        {
            this.configStore = NativeConfigStore.FabricGetConfigStore(this);
            string         serverAuthCredentialTypeName = configStore.ReadUnencryptedString(SecurityConfigSectionName, ServerAuthCredentialTypeName);
            CredentialType serverAuthCredentialType     = CredentialType.None;

            if ((!string.IsNullOrEmpty(serverAuthCredentialTypeName)) &&
                (!Enum.TryParse <CredentialType>(serverAuthCredentialTypeName, out serverAuthCredentialType)))
            {
                EventStoreLogger.Logger.LogWarning(
                    "Unable to convert configuration value serverAuthCredentialTypeName {0} for {1} type.",
                    serverAuthCredentialTypeName,
                    serverAuthCredentialType);
            }

            this.ServerAuthCredentialType = serverAuthCredentialType;
            if (ServerAuthCredentialType == CredentialType.X509)
            {
                this.EndpointProtocol = EndpointProtocol.Https;
            }
            else
            {
                this.EndpointProtocol = EndpointProtocol.Http;
            }

            this.AllowedClientCertThumbprints = null;
            this.AllowedClientIdentities      = null;
            this.AllowedClientCertCommonNames = null;

            this.InitializeFromConfig();
        }
Esempio n. 3
0
        public AADSettings()
        {
            this.configValuesLock  = new RwLock();
            this.nativeConfigStore = NativeConfigStore.FabricGetConfigStore(this);

            this.LoadGlobalDefaultSettings();
        }
Esempio n. 4
0
        private bool IsPackageNearExpiry(PackageDetails currentPackage)
        {
            bool isNearExpiry             = false;
            NativeConfigStore configStore = NativeConfigStore.FabricGetConfigStore();

            string goalStateExpirationReminderInDaysString = configStore.ReadUnencryptedString(DMConstants.UpgradeOrchestrationServiceConfigSectionName, DMConstants.GoalStateExpirationReminderInDays);
            uint   goalStateExpirationReminderInDays;

            if (string.IsNullOrEmpty(goalStateExpirationReminderInDaysString) || !uint.TryParse(goalStateExpirationReminderInDaysString, out goalStateExpirationReminderInDays))
            {
                this.traceSource.WriteInfo(
                    TraceType,
                    "goalStateExpirationReminderInDays value invalid: \"{0}\". Defaulting to {1}.",
                    goalStateExpirationReminderInDaysString,
                    DMConstants.DefaultGoalStateExpirationReminderInDays);
                goalStateExpirationReminderInDays = DMConstants.DefaultGoalStateExpirationReminderInDays;
            }

            if (currentPackage != null && currentPackage.SupportExpiryDate != null)
            {
                isNearExpiry = (currentPackage.SupportExpiryDate - DateTime.UtcNow).Value.TotalDays < goalStateExpirationReminderInDays;
            }

            return(isNearExpiry);
        }
Esempio n. 5
0
        private static StatefulServiceBase ReadConfiguration(StatefulServiceContext context)
        {
            var configStore = NativeConfigStore.FabricGetConfigStore();
            var backupRestoreServiceReplicatorAddress = configStore.ReadUnencryptedString("FabricNode", "BackupRestoreServiceReplicatorAddress");

            return(new BackupRestoreService(context, backupRestoreServiceReplicatorAddress));
        }
Esempio n. 6
0
 public EncryptionCertConfigHandler(Action <string, string, CancellationToken> encryptionCertChangeCallback,
                                    StatefulService statefulService, CancellationToken runAsyncCancellationToken)
 {
     this.updateCertCallback        = encryptionCertChangeCallback;
     this.runAsyncCancellationToken = runAsyncCancellationToken;
     this.statefulService           = statefulService;
     this.nativeConfigStore         = NativeConfigStore.FabricGetConfigStore();
 }
Esempio n. 7
0
 internal void LoadSettings(NativeConfigStore nativeConfig)
 {
     this.DSTSDnsName                = nativeConfig.ReadUnencryptedString(DSTSSectionName, DSTSDnsNameKey);
     this.DSTSRealm                  = nativeConfig.ReadUnencryptedString(DSTSSectionName, DSTSRealmKey);
     this.ServiceDnsName             = nativeConfig.ReadUnencryptedString(DSTSSectionName, TVSServiceDnsNameKey);
     this.ServiceName                = nativeConfig.ReadUnencryptedString(DSTSSectionName, ServiceNameKey);
     this.TokenValidationServiceType = nativeConfig.ReadUnencryptedString(DSTSSectionName, TokenValidationServiceTypeKey);
 }
        public static bool GetValue(NativeConfigStore configStore)
        {
            ThrowIf.Null(configStore, "configStore");

            string value = configStore.ReadUnencryptedString("Common", "EnableEndpointV2");
            bool   flag  = string.IsNullOrEmpty(value) ? false : bool.Parse(value);

            return(flag);
        }
Esempio n. 9
0
        private string GetValueFromManifest(SettingsOverridesTypeSection section, string parameterName)
        {
            var parameter = section == null ? null : section.Parameter.FirstOrDefault(par => par.Name.Equals(parameterName, StringComparison.OrdinalIgnoreCase));
            var value     = parameter == null ? null : parameter.Value;

            if (parameter != null && parameter.IsEncrypted && value != null)
            {
                value = NativeConfigStore.DecryptText(value).ToString();
            }
            DeployerTrace.WriteInfo("Setup section, parameter {0}, has value {1}", parameterName, value);
            return(value);
        }
        public ClusterEndpointSecuritySettingsChangeNotifier(string endpoint, Action <string> updateReplicatorSettingsAction)
        {
            if (updateReplicatorSettingsAction == null)
            {
                throw new ArgumentNullException("updateReplicatorSettingsAction");
            }

            // null is allowed for endpoint
            this.endpoint = endpoint;
            this.updateReplicatorSettingsAction = updateReplicatorSettingsAction;
            this.configStore = NativeConfigStore.FabricGetConfigStore(this);
        }
        static BackupRestoreServiceConfig()
        {
            // Read value from config store
            var configStore = NativeConfigStore.FabricGetConfigStore();

            var apiTimeoutString = configStore.ReadUnencryptedString(BackupRestoreContants.BrsConfigSectionName, BackupRestoreContants.ApiTimeoutKeyName);

            ApiTimeout = String.IsNullOrEmpty(apiTimeoutString) ? BackupRestoreContants.ApiTimeoutInSecondsDefault : TimeSpan.FromSeconds(int.Parse(apiTimeoutString, CultureInfo.InvariantCulture));

            var workItemTimeoutString = configStore.ReadUnencryptedString(BackupRestoreContants.BrsConfigSectionName, WorkItemTimeoutKeyName);

            WorkItemTimeout = String.IsNullOrEmpty(workItemTimeoutString) ? DefaultWorkItemTimeout : TimeSpan.FromSeconds(int.Parse(workItemTimeoutString, CultureInfo.InvariantCulture));
        }
Esempio n. 12
0
        public static void InitializeFromConfigStore(bool forceUpdate = false)
        {
            lock (SyncLock)
            {
                if (configReader != null && !forceUpdate)
                {
                    return;
                }

                configReader = new ConfigReader(NativeConfigStore.FabricGetConfigStore(UpdateHandler));
            }

            InitializeFromConfigStore(configReader);
        }
Esempio n. 13
0
 private static void Ensure_IgnoreUpdateFailures()
 {
     if (!ignoreUpdateFailures)
     {
         lock (configLock)
         {
             if (!ignoreUpdateFailures)
             {
                 configStore = NativeConfigStore.FabricGetConfigStore();
                 configStore.IgnoreUpdateFailures = true;
                 ignoreUpdateFailures             = true;
             }
         }
     }
 }
Esempio n. 14
0
        private void LoadJiterConfig()
        {
            string jitterInSecondsString = null;

            try
            {
                var configStore = NativeConfigStore.FabricGetConfigStore();
                jitterInSecondsString = configStore.ReadUnencryptedString(BackupRestoreContants.BrsConfigSectionName, BackupRestoreContants.JitterInBackupsKeyName);
            }
            catch (Exception) { }

            var jitterInSeconds = String.IsNullOrEmpty(jitterInSecondsString) ? BackupRestoreContants.JitterInBackupsDefault : int.Parse(jitterInSecondsString, CultureInfo.InvariantCulture);

            this.jitter = Math.Abs(jitterInSeconds) * 1000;
        }
        public DsmsAzureStorageHelper(string sourceLocation)
        {
            var configStore   = NativeConfigStore.FabricGetConfigStore();
            var ApServiceName = configStore.ReadUnencryptedString(BackupRestoreContants.BrsConfigSectionName, BackupRestoreContants.DsmsAutopilotServiceNameKeyName);

            if (string.IsNullOrEmpty(ApServiceName))
            {
                CredentialManagementClient.Instance.ClientInitialize();
            }
            else
            {
                CredentialManagementClient.Instance.ClientInitializeForAp(ApServiceName);
            }

            this.dsmsCredentials = DsmsStorageCredentials.GetStorageCredentials(sourceLocation);
        }
Esempio n. 16
0
        private void UpdateTimers()
        {
            try
            {
                NativeConfigStore configStore = NativeConfigStore.FabricGetConfigStore();

                string goalStateFetchIntervalInSecondsString = configStore.ReadUnencryptedString(DMConstants.UpgradeOrchestrationServiceConfigSectionName, DMConstants.GoalStateFetchIntervalInSecondsName);
                int    goalStateFetchIntervalInSeconds;
                if (string.IsNullOrEmpty(goalStateFetchIntervalInSecondsString) || !int.TryParse(goalStateFetchIntervalInSecondsString, out goalStateFetchIntervalInSeconds))
                {
                    this.traceSource.WriteInfo(
                        TraceType,
                        "goalStateFetchIntervalInSeconds value invalid: \"{0}\". Defaulting to {1}.",
                        goalStateFetchIntervalInSecondsString,
                        DMConstants.DefaultGoalStateFetchIntervalInSeconds);
                    goalStateFetchIntervalInSeconds = DMConstants.DefaultGoalStateFetchIntervalInSeconds;
                }

                this.timerInterval = TimeSpan.FromSeconds(goalStateFetchIntervalInSeconds);

                string   goalStateProvisioningTimeOfDayString = configStore.ReadUnencryptedString(DMConstants.UpgradeOrchestrationServiceConfigSectionName, DMConstants.GoalStateProvisioningTimeOfDayName);
                TimeSpan goalStateProvisioningTimeOfDay;
                if (string.IsNullOrEmpty(goalStateProvisioningTimeOfDayString) || !TimeSpan.TryParse(goalStateProvisioningTimeOfDayString, out goalStateProvisioningTimeOfDay))
                {
                    this.traceSource.WriteInfo(
                        TraceType,
                        "goalStateProvisioningTimeOfDay value invalid: \"{0}\". Defaulting to {1}.",
                        goalStateProvisioningTimeOfDayString,
                        DMConstants.DefaultProvisioningTimeOfDay);
                    goalStateProvisioningTimeOfDay = DMConstants.DefaultProvisioningTimeOfDay;
                }

                this.provisioningTimeOfDay = goalStateProvisioningTimeOfDay;
                this.traceSource.WriteInfo(
                    TraceType,
                    "Timers set to: TimerInterval: {0}, ProvisioningTimeOfDay: {1}.",
                    this.timerInterval.ToString(),
                    this.provisioningTimeOfDay.ToString());
            }
            catch (Exception ex)
            {
                this.traceSource.WriteError(TraceType, "UpdateTimers threw {0}", ex.ToString());
                throw;
            }
        }
Esempio n. 17
0
        /// <summary>
        /// This is the main entry point for your service replica.
        /// This method executes when this replica of your service becomes primary and has write status.
        /// </summary>
        /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service replica.</param>
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            BackupRestoreTrace.TraceSource.WriteInfo(TraceType, "Enter RunAsync");
            FabricEvents.Events.BackupRestoreEnabled(this.Context.TraceId);

            // TODO: Ensure that the requests dont come in before we do the necessary initializations which are being done below
            await WorkItemHandler.StartAndScheduleWorkItemHandler(this);

            BackupRestoreTrace.TraceSource.WriteInfo(TraceType, "Registering config update handlers now");

            var configUpdateHandler = new ConfigUpdateHandler();

            configStore = NativeConfigStore.FabricGetConfigStore(configUpdateHandler);

            var certConfigHandler = new EncryptionCertConfigHandler(this.EncryptionCertUpdateCallbackAsync, this, cancellationToken);

            encryptionCertConfigStore = NativeConfigStore.FabricGetConfigStore(certConfigHandler);

            await certConfigHandler.InitializeAsync();

            Task <RetentionManager> retentionManagerTask = RetentionManager.CreateOrGetRetentionManager(this);

            BackupRestoreTrace.TraceSource.WriteInfo(TraceType, "Config update handlers registered");

            try
            {
                while (!configUpdateHandler.ProcessRecycleRequired)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    if (this.retentionManager == null && retentionManagerTask.IsCompleted)
                    {
                        this.retentionManager = retentionManagerTask.Result;
                    }
                    await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
                }

                // Process recycle is required, throwing exception from RunAsync
                throw new Exception("Process recycle needed.");
            }
            finally
            {
                this.retentionManager?.StopRetentionManager();
                BackupRestoreTrace.TraceSource.WriteInfo(TraceType, "Exit RunAsync");
            }
        }
Esempio n. 18
0
        private bool UseClusterSecuritySettingsForReplicator(IConfigSection configSection)
        {
            NativeConfigStore configStore = NativeConfigStore.FabricGetConfigStore();

            if (EnableEndpointV2Utility.GetValue(configStore))
            {
                TraceType.WriteInfo("Using cluster security settings for replicator because cluster setting EnableEndpointV2 is true");
                return(true);
            }

            if (this.ReadFactoryConfig(configSection, "UseClusterSecuritySettingsForReplicator", false))
            {
                TraceType.WriteInfo("Using cluster security settings for replicator because UseClusterSecuritySettingsForReplicator is true");
                return(true);
            }

            return(false);
        }
Esempio n. 19
0
        public static ITokenValidationProvider Create(string configSection)
        {
            var nativeConfig   = NativeConfigStore.FabricGetConfigStore(null);
            var providersValue = nativeConfig.ReadUnencryptedString(configSection, ProvidersConfigName);
            var providers      = providersValue.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            if (providers.Length > 1)
            {
                // TVS API currently has no way of specifying which provider should be
                // performing validation of the supplied token
                throw new FabricException(
                          "Multiple TVS validation providers not supported",
                          FabricErrorCode.InvalidConfiguration);
            }

            // DSTS is the default provider for backwards compatibility
            if (providers.Length < 1 || string.Equals(providers[0], DSTSProviderName, StringComparison.OrdinalIgnoreCase))
            {
                TokenValidationServiceFactory.TraceSource.WriteInfo(
                    TraceType,
                    "Creating {0} provider",
                    DSTSProviderName);

                return(new DSTSValidationProvider(configSection));
            }
            else if (string.Equals(providers[0], AADProviderName, StringComparison.OrdinalIgnoreCase))
            {
                TokenValidationServiceFactory.TraceSource.WriteInfo(
                    TraceType,
                    "Creating {0} provider",
                    AADProviderName);

                return(new AADValidationProvider(configSection));
            }
            else
            {
                throw new FabricException(string.Format(CultureInfo.InvariantCulture,
                                                        "Invalid TVS provider '{0}'. Valid providers are '{1}' and '{2}'",
                                                        providers[0],
                                                        DSTSProviderName,
                                                        AADProviderName),
                                          FabricErrorCode.InvalidConfiguration);
            }
        }
Esempio n. 20
0
        public DSTSObjectManager(string configSection)
        {
            this.configSection     = configSection;
            this.reloadLock        = new ReaderWriterLockSlim();
            this.configStore       = NativeConfigStore.FabricGetConfigStore(this);
            this.claimsAuthEnabled = false;

            try
            {
                this.InitializeDSTSObjects();
            }
            catch (Exception e)
            {
                TokenValidationServiceFactory.TraceSource.WriteError(DSTSObjectManager.TraceType,
                                                                     "Failed to update DSTSObjects due to exception {0}, {1}",
                                                                     e.GetType(),
                                                                     e.Message);
                throw;
            }
        }
Esempio n. 21
0
        public static void Main(string[] args)
        {
#if !DotNetCoreClr
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
#endif

            using (FabricRuntime fabricRuntime = FabricRuntime.Create())
            {
                ServiceRuntime.RegisterServiceAsync("EventStoreServiceType", context =>
                                                    new EventStoreService(
                                                        context,
                                                        NativeConfigStore.FabricGetConfigStore().ReadUnencryptedString(
                                                            "FabricNode",
                                                            "EventStoreServiceReplicatorAddress")))
                .GetAwaiter()
                .GetResult();

                Thread.Sleep(Timeout.Infinite);
            }
        }
Esempio n. 22
0
        public static ServiceFactory CreateAndRegister()
        {
            try
            {
                IInfrastructureAgentWrapper agent = new InfrastructureAgentWrapper();

                var configUpdateHandler       = new FactoryConfigUpdateHandler();
                NativeConfigStore configStore = NativeConfigStore.FabricGetConfigStore(configUpdateHandler);

                ServiceFactory factory = new ServiceFactory(agent, configStore, null, configUpdateHandler);

                agent.RegisterInfrastructureServiceFactory(factory);

                return(factory);
            }
            catch (Exception ex)
            {
                TraceType.WriteError("Error registering infrastructure service factory. Cannot continue further. Exception: {0}", ex);
                throw;
            }
        }
Esempio n. 23
0
        internal static string GetGoalStateUri()
        {
            string goalStateUriStr = null;

            /* Test code relies on the settings present in ClusterSettings.json for deployment of a specific version.
             * We need this check for the test code because certain APIs will be invoked before the cluster is even up. */
            string clusterSettingsFilepath = StandaloneUtility.FindFabricResourceFile(DMConstants.ClusterSettingsFileName);

            if (!string.IsNullOrEmpty(clusterSettingsFilepath))
            {
                StandAloneClusterManifestSettings standAloneClusterManifestSettings = JsonConvert.DeserializeObject <StandAloneClusterManifestSettings>(File.ReadAllText(clusterSettingsFilepath));
                if (standAloneClusterManifestSettings.CommonClusterSettings != null && standAloneClusterManifestSettings.CommonClusterSettings.Section != null)
                {
                    SettingsTypeSection settings = standAloneClusterManifestSettings.CommonClusterSettings.Section.ToList().SingleOrDefault(
                        section => section.Name == DMConstants.UpgradeOrchestrationServiceConfigSectionName);
                    if (settings != null)
                    {
                        SettingsTypeSectionParameter goalStatePathParam = settings.Parameter.ToList().SingleOrDefault(param => param.Name == DMConstants.GoalStateFileUrlName);
                        if (goalStatePathParam != null)
                        {
                            goalStateUriStr = goalStatePathParam.Value;
                        }
                    }
                }
            }

            // Check the native config store before using default location. The GoalStateFileUrl may have been overridden by the user.
            if (string.IsNullOrEmpty(goalStateUriStr))
            {
                NativeConfigStore configStore = NativeConfigStore.FabricGetConfigStore();
                goalStateUriStr = configStore.ReadUnencryptedString(DMConstants.UpgradeOrchestrationServiceConfigSectionName, DMConstants.GoalStateFileUrlName);
            }

            if (string.IsNullOrEmpty(goalStateUriStr))
            {
                goalStateUriStr = DMConstants.DefaultGoalStateFileUrl;
            }

            return(goalStateUriStr);
        }
Esempio n. 24
0
        private Task InitClusterAnalysisEngineAsync(FabricClient fabricClient, NativeConfigStore configStore, CancellationToken cancellationToken)
        {
#if DotNetCoreClr
            TestabilityTrace.TraceSource.WriteInfo(FaultAnalysisServiceTraceType, "Skipping Cluster Analysis in .Net Core environment");
            return(Task.FromResult(true));
#else
            string clusterAnalysisEnabledAsString = configStore.ReadUnencryptedString(FASConstants.FaultAnalysisServiceConfigSectionName, ClusterAnalysisEnabledConfig);
            if (string.IsNullOrWhiteSpace(clusterAnalysisEnabledAsString))
            {
                TestabilityTrace.TraceSource.WriteWarning(FaultAnalysisServiceTraceType, "ClusterAnalysisEnabled feature Flag is Null/Empty. Skipping Cluster Analysis.");
                return(Task.FromResult(true));
            }

            bool clusterAnalysisEnabled = false;
            if (!bool.TryParse(clusterAnalysisEnabledAsString, out clusterAnalysisEnabled))
            {
                TestabilityTrace.TraceSource.WriteInfo(FaultAnalysisServiceTraceType, "ClusterAnalysisConfig : {0} Couldn't be parsed. Skipping Cluster Analysis.", clusterAnalysisEnabledAsString);
                clusterAnalysisEnabled = false;
            }

            if (!clusterAnalysisEnabled)
            {
                TestabilityTrace.TraceSource.WriteInfo(FaultAnalysisServiceTraceType, "Cluster Anaysis Feature Status is Disabled");
                return(Task.FromResult(true));
            }

            TestabilityTrace.TraceSource.WriteInfo(FaultAnalysisServiceTraceType, "Launching Cluster Analysis");
            this.clusterAnalysisApiHandler = new System.Fabric.FaultAnalysis.Service.ClusterAnalysis.ClusterAnalysisApiHandler(this.StateManager, fabricClient, cancellationToken);

            try
            {
                return(this.clusterAnalysisApiHandler.InternalLaunchAsync(cancellationToken));
            }
            catch (Exception e)
            {
                TestabilityTrace.TraceSource.WriteError(FaultAnalysisServiceTraceType, "Exception Launching Cluster Analysis " + e);
                throw;
            }
#endif
        }
Esempio n. 25
0
        internal void LoadSettings(NativeConfigStore nativeConfig)
        {
            this.LinuxProxyImageName        = nativeConfig.ReadUnencryptedString(this.GRMSectionName, LinuxProxyImageNameKey);
            this.WindowsProxyImageName      = nativeConfig.ReadUnencryptedString(this.GRMSectionName, WindowsProxyImageNameKey);
            this.ProxyReplicaCount          = nativeConfig.ReadUnencryptedString(this.GRMSectionName, ProxyReplicaCountKey);
            this.ImageStoreConnectionString = nativeConfig.ReadUnencryptedString("Management", ImageStoreConnectionStringKey);
            this.IPProviderEnabled          = nativeConfig.ReadUnencryptedBool("Hosting", IPProviderEnabledKey, GatewayResourceManagerTrace.TraceSource, Program.TraceType, false);
            this.LocalNatIPProviderEnabled  = nativeConfig.ReadUnencryptedBool("Hosting", LocalNatIPProviderEnabledKey, GatewayResourceManagerTrace.TraceSource, Program.TraceType, false);
            this.IsolatedNetworkSetup       = nativeConfig.ReadUnencryptedBool("Setup", IsolatedNetworkSetupKey, GatewayResourceManagerTrace.TraceSource, Program.TraceType, false);
            this.ContainerNetworkSetup      = nativeConfig.ReadUnencryptedBool("Setup", ContainerNetworkSetupKey, GatewayResourceManagerTrace.TraceSource, Program.TraceType, false);

            var proxyCPUCores = nativeConfig.ReadUnencryptedString(this.GRMSectionName, ProxyCPUCoresKey);

            this.ProxyCPUCores = string.IsNullOrEmpty(proxyCPUCores) ? ProxyCPUCoresDefault : proxyCPUCores;

            var proxyCreateToReadyTimeoutInMinutes = nativeConfig.ReadUnencryptedString(this.GRMSectionName, ProxyCreateToReadyTimeoutInMinutesKey);

            this.ProxyCreateToReadyTimeoutInMinutes = string.IsNullOrEmpty(proxyCreateToReadyTimeoutInMinutes) ? ProxyCreateToReadyTimeoutInMinutesDefault : TimeSpan.FromMinutes(int.Parse(proxyCreateToReadyTimeoutInMinutes));

            try
            {
                this.ClientCertThumbprints = nativeConfig.ReadUnencryptedString("Security", ClientCertThumbprintsKey);
            }
            catch (Exception)
            {
                this.ClientCertThumbprints = string.Empty;
            }

            try
            {
                this.ClusterCertThumbprints = nativeConfig.ReadUnencryptedString("Security", ClusterCertThumbprintsKey);
            }
            catch (Exception)
            {
                this.ClusterCertThumbprints = string.Empty;
            }
        }
Esempio n. 26
0
        private WindowsIdentity GetIdentityToImpersonate()
        {
            WindowsIdentity identity = null;
            if (this.accessInfo.AccountPasswordIsEncrypted)
            {
                SecureString password = NativeConfigStore.DecryptText(this.accessInfo.AccountPassword);

                identity = AccountHelper.CreateWindowsIdentity(
                    this.accessInfo.UserName,
                    this.accessInfo.DomainName,
                    password,
                    FileShareAccessAccountType.ManagedServiceAccount == this.accessInfo.AccountType);
            }
            else
            {
                identity = AccountHelper.CreateWindowsIdentity(
                    this.accessInfo.UserName,
                    this.accessInfo.DomainName,
                    this.accessInfo.AccountPassword,
                    FileShareAccessAccountType.ManagedServiceAccount == this.accessInfo.AccountType);
            }

            return identity;
        }
        private UpgradeSystemService(
            string workingDirectory,
            Guid partitionId)
            : base(
                workingDirectory,     // (V2 only)
                DatabaseSubDirectory, // (V2 only)
                DatabaseFileName,     // (both V1 and V2)
                partitionId)          // shared log ID (V2 only)
        {
            this.cancellationTokenSource = null;

            this.configStore      = NativeConfigStore.FabricGetConfigStore();
            this.enableEndpointV2 = EnableEndpointV2Utility.GetValue(configStore);

            this.replicatorAddress = GetReplicatorAddress();
            Trace.WriteInfo(TraceType, "Read UpgradeServiceReplicatorAddress={0}", this.replicatorAddress);

            if (this.enableEndpointV2)
            {
                this.clusterEndpointSecuritySettingsChangeNotifier = new ClusterEndpointSecuritySettingsChangeNotifier(
                    this.replicatorAddress,
                    this.UpdateReplicatorSettingsOnConfigChange);
            }
        }
Esempio n. 28
0
 internal static void InitializeConfigStore()
 {
     configStore = NativeConfigStore.FabricGetConfigStore();
     return;
 }
Esempio n. 29
0
 static ClusterSettingsReader()
 {
     configStore = NativeConfigStore.FabricGetConfigStore();
 }
Esempio n. 30
0
        public static AzureTableConsumer[] GetEnabledAzureTableConsumersSettings()
        {
            var result    = new List <AzureTableConsumer>();
            var consumers = GetDiagnosticsConsumersNames();

            foreach (var consumer in consumers)
            {
                bool isEncrypted;
                AzureConsumerType consumerType;
                var consumerTypeString = configStore.ReadString(
                    consumer,
                    ReaderConstants.ClusterSettings.ConsumerType,
                    out isEncrypted);

                if (consumerTypeString != QueryableConsumerIdentifier &&
                    consumerTypeString != OperationalConsumerIdentifier)
                {
                    continue;
                }

                if (consumerTypeString == QueryableConsumerIdentifier)
                {
                    consumerType = AzureConsumerType.Query;
                }
                else
                {
                    consumerType = AzureConsumerType.Operational;
                }

                bool isConnectionStringEncrypted;
                var  tablesPrefix = configStore.ReadString(
                    consumer,
                    ReaderConstants.ClusterSettings.TableNamePrefix,
                    out isEncrypted);

                var connectionString = configStore.ReadString(
                    consumer,
                    ReaderConstants.ClusterSettings.StoreConnectionString,
                    out isConnectionStringEncrypted);

                var isEnabled = configStore.ReadString(
                    consumer,
                    ReaderConstants.ClusterSettings.IsEnabled,
                    out isEncrypted);

                if (string.IsNullOrEmpty(tablesPrefix) || string.IsNullOrEmpty(connectionString))
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(isEnabled) && !bool.Parse(isEnabled))
                {
                    continue;
                }

                if (isConnectionStringEncrypted)
                {
                    var secureString    = NativeConfigStore.DecryptText(connectionString);
                    var secureCharArray = FabricValidatorUtility.SecureStringToCharArray(secureString);
                    connectionString = new string(secureCharArray);
                }


                result.Add(new AzureTableConsumer(consumerType, tablesPrefix, connectionString));
            }

            return(result.ToArray());
        }