private void menuItemExtract_Click(object sender, EventArgs e)
 {
     try {
         CmdManager.ExecuteCommand("tls\\ResourcesExtract\\ResourcesExtract.exe");
     }
     catch (Exception ex) {
         MessageBox.Show($"Impossible de démarrer le programme: {ex.Message}", "Erreur",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void RunProgram(Item i)
 {
     try {
         CmdManager.ExecuteCommand(i.Target);
         if (settings.hideAfterLaunch)
         {
             Hide();
         }
     }
     catch (Exception e) {
         MessageBox.Show($"Impossible de démarrer le programme: {e.Message}", "Erreur",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public bool PublishATMCertificate()
        {
            string username = Formatter.ParseName(Thread.CurrentPrincipal.Identity.Name);

            if (Thread.CurrentPrincipal.IsInRole("ATMGroup"))
            {
                // generisanje pin koda za klijenta
                Random       rand     = new Random();
                string       password = (rand.Next(1000, 9999)).ToString();
                SecureString pin      = new NetworkCredential("", password).SecurePassword;

                string CA = "SmartCardCA";

                Console.WriteLine($"Generated password is: {password}. Please use it for registration.\nPress any key to continue");

                // klijentski sertifikat
                //string path = @"C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x86";
                string path = @"C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x86";

                string cmd = $"makecert -sv {username}.pvk -iv {CA}.pvk -n \"CN={username}\" -pe -ic {CA}.cer {username}.cer -sr localmachine -ss My -sky exchange";
                cmd = cmd.Replace(@"\", "");
                CmdManager.ExecuteCommand(path, cmd);
                CmdManager.ExecuteCommand(path, $"pvk2pfx.exe /pvk {username}.pvk /pi {password} /spc {username}.cer /pfx {username}.pfx");
                //CmdManager.ExecuteCommand(path, $"CertMgr.exe /add {username}.cer /s /r localmachine personal");   // DA LI TREBA. ovo personal treba menjati TRUSTED PEOPLE KAD BUDE NA VISE KOMPOVA

                // klijentski sertifikat za potpis
                CmdManager.ExecuteCommand(path, $"makecert -sv {username}Sign.pvk -iv {CA}.pvk -n \"CN = {username}Sign\" -pe -ic {CA}.cer {username}Sign.cer -sr localmachine -ss My -sky signature");
                CmdManager.ExecuteCommand(path, $"pvk2pfx.exe /pvk {username}Sign.pvk /pi {password} /spc {username}Sign.cer /pfx {username}Sign.pfx");
                //CmdManager.ExecuteCommand(path, $"CertMgr.exe /add {username}Sign.cer /s /r localmachine personal");   // DA LI TREBA. ovo personal treba menjati

                path = @"C:\Program Files (x86)\Windows Resource Kits\Tools";
                CmdManager.ExecuteCommand(path, $@"winhttpcertcfg -g -c LOCAL_MACHINE\My -s {username} -a {username}");
                CmdManager.ExecuteCommand(path, $@"winhttpcertcfg -g -c LOCAL_MACHINE\My -s {username}Sign -a {username}");

                // logovanje uspesnog izdavanja nove smart kartice
                SmartCardServiceLogger scsLogger = new SmartCardServiceLogger();
                scsLogger.WriteInformation($"SCS has successfully published new smart card for client {username}.");

                return(true);
            }
            else
            {
                return(false);
            }
        }