Skip to content
Snippets Groups Projects
Commit 863435b9 authored by tjc's avatar tjc
Browse files

remember login details

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@3383 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent e1643557
No related branches found
No related tags found
No related merge requests found
...@@ -62,6 +62,10 @@ public class SshPSUClient extends Thread ...@@ -62,6 +62,10 @@ public class SshPSUClient extends Thread
private String db = null; private String db = null;
private String wdir = "/nfs/pathscratch1/scratch"; private String wdir = "/nfs/pathscratch1/scratch";
private int port = -1; private int port = -1;
private static JPasswordField pfield = new JPasswordField(16);
private static JTextField portfield = new JTextField(16);
private static JTextField hostfield = new JTextField(16);
private static JTextField ufield = new JTextField(16);
public SshPSUClient(String args[]) public SshPSUClient(String args[])
{ {
...@@ -141,34 +145,22 @@ public class SshPSUClient extends Thread ...@@ -141,34 +145,22 @@ public class SshPSUClient extends Thread
ConfigurationLoader.initialize(false); ConfigurationLoader.initialize(false);
// if(hostname == null)
// hostname = (String)JOptionPane.showInputDialog(
// null, "Name of server machine:",
// "Server hostname",
// JOptionPane.PLAIN_MESSAGE, null,
// null, null);
BufferedReader reader = BufferedReader reader =
new BufferedReader(new InputStreamReader(System.in)); new BufferedReader(new InputStreamReader(System.in));
// Create a password authentication instance // Create a password authentication instance
PasswordAuthenticationClient pwd = new PasswordAuthenticationClient(); PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();
// Get the users name
JPanel promptPanel = new JPanel(new GridLayout(4,2)); JPanel promptPanel = new JPanel(new GridLayout(4,2));
JTextField hostfield = new JTextField(16); if(hostname != null && hostfield.getText().equals(""))
if(hostname != null)
hostfield.setText(hostname); hostfield.setText(hostname);
JTextField portfield = new JTextField(16); if(port >-1 && portfield.getText().equals(""))
if(port >-1)
portfield.setText(Integer.toString(port)); portfield.setText(Integer.toString(port));
JTextField ufield = new JTextField(16); if(user != null && ufield.getText().equals(""))
if(user != null)
ufield.setText(user); ufield.setText(user);
JPasswordField pfield = new JPasswordField(16);
JLabel hostlab = new JLabel(" Hostname:", SwingConstants.LEFT); JLabel hostlab = new JLabel(" Hostname:", SwingConstants.LEFT);
JLabel portlab = new JLabel(" Port:", SwingConstants.LEFT); JLabel portlab = new JLabel(" Port:", SwingConstants.LEFT);
...@@ -187,19 +179,23 @@ public class SshPSUClient extends Thread ...@@ -187,19 +179,23 @@ public class SshPSUClient extends Thread
promptPanel.add(plab); promptPanel.add(plab);
promptPanel.add(pfield); promptPanel.add(pfield);
Object[] options = { "CANCEL", "LOGIN"}; Object[] options = { "CANCEL", "LOGIN AND RUN"};
int select = JOptionPane.showOptionDialog(null, promptPanel, int select = JOptionPane.showOptionDialog(null, promptPanel,
"LOGIN", "LOGIN",
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE, JOptionPane.QUESTION_MESSAGE,
null, null,
options, options,
options[1]); options[1]);
if(select == 0) if(select == 0)
return; return;
user = ufield.getText().trim();
pwd.setUsername(user);
pwd.setPassword(new String(pfield.getPassword()));
// Make a client connection // Make a client connection
SshClient ssh = new SshClient(); SshClient ssh = new SshClient();
...@@ -208,17 +204,12 @@ public class SshPSUClient extends Thread ...@@ -208,17 +204,12 @@ public class SshPSUClient extends Thread
port = -1; port = -1;
else else
port = Integer.parseInt(portfield.getText().trim()); port = Integer.parseInt(portfield.getText().trim());
// Connect to the host
if(port < 0) if(port < 0)
ssh.connect(hostname); ssh.connect(hostname);
else else
ssh.connect(hostname,port); ssh.connect(hostname,port);
user = ufield.getText().trim();
pwd.setUsername(user);
pwd.setPassword(new String(pfield.getPassword()));
// Try the authentication // Try the authentication
int result = ssh.authenticate(pwd); int result = ssh.authenticate(pwd);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment