public override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            var settingsForThisSection = windowsFabricSettings.GetSection(this.SectionName);

            ValueValidator.VerifyIntValueGreaterThanInput(settingsForThisSection, FabricValidatorConstants.ParameterNames.TargetReplicaSetSize, 0, SectionName);
            ValueValidator.VerifyIntValueGreaterThanInput(settingsForThisSection, FabricValidatorConstants.ParameterNames.MinReplicaSetSize, 0, SectionName);
            ValueValidator.VerifyFirstIntParameterGreaterThanOrEqualToSecondIntParameter(settingsForThisSection, FabricValidatorConstants.ParameterNames.TargetReplicaSetSize, FabricValidatorConstants.ParameterNames.MinReplicaSetSize, SectionName);
            FabricValidatorUtility.ValidateExpression(settingsForThisSection, FabricValidatorConstants.ParameterNames.PlacementConstraints);
        }
        public override void ValidateConfiguration(WindowsFabricSettings windowsFabricSettings)
        {
            var settingsForThisSection = windowsFabricSettings.GetSection(this.SectionName);

            if (settingsForThisSection.ContainsKey(FabricValidatorConstants.ParameterNames.PlacementConstraints))
            {
                FabricValidatorUtility.ValidateExpression(settingsForThisSection, FabricValidatorConstants.ParameterNames.PlacementConstraints);
            }
        }
Exemple #3
0
        public void ValidateSettings()
        {
            if (this.allTVSSettings.Count > 0)
            {
                this.IsTVSEnabled = true;

                if (!this.runAsPolicyEnabled)
                {
                    throw new ArgumentException(
                              string.Format(
                                  "RunAsPolicyEnabled should be set to true when enabling TokenValidationService"));
                }

                foreach (Dictionary <string, WindowsFabricSettings.SettingsValue> tvsSettings in this.allTVSSettings.Values)
                {
                    bool hasDSTSProvider = true;

                    if (tvsSettings.ContainsKey(FabricValidatorConstants.ParameterNames.Providers))
                    {
                        var providers = tvsSettings[FabricValidatorConstants.ParameterNames.Providers].Value.Split(
                            new char[] { ',' },
                            StringSplitOptions.RemoveEmptyEntries);

                        hasDSTSProvider = (providers.Length < 1);

                        if (!hasDSTSProvider)
                        {
                            foreach (var provider in providers)
                            {
                                if (string.Equals(provider, FabricValidatorConstants.Provider_DSTS, StringComparison.OrdinalIgnoreCase))
                                {
                                    hasDSTSProvider = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!hasDSTSProvider)
                    {
                        break;
                    }

                    if (!tvsSettings.ContainsKey(FabricValidatorConstants.ParameterNames.DSTSDnsName) ||
                        String.IsNullOrEmpty(tvsSettings[FabricValidatorConstants.ParameterNames.DSTSDnsName].Value))
                    {
                        throw new ArgumentException(
                                  string.Format(
                                      "ValidateTokenValidationServiceSettings failed as DSTSDnsName is not specified"));
                    }

                    if (!tvsSettings.ContainsKey(FabricValidatorConstants.ParameterNames.DSTSRealm) ||
                        String.IsNullOrEmpty(tvsSettings[FabricValidatorConstants.ParameterNames.DSTSRealm].Value))
                    {
                        throw new ArgumentException(
                                  string.Format(
                                      "ValidateTokenValidationServiceSettings failed as DSTSRealm is not specified"));
                    }

                    if (!tvsSettings.ContainsKey(FabricValidatorConstants.ParameterNames.DSTSWinFabServiceDnsName) ||
                        String.IsNullOrEmpty(tvsSettings[FabricValidatorConstants.ParameterNames.DSTSWinFabServiceDnsName].Value))
                    {
                        throw new ArgumentException(
                                  string.Format(
                                      "ValidateTokenValidationServiceSettings failed as DSTSMetadataServiceDnsName is not specified"));
                    }

                    if (!tvsSettings.ContainsKey(FabricValidatorConstants.ParameterNames.DSTSWinFabServiceName) ||
                        String.IsNullOrEmpty(tvsSettings[FabricValidatorConstants.ParameterNames.DSTSWinFabServiceName].Value))
                    {
                        throw new ArgumentException(
                                  string.Format(
                                      "ValidateTokenValidationServiceSettings failed as DSTSWinFabServiceName is not specified"));
                    }

                    if (tvsSettings.ContainsKey(FabricValidatorConstants.ParameterNames.PlacementConstraints))
                    {
                        FabricValidatorUtility.ValidateExpression(tvsSettings, FabricValidatorConstants.ParameterNames.PlacementConstraints);
                    }
                }

                //
                // Metadata endpoint is exposed via the httpgateway, so validate its settings according to TVS requirements.
                //
                ValidateHttpGatewaySettingsForTVS();
            }
        }