public PlatformConfigurationManager(IPlatformDatabaseConfiguration uiConfiguration)
            : base(uiConfiguration)
        {
            var config = (PlatformDatabaseConfiguration)uiConfiguration;

            config.SqlEngineEdition = ConfigurationManagerUtils.GetSqlEngineEdition(uiConfiguration);
        }
        public void CheckRoles(out string friendlyMessage, UserType user, string username)
        {
            try {
                bool hasLogRole = false, owner = false, canRead = false, canWrite = false;
                bool hasAccessAdmin = false, hasDDLAdmin = false, hasSecurityAdmin = false;
                var  config = ((TwoUserDatabaseConfiguration)uiConfiguration).RuntimeDatabaseConfiguration(user);
                try {
                    ConfigurationManagerUtils.GetDBUserRoles(username, ref hasLogRole, ref owner, ref canRead, ref canWrite, ref hasAccessAdmin, ref hasDDLAdmin, ref hasSecurityAdmin, config);
                    if (!owner)
                    {
                        if (!CheckDBRolesForUserType(user, username, canRead, canWrite, hasAccessAdmin, hasSecurityAdmin, hasDDLAdmin, hasLogRole, out friendlyMessage))
                        {
                            return;
                        }
                    }

                    if (!ConfigurationManagerUtils.CheckHubServerVersion(this, config, out friendlyMessage))
                    {
                        return;
                    }
                } catch {
                    friendlyMessage = "Database connection was successful.\r\n\r\nHowever, it was not possible to read the schema version. This may be because the schema has not been created yet.";
                    return;
                }
            } catch (Exception exception) {
                friendlyMessage = "Database connection was successful.\r\n\r\nHowever the following error ocurred while trying to read user permissions:\r\n\r\nFailed to retrieve user roles:\r\n\r\n" + exception.Message;
                return;
            }
            friendlyMessage = "Test completed successfully.";
        }
        public override void Pre_CreateOrUpgradePlatform()
        {
            NormalizeAllUsers();

            var elevated = (IElevatedUserConfiguration)uiConfiguration;

            var masterElevated = ConfigurationManagerUtils.ConfigurationToMaster(elevated);

            var runtimeElevated = (RuntimeDatabaseConfiguration)elevated.ElevatedRuntimeDatabaseConfiguration();

            bool isAzureDB = ConfigurationManagerUtils.IsDatabaseAzure(masterElevated);

            if (isAzureDB)
            {
                // On the unlikely scenario of an on-premise installation with Azure SQL,
                // we try to minimise the chance of timeouts.
                ConfigurationManagerUtils.QueryTimeout = 300;
            }

            ConfigurationManagerUtils.CheckIfUserHasNecessaryElevatedPermissions(masterElevated);

            if (!isAzureDB)
            {
                ConfigurationManagerUtils.CreateSqlServerCatalogIfDoesntExist(masterElevated, runtimeElevated.Catalog);
            }
            else
            {
                // We will not support automatically creating Azure databases.
                // An appropriate message is displayed.
                ConfigurationManagerUtils.CheckIfAzureDatabaseExists(masterElevated, runtimeElevated.Catalog);
            }

            ConfigurationManagerUtils.GrantUserPermissions((PlatformDatabaseConfiguration)uiConfiguration);
            ConfigurationManagerUtils.AddHubLogRole(runtimeElevated);
        }
Example #4
0
 public virtual void run()
 {
     if (this.showConfig)
     {
         ConfigurationManagerUtils.showConfig(this.cm);
     }
     if (this.showHTML)
     {
         try
         {
             HTMLDumper.showConfigAsHTML(this.cm, "foo.html");
         }
         catch (IOException ex)
         {
             this.logger.warning(new StringBuilder().append("Can't open ").append(this.htmlPath).append(' ').append(ex).toString());
         }
     }
     if (this.showGDL)
     {
         try
         {
             GDLDumper.showConfigAsGDL(this.cm, this.gdlPath);
         }
         catch (IOException ex4)
         {
             this.logger.warning(new StringBuilder().append("Can't open ").append(this.gdlPath).append(' ').append(ex4).toString());
         }
     }
     if (this.saveXML)
     {
         ConfigurationManager configurationManager = this.cm;
         ConfigurationManagerUtils.save(configurationManager, new File(this.xmlPath));
     }
 }
