Beispiel #1
0
        public DatabaseConnectionInfo GetCcsOwnerConnectionDetails()
        {
            DatabaseConnectionInfo info       = null;
            OracleConnection       connection = new OracleConnection(ConnectionString);

            connection.Open();
            OracleCommand command = new OracleCommand();

            command.Connection  = connection;
            command.CommandText = string.Format("select server,port,schema,dbuser,dbuserpwd,auxinfo from databaseservice where servicetype = 'ORACLE' and rownum <= 1");
            command.CommandType = CommandType.Text;
            OracleDataReader dr = command.ExecuteReader();

            while (dr.Read())
            {
                info          = new DatabaseConnectionInfo();
                info.Host     = Conversion.ToString(dr["server"]);
                info.Port     = Conversion.ToString(dr["port"]);
                info.Schema   = Conversion.ToString(dr["schema"]);
                info.UserId   = Conversion.ToString(dr["dbuser"]);
                info.Password = Conversion.ToString(dr["dbuserpwd"]);
                info.Service  = Conversion.ToString(dr["auxinfo"]);
            }
            connection.Dispose();

            return(info);
        }
        private DatabaseConnectionInfo GetCcsOwnerDatabaseConfigurationInfo(DatabaseConnectionInfo pawnSecConnectionInfo)
        {
            Database database = new Database(pawnSecConnectionInfo.ConnectionString);
            DatabaseConnectionInfo encryptedInfo = database.GetCcsOwnerConnectionDetails();
            DatabaseConnectionInfo decryptedInfo = new DatabaseConnectionInfo();

            decryptedInfo.Host     = EncryptionUtil.Decrypt(encryptedInfo.Host, Resources.PublicKey, true);
            decryptedInfo.Password = EncryptionUtil.Decrypt(encryptedInfo.Password, Resources.PublicKey, true);
            decryptedInfo.Port     = EncryptionUtil.Decrypt(encryptedInfo.Port, Resources.PublicKey, true);
            decryptedInfo.Schema   = EncryptionUtil.Decrypt(encryptedInfo.Schema, Resources.PublicKey, true);
            decryptedInfo.Service  = EncryptionUtil.Decrypt(encryptedInfo.Service, Resources.PublicKey, true);
            decryptedInfo.UserId   = EncryptionUtil.Decrypt(encryptedInfo.UserId, Resources.PublicKey, true);

            return(decryptedInfo);
        }
        private DatabaseConnectionInfo GetPawnSecDatabaseConfigurationInfo(ClxApplication application, ConfigurationKey key)
        {
            string configValue = ConfigurationReader.GetInstance().GetConfigurationContents(application, key);

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(configValue);

            XmlNodeList list = xmlDocument.GetElementsByTagName("setting");

            DatabaseConnectionInfo info = new DatabaseConnectionInfo();

            foreach (XmlNode n in list)
            {
                string decryptedValue = EncryptionUtil.Decrypt(n.ChildNodes[0].InnerText, Resources.PrivateKey, true);

                switch (n.Attributes["name"].Value)
                {
                case "PawnSecDBUser":
                    info.UserId = decryptedValue;
                    break;

                case "PawnSecDBPassword":
                    info.Password = decryptedValue;
                    break;

                case "PawnSecDBSchema":
                    info.Schema = decryptedValue;
                    break;

                case "PawnSecDBPort":
                    info.Port = decryptedValue;
                    break;

                case "PawnSecDBHost":
                    info.Host = decryptedValue;
                    break;

                case "PawnSecDBService":
                    info.Service = decryptedValue;
                    break;
                }
            }

            return(info);
        }