private static bool internalParse(String str, out PuttyOptions options)
 {
     options = new PuttyOptions();
     if (str == null)
     {
         return(false);
     }
     if (str.Trim(' ').Length == 0)
     {
         return(false);
     }
     String[] tokens = str.Split(';');
     foreach (String token in tokens)
     {
         if (token.Trim().StartsWith("key"))
         {
             options.KeyFilePath = token.Substring(token.IndexOf(':') + 1).Trim().Trim('\"');
         }
         else if (token.Contains(":"))
         {
             String[] optionNameValue = token.Split(':');
             if (optionNameValue.Length == 2 && optionNameValue[0].Trim().Equals("session"))
             {
                 options.SessionName = optionNameValue[1].Trim().Trim('\"');
             }
             else if (optionNameValue.Length == 2 && optionNameValue[0].Trim().Equals("port"))
             {
                 options.Port = int.Parse(optionNameValue[1].Trim());
             }
         }
     }
     return(true);
 }
        private ToolStripMenuItem createChangePasswordMenuItem(HostPwEntry hostPwEntry)
        {
            IPasswordChanger pwChanger = null;
            var hostTypeMapper         = new HostTypeMapper(new HostTypeSafeConverter());
            var hostType = hostTypeMapper.Get(hostPwEntry);

            if (hostType == HostType.ESXi && QuickConnectUtils.IsVSpherePowerCLIInstalled())
            {
                pwChanger = new ESXiPasswordChanger();
            }
            else if (hostType == HostType.Windows &&
                     !String.IsNullOrEmpty(this.Settings.PsPasswdPath) &&
                     File.Exists(this.Settings.PsPasswdPath) &&
                     PsPasswdWrapper.IsPsPasswdUtility(this.Settings.PsPasswdPath) &&
                     PsPasswdWrapper.IsSupportedVersion(this.Settings.PsPasswdPath)
                     )
            {
                pwChanger = new WindowsPasswordChanger(new PsPasswdWrapper(this.Settings.PsPasswdPath));
            }
            else if (hostType == HostType.Linux)
            {
                PuttyOptions puttyOptions = null;
                bool         success      = PuttyOptionsParser.TryParse(hostPwEntry.AdditionalOptions, out puttyOptions);
                // Disable change password menu item if authentication is done using SSH key file.
                if (!success || (success && !puttyOptions.HasKeyFile()))
                {
                    int?sshPort = null;
                    if (success)
                    {
                        sshPort = puttyOptions.Port;
                    }
                    pwChanger = new LinuxPasswordChanger()
                    {
                        SshPort = sshPort
                    };
                }
            }
            var menuItem = new ToolStripMenuItem()
            {
                Text    = ChangePasswordMenuItemText,
                Enabled = hostPwEntry.HasIPAddress && pwChanger != null
            };

            menuItem.Click += new EventHandler(
                delegate(object obj, EventArgs ev) {
                try {
                    var pwDatabase       = new PasswordDatabase(this.pluginHost.Database);
                    var pwChangerService = new PasswordChangerServiceWrapper(pwDatabase, pwChanger);
                    using (var formPasswordChange = new FormPasswordChanger(hostPwEntry, pwChangerService)) {
                        formPasswordChange.ShowDialog();
                    }
                }
                catch (Exception ex) {
                    log(ex);
                }
            }
                );
            return(menuItem);
        }
 public static bool TryParse(String str, out PuttyOptions options)
 {
     return(internalParse(str, out options));
 }