Example #5
0
        /*
         * (non-Javadoc)
         *
         * @see
         * edu.cmu.sphinx.util.props.Configurable#newProperties(edu.cmu.sphinx.util
         * .props.PropertySheet)
         */

        public override void NewProperties(PropertySheet ps)
        {
            base.NewProperties(ps);
            BaseUrl = ConfigurationManagerUtils.GetResource(PropBaseGrammarUrl, ps);
            //logger = ps.getLogger();
            GrammarName = ps.GetString(PropGrammarName);
            LoadGrammar = true;
        }
 private static void GrantPlatformPermissions(PlatformDatabaseConfiguration platformConfiguration)
 {
     try {
         ConfigurationManagerUtils.ExecuteStatements(
             platformConfiguration.ElevatedRuntimeDatabaseConfiguration(),
             GetGrantPlatformPermissionsStatements(platformConfiguration.RuntimeUser));
     } catch { }
 }
Example #7
0
        public override bool TestSessionConnection(out string friendlyMessage)
        {
            NormalizeWindowsUser();
            bool result = base.TestSessionConnection(out friendlyMessage);

            ConfigurationManagerUtils.CheckSessionRoles(sessionConfiguration, out friendlyMessage);
            return(result);
        }
Example #8
0
 public override void newProperties(PropertySheet ps)
 {
     base.newProperties(ps);
     this.logger      = ps.getLogger();
     this.logMath     = LogMath.getLogMath();
     this.baseURL     = ConfigurationManagerUtils.getResource("grammarLocation", ps);
     this.grammarName = ps.getString("grammarName");
     this.loadGrammar = true;
 }
Example #9
0
        public SessionConfigurationManager(ISessionDatabaseConfiguration sessionConfiguration)
            : base(sessionConfiguration)
        {
            PreProcessedStatements = new ArrayList();

            var config = (SessionDatabaseConfiguration)sessionConfiguration;

            config.SqlEngineEdition = ConfigurationManagerUtils.GetSqlEngineEdition(sessionConfiguration);
        }
        // TODO jmt: remove the systemDatabaseName parameter after we don't need synonyms anymore.
        public TwoUserDatabaseConfigurationManager(ISettableTwoUserDatabaseConfiguration uiConfiguration, IPlatformDatabaseConfiguration systemDatabaseconfig)
            : base(uiConfiguration)
        {
            extraTokens.Add("[SYSTEM_DB]", ((IDatabaseConfiguration)systemDatabaseconfig).Catalog);

            var config = (TwoUserDatabaseConfiguration)uiConfiguration;

            config.SqlEngineEdition = ConfigurationManagerUtils.GetSqlEngineEdition(uiConfiguration);
        }
Example #11
0
        /*
         * (non-Javadoc)
         *
         * @see
         * edu.cmu.sphinx.util.props.Configurable#newProperties(edu.cmu.sphinx.util
         * .props.PropertySheet)
         */

        public override void NewProperties(PropertySheet ps)
        {
            wordDictionaryFile   = ConfigurationManagerUtils.GetResource(PropDictionary, ps);
            fillerDictionaryFile = ConfigurationManagerUtils.GetResource(PropFillerDictionary, ps);
            addendaUrlList       = ps.GetResourceList(PropAddenda);
            wordReplacement      = ps.GetString(PropWordReplacement);
            unitManager          = (UnitManager)ps.GetComponent(PropUnitManager);
            g2pModelFile         = ConfigurationManagerUtils.GetResource(PropG2PModelPath, ps);
            g2pMaxPron           = ps.GetInt(PropG2PMaxPronunciations);
        }
Example #12
0
 public void NewProperties(PropertySheet ps)
 {
     Init(ConfigurationManagerUtils.GetResource(PropLocation, ps),
          ps.GetString(PropModel), ps.GetString(PropDataLocation),
          (UnitManager)ps.GetComponent(PropUnitManager),
          ps.GetFloat(PropMcFloor), ps.GetFloat(PropMwFloor),
          ps.GetFloat(PropVarianceFloor),
          ps.GetInt(PropTopn),
          ps.GetBoolean(PropUseCdUnits));
 }
        public override string GenerateSetupScript()
        {
            NormalizeAllUsers();

            //for P10 the setup script is going to be generated by the conf tool to avoid duplication

            string setupScript = ConfigurationManagerUtils.ReplaceTokens((TwoUserDatabaseConfiguration)uiConfiguration, ReadScriptFile(StreamForSetupScriptFile), extraTokens);

            return(setupScript);
        }
