📄 sshmenuhandlerfull.java
字号:
p = new Panel(new FlowLayout()); p.add(new Label("Have SecurID token ready when connecting")); authCP.add(p, "securid"); p = new Panel(new FlowLayout()); p.add(new Label("Have CryptoCard token ready when connecting")); authCP.add(p, "cryptocard"); p = new Panel(new FlowLayout()); p.add(new Label("TIS challenge/response will occur when connecting")); authCP.add(p, "tis"); p = new Panel(new FlowLayout()); p.add(new Label("Generic keyboard interactive authentication")); authCP.add(p, "kbd-interact"); return authCP; } private void checkSupportedByPeer() throws Exception { checkSupportedByPeer(SSH2Preferences.CIPHERS_C2S, choiceCipherC2S); checkSupportedByPeer(SSH2Preferences.CIPHERS_S2C, choiceCipherS2C); checkSupportedByPeer(SSH2Preferences.MACS_C2S, choiceMacC2S); checkSupportedByPeer(SSH2Preferences.MACS_S2C, choiceMacS2C); if((!choiceCompC2S.getSelectedItem().equals("none") && !client.transport.getPeerPreferences(). isSupported(SSH2Preferences.COMP_C2S, "zlib")) || (!choiceCompS2C.getSelectedItem().equals("none") && !client.transport.getPeerPreferences(). isSupported(SSH2Preferences.COMP_S2C, "zlib"))) { throw new Exception("Peer doesn't support 'zlib'"); } } private void checkSupportedByPeer(String type, Choice c) throws Exception { if(c.getSelectedIndex() == 0) { return; } String item = c.getSelectedItem(); if(!client.transport.getPeerPreferences().isSupported(type, item)) { throw new Exception("Peer doesn't support: " + item); } } private void updateChoices() { String auth = choiceAuthTyp.getSelectedItem(); authCL.show(authCP, auth); if(cbSaveAlias.getState()) { String t = textAlias.getText(); if(!textAlias.isEnabled() && (t == null || t.trim().length() == 0)) { String p = textPort.getText().trim(); textAlias.setText(textSrv.getText() + (p.equals("22") ? "" : ("_" + p))); textAlias.setEnabled(true); textAlias.requestFocus(); } } else { textAlias.setText(""); textAlias.setEnabled(false); } } Dialog currentTunnelsDialog = null; List currList; public final void currentTunnelsDialog() { if(currentTunnelsDialog == null) { currentTunnelsDialog = new Dialog(parent, "MindTerm - Currently Open Tunnels", false); AWTGridBagContainer grid = new AWTGridBagContainer(currentTunnelsDialog); Label label; Button b; label = new Label("Currently open tunnels:"); grid.add(label, 0, 2); grid.getConstraints().fill = GridBagConstraints.BOTH; currList = new List(8); grid.add(currList, 1, 10); Panel bp = new Panel(new FlowLayout()); bp.add(b = new Button("Close Tunnel")); b.addActionListener(new Actions(ACT_CLOSE_TUNNEL)); bp.add(b = new Button("Refresh")); b.addActionListener(new Actions(ACT_REFRESH)); bp.add(b = new Button("Close Dialog")); b.addActionListener(new AWTConvenience.CloseAction(currentTunnelsDialog)); grid.getConstraints().anchor = GridBagConstraints.CENTER; grid.add(bp, 2, GridBagConstraints.REMAINDER); currentTunnelsDialog.addWindowListener(new AWTConvenience.CloseAdapter(b)); AWTConvenience.setBackgroundOfChildren(currentTunnelsDialog); currentTunnelsDialog.setResizable(true); currentTunnelsDialog.pack(); } refreshCurrList(); AWTConvenience.placeDialog(currentTunnelsDialog); currList.requestFocus(); currentTunnelsDialog.setVisible(true); } void refreshCurrList() { currList.removeAll(); String[] l = client.listTunnels(); for(int i = 0; i < l.length; i++) { currList.add(l[i]); } if(l.length > 0) currList.select(0); } TunnelEditor localEdit = null; TunnelEditor remoteEdit = null; Dialog tunnelDialog = null; public final void advancedTunnelsDialog() { if(tunnelDialog == null) { tunnelDialog = new Dialog(parent, "MindTerm - Advanced Tunnels Setup", true); AWTGridBagContainer grid = new AWTGridBagContainer(tunnelDialog); grid.getConstraints().fill = GridBagConstraints.BOTH; grid.getConstraints().weightx = 1.0; grid.getConstraints().weighty = 1.0; localEdit = new TunnelEditor("Local: ([/plug/][<loc-host>:]<loc-port>:<rem-host>:<rem-port>)", new Actions(ACT_LOCALADD), new Actions(ACT_LOCALDEL)); grid.add(localEdit, 0, 1); remoteEdit = new TunnelEditor("Remote: ([/plug/][<rem-host>:]<rem-port>:<loc-host>:<loc-port>)", new Actions(ACT_REMOTEADD), new Actions(ACT_REMOTEDEL)); grid.add(remoteEdit, 1, 1); Button b; b = new Button("Close Dialog"); b.addActionListener(new AWTConvenience.CloseAction(tunnelDialog)); grid.getConstraints().fill = GridBagConstraints.NONE; grid.getConstraints().anchor = GridBagConstraints.CENTER; grid.getConstraints().weighty = 0; grid.add(b, 2, 1); tunnelDialog.addWindowListener(new AWTConvenience.CloseAdapter(b)); AWTConvenience.setBackgroundOfChildren(tunnelDialog); tunnelDialog.setResizable(true); tunnelDialog.pack(); } updateAdvancedTunnelLists(); AWTConvenience.placeDialog(tunnelDialog); tunnelDialog.setVisible(true); } void updateAdvancedTunnelLists() { String plugStr; int i; localEdit.removeAll(); remoteEdit.removeAll(); for(i = 0; i < client.localForwards.size(); i++) { SSHClient.LocalForward fwd = (SSHClient.LocalForward) client.localForwards.elementAt(i); plugStr = (fwd.plugin.equals("general") ? "" : "/" + fwd.plugin + "/"); localEdit.addToList(plugStr + fwd.localHost + ":" + fwd.localPort + ":" + fwd.remoteHost + ":" + fwd.remotePort); } for(i = 0; i < client.remoteForwards.size(); i++) { SSHClient.RemoteForward fwd = (SSHClient.RemoteForward) client.remoteForwards.elementAt(i); plugStr = (fwd.plugin.equals("general") ? "" : "/" + fwd.plugin + "/"); remoteEdit.addToList(plugStr + fwd.remotePort + ":" + fwd.localHost + ":" + fwd.localPort); } } Dialog connectDialog = null; List hostList; boolean wantToRunSettingsDialog = false; public final void connectDialog() { if(connectDialog == null) { connectDialog = new Dialog(parent, "MindTerm - Connect", true); GridBagLayout grid = new GridBagLayout(); GridBagConstraints gridc = new GridBagConstraints(); Label label; Button b; ActionListener al; connectDialog.setLayout(grid); gridc.fill = GridBagConstraints.NONE; gridc.anchor = GridBagConstraints.WEST; gridc.gridwidth = 2; gridc.gridy = 0; gridc.insets = new Insets(8, 8, 0, 8); label = new Label("Available hosts/aliases:"); grid.setConstraints(label, gridc); connectDialog.add(label); gridc.gridy = 1; label = new Label("(dir: " + client.propsHandler.getSSHHomeDir() + ")"); grid.setConstraints(label, gridc); connectDialog.add(label); gridc.fill = GridBagConstraints.BOTH; gridc.weightx = 1.0; gridc.weighty = 1.0; gridc.anchor = GridBagConstraints.WEST; gridc.insets = new Insets(8, 8, 8, 8); gridc.gridy = 2; hostList = new List(8); grid.setConstraints(hostList, gridc); connectDialog.add(hostList); hostList.addActionListener(al = new Actions(ACT_CONNECT2)); Panel bp = new Panel(new FlowLayout()); bp.add(b = new Button("Connect")); b.addActionListener(al); bp.add(b = new Button("New Server")); b.addActionListener(new Actions(ACT_NEWSERVER)); bp.add(b = new Button("Cancel")); b.addActionListener(new AWTConvenience.CloseAction(connectDialog)); gridc.gridy = 4; gridc.gridwidth = GridBagConstraints.REMAINDER; gridc.weightx = 1.0; gridc.anchor = GridBagConstraints.CENTER; grid.setConstraints(bp, gridc); connectDialog.add(bp); connectDialog.addWindowListener(new AWTConvenience.CloseAdapter(b)); AWTConvenience.setBackgroundOfChildren(connectDialog); connectDialog.setResizable(true); connectDialog.pack(); } hostList.removeAll(); String[] l = client.propsHandler.availableAliases(); if(l != null) { for(int i = 0; i < l.length; i++) { hostList.add(l[i]); } } hostList.select(0); connectDialog.pack(); AWTConvenience.placeDialog(connectDialog); hostList.requestFocus(); connectDialog.setVisible(true); if(wantToRunSettingsDialog) { wantToRunSettingsDialog = false; sshSettingsDialog(); } } FileDialog loadFileDialog = null; public final void loadFileDialog() { if(loadFileDialog == null) { loadFileDialog = new FileDialog(parent, "MindTerm - Select file to load settings from", FileDialog.LOAD); } loadFileDialog.setDirectory(client.propsHandler.getSSHHomeDir()); loadFileDialog.setVisible(true); String fileName = loadFileDialog.getFile(); String dirName = loadFileDialog.getDirectory(); if(fileName != null && fileName.length() > 0) { try { String pwd = ""; do { try { client.propsHandler.setPropertyPassword(pwd); client.propsHandler.loadAbsoluteFile(dirName + fileName, false); client.quiet = true; client.sshStdIO.breakPromptLine("Loaded new settings: " + fileName); break; } catch(SSHClient.AuthFailException ee) { } } while((pwd = passwordDialog("Please give password for " + fileName, "MindTerm - File Password")) != null); } catch (Throwable t) { alertDialog("Error loading settings: " + t.getMessage()); } } } FileDialog saveAsFileDialog = null; public final void saveAsFileDialog() { if(saveAsFileDialog == null) { saveAsFileDialog = new FileDialog(parent, "MindTerm - Select file to save settings to", FileDialog.SAVE); } saveAsFileDialog.setDirectory(client.propsHandler.getSSHHomeDir()); String fname = client.propsHandler.currentAlias; if(fname == null) fname = client.propsHandler.getProperty("server"); saveAsFileDialog.setFile(fname + client.propsHandler.PROPS_FILE_EXT); saveAsFileDialog.setVisible(true); String fileName = saveAsFileDialog.getFile(); String dirName = saveAsFileDialog.getDirectory(); if(fileName != null && fileName.length() > 0) { try { if(client.propsHandler.savePasswords) { String pwd = setPasswordDialog("Please set password for " + fileName, "MindTerm - Set File Password"); if(pwd == null) return; client.propsHandler.setPropertyPassword(pwd); } client.propsHandler.saveAsCurrentFile(dirName + fileName); } catch (Throwable t) { alertDialog("Error saving settings: " + t.getMessage()); } } } public final void alertDialog(String message) { SSHMiscDialogs.alert("MindTerm - Alert", message, parent); } public final String passwordDialog(String message, String title) { return SSHMiscDialogs.password(title, message, parent); } public final String setPasswordDialog(String message, String title) { return SSHMiscDialogs.setPassword(title, message, parent); } public final boolean confirmDialog(String message, boolean defAnswer) { return SSHMiscDialogs.confirm("MindTerm - Confirmation", message, defAnswer, parent); } public final void textDialog(String title, String text, int rows, int cols, boolean scrollbar) { SSHMiscDialogs.notice(title, text, rows, cols, scrollbar, parent); } public final static String aboutText = SSH.VER_MINDTERM + "\n" + Version.licenseMessage + "\n" + "\n" + Version.copyright + "\n" + "\thttp://www.appgate.com/mindterm/\n" + "\n" + "Includes parts of JZlib,\n" + "Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.\n" + "\n" + "JVM vendor:\t" + MindTerm.javaVendor + "\n" + "JVM version:\t" + MindTerm.javaVersion + "\n" + "OS name:\t\t" + MindTerm.osName + "\n" + "OS architecture:\t" + MindTerm.osArch + "\n" + "OS version:\t" + MindTerm.osVersion + "\n"; public static void about(Frame parent, SSHInteractiveClient client) { Dialog aboutDialog = null; TextArea textArea; Button okTextBut; aboutDialog = new Dialog(parent, "About " + SSH.VER_MINDTERM, true); AWTGridBagContainer grid = new AWTGridBagContainer(aboutDialog); grid.getConstraints().anchor = GridBagConstraints.CENTER; Component logo = client.getLogo(); if(logo != null) { grid.add(logo, 0, GridBagConstraints.REMAINDER); } textArea = new TextArea(aboutText, 12, 40, TextArea.SCROLLBARS_VERTICAL_ONLY); textArea.setEditable(false); grid.add(textArea, 1, GridBagConstraints.REMAINDER); okTextBut = new Button("OK"); okTextBut.addActionListener(new AWTConvenience.CloseAction(aboutDialog)); grid.getConstraints().fill = GridBagConstraints.NONE; grid.add(okTextBut, 2, GridBagConstraints.REMAINDER); aboutDialog.addWindowListener(new AWTConvenience.CloseAdapter(okTextBut)); AWTConvenience.setBackgroundOfChildren(aboutDialog); aboutDialog.setResizable(true); aboutDialog.pack(); AWTConvenience.placeDialog(aboutDialog); okTextBut.requestFocus(); aboutDialog.setVisible(true); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -