Beispiel #1
0
        public void Authentication_TestAuthentication_eCW()
        {
            //Run this test against a direct connection. eCW uses MD5 hash. If middle tier is enabled, the default User will have a wrong password.
            //Once we enable eCW, all requests will fail.
            RunTestsAgainstDirectConnection();
            //Turn eCW on for this test.
            OpenDentBusiness.Program p = Programs.GetCur(ProgramName.eClinicalWorks);
            p.Enabled = true;
            Programs.Update(p);
            Programs.RefreshCache();
            //List of hashes to try
            string[] hashStrings = new string[] {
                "MD5_ECW$$81dc9bdb52d04dc20036dbd8313ed055",
                "81dc9bdb52d04dc20036dbd8313ed055",
            };
            PasswordContainer passCont;

            //Test password decode.
            for (int i = 0; i < 2; i++)
            {
                passCont = Authentication.DecodePass(hashStrings[i]);
                Assert.AreEqual(HashTypes.MD5_ECW, passCont.HashType);
                Assert.AreEqual(hashStrings[1], passCont.Hash);
                Assert.AreEqual("", passCont.Salt);
                //Always compare to hashString[0] because decoding it should prepend "MD5_ECW$$" to the string.
                Assert.AreEqual(hashStrings[0], passCont.ToString());
            }
            //Turn eCW back off at the end of the test.
            p.Enabled = false;
            Programs.Update(p);
            Programs.RefreshCache();
            RevertMiddleTierSettingsIfNeeded();
        }
        private void CreateProgramLink()
        {
            if (!checkCreateProgLink.Checked)
            {
                return;
            }
            XmlDocument document = new XmlDocument();

            document.Load(textDir.Text + "\\FreeDentalConfig.xml");
            XPathNavigator Navigator = document.CreateNavigator();
            XPathNavigator nav;

            //Database type
            nav = Navigator.SelectSingleNode("//DatabaseType");
            DatabaseType dbType = DatabaseType.MySql;

            if (nav != null && nav.Value == "Oracle")
            {
                dbType = DatabaseType.Oracle;
            }
            //See if there's a DatabaseConnection
            nav = Navigator.SelectSingleNode("//DatabaseConnection");
            string serverName   = "";
            string databaseName = "";
            string userName     = "";
            string password     = "";

            if (nav != null)
            {
                //If there is a DatabaseConnection, then use it.
                serverName   = nav.SelectSingleNode("ComputerName").Value;
                databaseName = nav.SelectSingleNode("Database").Value;
                userName     = nav.SelectSingleNode("User").Value;
                password     = nav.SelectSingleNode("Password").Value;
                XPathNavigator encryptedPwdNode = nav.SelectSingleNode("MySQLPassHash");
                //If the Password node is empty, but there is a value in the MySQLPassHash node, decrypt the node value and use that instead
                string decryptedPwd;
                if (password == "" &&
                    encryptedPwdNode != null &&
                    encryptedPwdNode.Value != "" &&
                    CDT.Class1.Decrypt(encryptedPwdNode.Value, out decryptedPwd))
                {
                    //decrypted value could be an empty string, which means they don't have a password set, so textPassword will be an empty string
                    password = decryptedPwd;
                }
            }
            DataConnection dbCon = new DataConnection();

            dbCon.SetDb(serverName, databaseName, userName, password, "", "", dbType);
            if (ProgramC.GetListt().Count(x => x.ProgDesc == "Voice Command") > 0)           //Program link already exists
            {
                return;
            }
            OpenDentBusiness.Program prog = new OpenDentBusiness.Program();
            prog.ProgDesc      = "Voice Command";
            prog.Enabled       = true;
            prog.PluginDllName = "VoiceCommand.dll";
            Programs.Insert(prog);
        }