Example #14
0
        public virtual void newProperties(PropertySheet ps)
        {
            this.logger = ps.getLogger();
            if (this.allocated)
            {
                string text = "Can't change properties after allocation";

                throw new RuntimeException(text);
            }
            this.classDefsLocation = ConfigurationManagerUtils.getResource("classDefsLocation", ps);
        }
        public override bool TestLogConnection(out string friendlyMessage, Source source)
        {
            NormalizeLogUser();
            bool result = base.TestLogConnection(out friendlyMessage, source);

            if (result)
            {
                ConfigurationManagerUtils.CheckRoles(uiConfiguration, out friendlyMessage, source, User.Log, uiConfiguration.LogAuthenticationCredential.UserName);
            }
            return(result);
        }
        public override bool RequiresElevatedPrivilges()
        {
            try {
                RuntimeDatabaseConfiguration confAdmin = (RuntimeDatabaseConfiguration)uiConfiguration.RuntimeDatabaseConfiguration(Source.Services, User.Admin);

                return(ConfigurationManagerUtils.LoginExists(confAdmin, confAdmin.Username) == false ||
                       ConfigurationManagerUtils.DatabaseExists(confAdmin, confAdmin.Catalog) == false);
            } catch {
                return(base.RequiresElevatedPrivilges());
            }
        }
 public override void newProperties(PropertySheet ps)
 {
     this.logger               = ps.getLogger();
     this.wordDictionaryFile   = ConfigurationManagerUtils.getResource("dictionaryPath", ps);
     this.fillerDictionaryFile = ConfigurationManagerUtils.getResource("fillerPath", ps);
     this.addendaUrlList       = ps.getResourceList("addenda");
     this.wordReplacement      = ps.getString("wordReplacement");
     this.unitManager          = (UnitManager)ps.getComponent("unitManager");
     this.g2pModelFile         = ConfigurationManagerUtils.getResource("g2pModelPath", ps);
     this.g2pMaxPron           = ps.getInt("g2pMaxPron");
 }
 public string execute(CommandInterpreter commandInterpreter, string[] array)
 {
     if (array.Length != 4)
     {
         commandInterpreter.putResponse("Usage: set component property value");
     }
     else
     {
         ConfigurationManagerUtils.setProperty(this.this_0.cm, array[1], array[3], array[2]);
     }
     return("");
 }
        public override IEnumerable <Block> ExtraDatabaseStatements(Version currentModelVersion)
        {
            // Create an extra Block for the current version to add extra permissions to runtime user.
            var newBlock = new Block();

            newBlock.SetTagValue(Tag.END_IGNORING_BLOCK.ToString(), "");
            string runtimeuser = ((PlatformDatabaseConfiguration)uiConfiguration).RuntimeUser;

            ConfigurationManagerUtils.GetGrantRuntimePermissionsStatements(runtimeuser).Apply(statement => newBlock.AddStatement(statement));
            GetGrantPlatformPermissionsStatements(runtimeuser).Apply(statement => newBlock.AddStatement(statement));

            yield return(newBlock);
        }
 public string execute(CommandInterpreter commandInterpreter, string[] array)
 {
     if (array.Length != 2)
     {
         commandInterpreter.putResponse("Usage: save filename.xml");
     }
     else
     {
         ConfigurationManager cm = this.this_0.cm;
         ConfigurationManagerUtils.save(cm, new File(array[1]));
     }
     return("");
 }
Example #21
0
        public void CMU_ComponentProperty()
        {
            var configFile = new URL(Helper.FilesDirectory + "/util/props/ConfigurationManagerTest.testconfig.sxl");
            var cm         = new ConfigurationManager(configFile);

            const int newBeamWidth = 4711;

            ConfigurationManagerUtils.SetProperty(cm, "beamWidth", newBeamWidth.ToString(CultureInfo.InvariantCulture));

            var dummyComp = (DummyComp)cm.Lookup("duco");

            Assert.AreEqual(newBeamWidth, dummyComp.GetBeamWidth());
        }
        public override bool RequiresElevatedPrivilges()
        {
            try {
                RuntimeDatabaseConfiguration confAdmin   = (RuntimeDatabaseConfiguration)((TwoUserDatabaseConfiguration)uiConfiguration).RuntimeDatabaseConfiguration(UserType.Admin);
                RuntimeDatabaseConfiguration confRuntime = (RuntimeDatabaseConfiguration)((TwoUserDatabaseConfiguration)uiConfiguration).RuntimeDatabaseConfiguration(UserType.Runtime);

                return(ConfigurationManagerUtils.LoginExists(confAdmin, confAdmin.Username) == false ||
                       ConfigurationManagerUtils.LoginExists(confRuntime, confRuntime.Username) == false ||
                       ConfigurationManagerUtils.DatabaseExists(confAdmin, confAdmin.Catalog) == false);
            } catch {
                return(base.RequiresElevatedPrivilges());
            }
        }
