Exemple #1
0
        /// <summary>
        /// Check which groups in created sessions containers (GroupBoxes) are part
        /// of private keys setup. If group is part of PK setup change properties
        /// of password textboxes.
        /// Calls IsGroupBetweenPrivateKeys().
        /// </summary>
        public void DetermineIfSessionGroupIsPasswordLess(List <GroupBox> containers_list)
        {
            GetSavedSessions     saved_data  = new GetSavedSessions();
            SavedPrivatekeysInfo privatekeys = null;

            if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                                         "PuTTYStorm", "privatekeys.xml")))
            {
                privatekeys = saved_data.get_PrivateKeys();
            }
            else
            {
                return;
            }

            foreach (GroupBox container in containers_list)
            {
                string  group            = null;
                string  sub_group        = null;
                TextBox password_textbox = null;

                foreach (Control control in container.Controls)
                {
                    if (control.Name == "password_textbox")
                    {
                        password_textbox = (TextBox)control;
                    }

                    if (control.Name == "combobox")
                    {
                        group = control.Text;
                    }

                    if (control.Name == "sub_groups_combobox")
                    {
                        sub_group = control.Text;
                    }
                }
                if ((IsGroupBetweenPrivateKeys(privatekeys, group)) || (IsGroupBetweenPrivateKeys(privatekeys, sub_group)))
                {
                    password_textbox.ReadOnly              = true;
                    password_textbox.BackColor             = System.Drawing.Color.White;
                    password_textbox.ForeColor             = Color.SlateGray;
                    password_textbox.UseSystemPasswordChar = false;
                    password_textbox.Text = "PASSWORDLESS";
                }
                else
                {
                    if (password_textbox.Text == "PASSWORDLESS")
                    {
                        password_textbox.ReadOnly              = false;
                        password_textbox.BackColor             = System.Drawing.Color.White;
                        password_textbox.ForeColor             = Color.Black;
                        password_textbox.UseSystemPasswordChar = true;
                        password_textbox.Text = "";
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Initialize PuTTY STORM sessions form (Form2) and register hotkeys for
        /// easy and fast swithing between TabPages.
        /// </summary>
        public SessionsForm(List <ProcessInfo> _my_ProcessInfo_List_TC_1, TabControl _tabcontrol1, TabControl _tabcontrol2,
                            SplitContainer _SessionsSplitContainer, List <GroupBox> _containers_list, GlobalHotKeysWorker _TabPagesForwardGlobalHotKeyWorker,
                            GlobalHotKeysWorker _TabPagesBackwardGlobalHotKeyWorker, GlobalHotKeysWorker _SplitScreenGlobalHotKeyWorker,
                            GlobalHotKeysWorker _SFTPManagerGlobalHotKeyWorker, GlobalHotKeysWorker _KotarakGlobalHotKeyWorker)
        {
            this.tabcontrol1 = _tabcontrol1;
            this.tabcontrol2 = _tabcontrol2;
            this.my_ProcessInfo_List_TC_1 = _my_ProcessInfo_List_TC_1;
            this.SessionsSplitContainer   = _SessionsSplitContainer;
            this.containers_list          = _containers_list;

            // GlobalHotKeys Configuration settings
            tabPagesForwardGlobalHotKeySettings  = new TabPagesForwardGlobalHotKeySettings();
            tabPagesbackwardGlobalHotKeySettings = new TabPagesBackwardGlobalHotKeySettings();
            splitScreenGlobalHotKeySettings      = new SplitScreenGlobalHotKeySettings();
            sftpManagerGlobalHotKeySettings      = new SFTPManagerGlobalHotKeySettings();
            kotarakGlobalHotKeySettings          = new KotarakGlobalHotKeySettings();

            // GlobalHotKeys registration
            this.TabPagesForwardGlobalHotKeyWorker  = _TabPagesForwardGlobalHotKeyWorker;
            this.TabPagesBackwardGlobalHotKeyWorker = _TabPagesBackwardGlobalHotKeyWorker;
            this.SplitScreenGlobalHotKeyWorker      = _SplitScreenGlobalHotKeyWorker;
            this.SFTPManagerGlobalHotKeyWorker      = _SFTPManagerGlobalHotKeyWorker;
            this.KotarakGlobalHotKeyWorker          = _KotarakGlobalHotKeyWorker;

            saved_data     = new GetSavedSessions();
            IsPasswordLess = new PasswordLess();

            // Initialize GlobalHotKeys to the default values if config is empty (application first run)!
            GlobalHotKeysFirstStart();

            // Register GlobalHotKeys
            this.TabPagesForwardGlobalHotKeyWorker.Handle = this.Handle;
            this.TabPagesForwardGlobalHotKeyWorker.RegisterGlobalHotKey((int)GlobalHotKeysManager.ConvertFromStringToKey(tabPagesForwardGlobalHotKeySettings.key),
                                                                        tabPagesForwardGlobalHotKeySettings.modifier);

            this.TabPagesBackwardGlobalHotKeyWorker.Handle = this.Handle;
            this.TabPagesBackwardGlobalHotKeyWorker.RegisterGlobalHotKey((int)GlobalHotKeysManager.ConvertFromStringToKey(tabPagesbackwardGlobalHotKeySettings.key),
                                                                         tabPagesbackwardGlobalHotKeySettings.modifier);

            this.SplitScreenGlobalHotKeyWorker.Handle = this.Handle;
            this.SplitScreenGlobalHotKeyWorker.RegisterGlobalHotKey((int)GlobalHotKeysManager.ConvertFromStringToKey(splitScreenGlobalHotKeySettings.key),
                                                                    splitScreenGlobalHotKeySettings.modifier);

            this.SFTPManagerGlobalHotKeyWorker.Handle = this.Handle;
            this.SFTPManagerGlobalHotKeyWorker.RegisterGlobalHotKey((int)GlobalHotKeysManager.ConvertFromStringToKey(sftpManagerGlobalHotKeySettings.key),
                                                                    sftpManagerGlobalHotKeySettings.modifier);

            this.KotarakGlobalHotKeyWorker.Handle = this.Handle;
            this.KotarakGlobalHotKeyWorker.RegisterGlobalHotKey((int)GlobalHotKeysManager.ConvertFromStringToKey(kotarakGlobalHotKeySettings.key),
                                                                kotarakGlobalHotKeySettings.modifier);


            WindowEvents = new GlobalWindowEvents();
            SessionsForm.WindowEvents.SystemSwitch += new EventHandler <GlobalWindowEventArgs>(OnSystemSwitch);
        }
Exemple #3
0
        /// <summary>
        /// Save private keys to the privatekeys.xml configuration file.
        /// </summary>
        public void Save_PrivateKeys(List <Panel> PrivateKeys)
        {
            String filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                                           "PuTTYStorm", "privatekeys.xml");

            if (!Directory.Exists(Path.Combine(Environment.GetFolderPath
                                                   (Environment.SpecialFolder.MyDocuments), "PuTTYStorm")))
            {
                Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath
                                                           (Environment.SpecialFolder.MyDocuments), "PuTTYStorm"));
            }

            using (XmlWriter writer = XmlWriter.Create(filePath))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("PrivateKeys");

                foreach (Panel container in PrivateKeys)
                {
                    string pk_name  = null;
                    string pk_type  = null;
                    string pk_group = null;
                    string pk_pwd   = null;

                    foreach (Control control in container.Controls)
                    {
                        if (control.Name == "pk_name_label")
                        {
                            pk_name = control.Text;
                        }

                        if (control.Name == "pk_type_label")
                        {
                            pk_type = control.Text.Replace("Type: ", string.Empty);
                        }

                        if (control.Name == "pk_group_label")
                        {
                            pk_group = control.Text.Replace("Group: ", string.Empty);
                        }

                        if (control.Name == "private_keys_hidden_passphrase_textbox")
                        {
                            pk_pwd = control.Text;
                        }
                    }

                    if (pk_name != "")
                    {
                        writer.WriteStartElement("PrivateKey");

                        writer.WriteElementString("name", pk_name);
                        writer.WriteElementString("type", pk_type);
                        writer.WriteElementString("group", pk_group);
                        if (pk_pwd == "" || pk_pwd == null)
                        {
                            writer.WriteElementString("pwd", " ");
                        }
                        else
                        {
                            writer.WriteElementString("pwd", AESEncryptDecrypt.Encrypt(pk_pwd));
                        }

                        writer.WriteEndElement();
                    }
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
            }

            GetSavedSessions     saved_data  = new GetSavedSessions();
            SavedPrivatekeysInfo privatekeys = null;

            if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                                         "PuTTYStorm", "privatekeys.xml")))
            {
                privatekeys = saved_data.get_PrivateKeys();
            }

            if (privatekeys.names.Count != 0)
            {
                Backup_PrivateKeys();
            }
        }