private void OpenInputPassphraseDialog(IPoderosaForm form, AgentPrivateKey key) { Debug.Assert(!form.AsForm().InvokeRequired); InputPassphraseDialog dlg = new InputPassphraseDialog(key); dlg.ShowDialog(form.AsForm()); }
private bool AskUserReliability(ISSHHostKeyInformationProvider info, string keystr, string message_text_id) { //比較結果に基づく処理 IPoderosaForm form = UsabilityPlugin.Instance.WindowManager.ActiveWindow; Debug.Assert(form.AsForm().InvokeRequired); //別スレッドで実行しているはず //fingerprint StringBuilder bld = new StringBuilder(); byte[] fingerprint = info.HostKeyFingerPrint; for (int i = 0; i < fingerprint.Length; i++) { if (bld.Length > 0) { bld.Append(':'); } bld.Append(fingerprint[i].ToString("x2")); } string message = String.Format("ssh hostkey fingerprint {0}\n\n{1}", bld.ToString(), UsabilityPlugin.Strings.GetString(message_text_id)); if (form.AskUserYesNo(message) == DialogResult.Yes) { Update(info, keystr, true); return(true); } else { return(false); } }
public SSH2UserAuthKey[] GetAvailableSSH2UserAuthKeys() { if (_loadRequiredFlag) { LoadKeys(); } IPoderosaForm form = UsabilityPlugin.Instance.WindowManager.ActiveWindow; List <SSH2UserAuthKey> keys = new List <SSH2UserAuthKey>(); foreach (AgentPrivateKey key in _keys) { if (key.Status == PrivateKeyStatus.OK) { keys.Add(key.Key); //有効であれば追加 } else if (key.Status != PrivateKeyStatus.FileError) //ファイルエラーだったら再試行はしない { if (key.GuessValidKeyFileOrWarn(form)) { form.AsForm().Invoke(new InputPassphraseDelegate(OpenInputPassphraseDialog), form, key); if (key.Status == PrivateKeyStatus.OK) { keys.Add(key.Key); } } } } return(keys.ToArray()); }
/// <summary> /// <ja>プラグイン実行</ja> /// </summary> public CommandResult InternalExecute(ICommandTarget target, params IAdaptable[] args) { IPoderosaView view; ITerminalSession session; // ビュー/セッション取得 if (!GetViewAndSession(target, out view, out session)) { return(CommandResult.Ignored); } // クリップボードデータ取得 var clipboardData = Clipboard.GetDataObject(); if (!clipboardData.GetDataPresent("Text")) { return(CommandResult.Ignored); } string data = (string)clipboardData.GetData("Text"); if (data == null) { return(CommandResult.Ignored); } // オプション取得 ExtendPasteOptions opt = ExtendPastePlugin.Instance.ExtendPasteOptionSupplier.OriginalOptions; // 改行存在チェック bool newLineFlg = ((data.IndexOfAny(new char[] { '\r', '\n' }) >= 0) || (data.Contains(Environment.NewLine))) ? true : false; // セッション名取得 //ITerminalSession sessionName = (ITerminalSession)view.Document.OwnerSession.GetAdapter(typeof(ITerminalSession)); // 確認ダイアログ表示 if (((opt.UseAction == UseAction.NewLine) && (newLineFlg)) || (opt.UseAction == UseAction.Always)) { IPoderosaForm poderosaForm = view.ParentForm; ExtendPasteDialog Form = new ExtendPasteDialog(data, newLineFlg, session.Caption); if (Form.ShowDialog(poderosaForm.AsForm()) != DialogResult.OK) { return(CommandResult.Ignored); } } // クリップボードデータ送信 StringReader reader = new StringReader(data); TerminalTransmission output = session.TerminalTransmission; output.SendTextStream(reader, data[data.Length - 1] == '\n', true); return(CommandResult.Succeeded); }