Example #23
0
 /*
  * (non-Javadoc)
  * @see
  * edu.cmu.sphinx.util.props.Configurable#newProperties(edu.cmu.sphinx.
  * util.props.PropertySheet)
  */
 public override void NewProperties(PropertySheet ps)
 {
     Location                  = ConfigurationManagerUtils.GetResource(PropLocation, ps);
     NgramLogFile              = ps.GetString(PropQueryLogFile);
     NgramCacheSize            = ps.GetInt(PropNgramCacheSize);
     ClearCacheAfterUtterance  = ps.GetBoolean(PropClearCachesAfterUtterance);
     MaxDepth                  = ps.GetInt(PropMaxDepth);
     Dictionary                = (IDictionary)ps.GetComponent(PropDictionary);
     ApplyLanguageWeightAndWip = ps.GetBoolean(PropApplyLanguageWeightAndWip);
     LanguageWeight            = ps.GetFloat(PropLanguageWeight);
     Wip           = ps.GetDouble(PropWordInsertionProbability);
     UnigramWeight = ps.GetFloat(PropUnigramWeight);
     FullSmear     = ps.GetBoolean(PropFullSmear);
 }
        /// <summary>
        /// Replaces known tokens in the given statement
        /// </summary>
        /// <param name="statement"></param>
        /// <returns></returns>
        private string ReplaceTokens(string statement)
        {
            PlatformDatabaseConfiguration conf = (PlatformDatabaseConfiguration)uiConfiguration;
            const string TAG_LOGUSERNAME       = "******";
            const string TAG_LOGPASSWORD       = "******";

            var tokenMap = new Dictionary <string, string>()
            {
                { TAG_LOGUSERNAME, conf.LogUser },
                { TAG_LOGPASSWORD, conf.LogPassword },
            };

            return(ConfigurationManagerUtils.ReplaceTokens(conf, statement, tokenMap));
        }
Example #25
0
 public override void NewProperties(PropertySheet ps)
 {
     logMath                   = LogMath.GetLogMath();
     location                  = ConfigurationManagerUtils.GetResource(PropLocation, ps);
     ngramLogFile              = ps.GetString(PROP_QUERY_LOG_FILE);
     MaxDepth                  = ps.GetInt(LanguageModel.PropMaxDepth);
     ngramCacheSize            = ps.GetInt(PROP_NGRAM_CACHE_SIZE);
     clearCacheAfterUtterance  = ps.GetBoolean(PROP_CLEAR_CACHES_AFTER_UTTERANCE);
     dictionary                = (IDictionary)ps.GetComponent(PropDictionary);
     applyLanguageWeightAndWip = ps.GetBoolean(PROP_APPLY_LANGUAGE_WEIGHT_AND_WIP);
     languageWeight            = ps.GetFloat(PROP_LANGUAGE_WEIGHT);
     logWip        = logMath.LinearToLog(ps.GetDouble(PROP_WORD_INSERTION_PROBABILITY));
     unigramWeight = ps.GetFloat(PropUnigramWeight);
 }
 public override void newProperties(PropertySheet ps)
 {
     this.logger                    = ps.getLogger();
     this.logMath                   = LogMath.getLogMath();
     this.location                  = ConfigurationManagerUtils.getResource("location", ps);
     this.ngramLogFile              = ps.getString("queryLogFile");
     this.maxDepth                  = ps.getInt("maxDepth");
     this.ngramCacheSize            = ps.getInt("ngramCacheSize");
     this.clearCacheAfterUtterance  = ps.getBoolean("clearCachesAfterUtterance").booleanValue();
     this.dictionary                = (dictionary.Dictionary)ps.getComponent("dictionary");
     this.applyLanguageWeightAndWip = ps.getBoolean("applyLanguageWeightAndWip").booleanValue();
     this.languageWeight            = ps.getFloat("languageWeight");
     this.logWip                    = this.logMath.linearToLog(ps.getDouble("wordInsertionProbability"));
     this.unigramWeight             = ps.getFloat("unigramWeight");
 }
Example #27
0
        public override bool CheckDBRolesForUserType(UserType user, string username, bool canRead, bool canWrite, bool hasAccessAdmin, bool hasSecurityAdmin, bool hasDDLAdmin, bool hasLogRole, out string friendlyMessage)
        {
            friendlyMessage = "";

            switch (user)
            {
            case UserType.Admin:
                return(ConfigurationManagerUtils.CheckDBAdminRoles(username, hasAccessAdmin, hasSecurityAdmin, hasDDLAdmin, canRead, canWrite, out friendlyMessage));

            case UserType.Runtime:
                return(ConfigurationManagerUtils.CheckDBLogRoles(username, canRead, canWrite, hasLogRole, uiConfiguration.AuthenticationMode, out friendlyMessage));
            }

            return(true);
        }
        private void GrantPlatformDatabaseUserPermissions(PlatformDatabaseConfiguration dbConfig)
        {
            var configRuntime = dbConfig.ElevatedRuntimeDatabaseConfiguration();
            var configMaster  = ConfigurationManagerUtils.ConfigurationToMaster(dbConfig);
            var authType      = dbConfig.AuthenticationMode;

            // Create User

            if (ConfigurationManagerUtils.NeedsCreate(configMaster, configRuntime, dbConfig.AdminUser))
            {
                if (authType == AuthenticationType.Windows_Authentication)
                {
                    ConfigurationManagerUtils.AddIntegratedAuthLogin(configRuntime, dbConfig.AdminUser);
                }
                else
                {
                    ConfigurationManagerUtils.AddDBAuthLogin(configMaster, dbConfig.AdminUser, dbConfig.AdminPassword);
                }
            }

            if (ConfigurationManagerUtils.NeedsPermissionsForAdmin(configRuntime, dbConfig.AdminUser))
            {
                ConfigurationManagerUtils.AddAdminPermissions(configRuntime, dbConfig.AdminUser);
            }

            if (ConfigurationManagerUtils.NeedsCreate(configMaster, configRuntime, dbConfig.RuntimeUser))
            {
                if (authType == AuthenticationType.Windows_Authentication)
                {
                    ConfigurationManagerUtils.AddIntegratedAuthLogin(configRuntime, dbConfig.RuntimeUser);
                }
                else
                {
                    ConfigurationManagerUtils.AddDBAuthLogin(configMaster, dbConfig.RuntimeUser, dbConfig.RuntimePassword);
                }
            }

            if (ConfigurationManagerUtils.NeedsPermissionsForReadWrite(configRuntime, dbConfig.RuntimeUser, dbConfig.AuthenticationMode))
            {
                ConfigurationManagerUtils.AddReadWritePermissions(configRuntime, dbConfig.RuntimeUser);
            }

            try {
                ConfigurationManagerUtils.AddRuntimePermissionsAfterUpgradeScript(configRuntime, dbConfig.RuntimeUser);
            } catch { }

            GrantPlatformPermissions(dbConfig);
        }
Example #29
0
        public override void Pre_CreateOrUpgradeSession()
        {
            NormalizeWindowsUser();

            var elevated = (IElevatedUserConfiguration)sessionConfiguration;

            var masterElevated = ConfigurationManagerUtils.ConfigurationToMaster(elevated);

            var runtimeElevated = (RuntimeDatabaseConfiguration)elevated.ElevatedRuntimeDatabaseConfiguration();

            bool isAzureDB = ConfigurationManagerUtils.IsDatabaseAzure(masterElevated);

            if (isAzureDB)
            {
                // On the unlikely scenario of an on-premise installation with Azure SQL,
                // we try to minimise the chance of timeouts.
                ConfigurationManagerUtils.QueryTimeout = 300;
            }

            ConfigurationManagerUtils.CheckIfUserHasNecessaryElevatedPermissions(masterElevated);

            if (!isAzureDB)
            {
                ConfigurationManagerUtils.CreateSqlServerCatalogIfDoesntExist(masterElevated, runtimeElevated.Catalog);
            }
            else
            {
                // We will not support automatically creating Azure databases.
                // An appropriate message is displayed.
                ConfigurationManagerUtils.CheckIfAzureDatabaseExists(masterElevated, runtimeElevated.Catalog);
            }

            // Prepare statements
            PreProcessedStatements.Add(ConfigurationManagerUtils.GrantSessionUserPermissions(
                                           (SessionDatabaseConfiguration)sessionConfiguration,
                                           (PlatformDatabaseConfiguration)platformConfiguration));

            // Azure does not support changing the recovery model
            if (!isAzureDB)
            {
                try {
                    // Set database recovery model to Simple
                    ConfigurationManagerUtils.SetRecoveryModel(masterElevated, runtimeElevated.Catalog, "Simple");
                } catch (Exception exception) {
                    throw new ConfigurationOperationException("After the Configuration Tool closes, you must set the '" + runtimeElevated.Catalog + "' database recovery model to simple.", exception);
                }
            }
        }
 public string execute(CommandInterpreter commandInterpreter, string[] array)
 {
     if (array.Length < 2)
     {
         ConfigurationManagerUtils.showConfig(this.this_0.cm);
     }
     else
     {
         for (int i = 1; i < array.Length; i++)
         {
             string name = array[i];
             ConfigurationManagerUtils.showConfig(this.this_0.cm, name);
         }
     }
     return("");
 }