Lines 67-74
Link Here
|
67 |
private static final int TELNET_CONNECT_TIMEOUT = 60; //seconds - TODO: Make configurable |
67 |
private static final int TELNET_CONNECT_TIMEOUT = 60; //seconds - TODO: Make configurable |
68 |
private List fTelnetClients = new ArrayList(); |
68 |
private List fTelnetClients = new ArrayList(); |
69 |
private SessionLostHandler fSessionLostHandler; |
69 |
private SessionLostHandler fSessionLostHandler; |
70 |
private InputStream in; |
|
|
71 |
private PrintStream out; |
72 |
private IPropertySet telnetPropertySet = null; |
70 |
private IPropertySet telnetPropertySet = null; |
73 |
private static final int ERROR_CODE = 100; // filed error code |
71 |
private static final int ERROR_CODE = 100; // filed error code |
74 |
private static final int SUCCESS_CODE = 150; // login pass code |
72 |
private static final int SUCCESS_CODE = 150; // login pass code |
Lines 148-158
Link Here
|
148 |
password = ssi.getPassword(); |
146 |
password = ssi.getPassword(); |
149 |
} |
147 |
} |
150 |
|
148 |
|
151 |
in = client.getInputStream(); |
|
|
152 |
out = new PrintStream(client.getOutputStream()); |
153 |
|
154 |
long millisToEnd = System.currentTimeMillis() + TELNET_CONNECT_TIMEOUT*1000; |
149 |
long millisToEnd = System.currentTimeMillis() + TELNET_CONNECT_TIMEOUT*1000; |
155 |
LoginThread checkLogin = new LoginThread(user, password); |
150 |
LoginThread checkLogin = new LoginThread(user, password,client.getInputStream(),new PrintStream( client.getOutputStream() )); |
156 |
checkLogin.start(); |
151 |
checkLogin.start(); |
157 |
while (checkLogin.isAlive() && System.currentTimeMillis()<millisToEnd) { |
152 |
while (checkLogin.isAlive() && System.currentTimeMillis()<millisToEnd) { |
158 |
if (monitor!=null) { |
153 |
if (monitor!=null) { |
Lines 231-237
Link Here
|
231 |
} |
226 |
} |
232 |
} |
227 |
} |
233 |
|
228 |
|
234 |
public int readUntil(String pattern) { |
229 |
public int readUntil(String pattern,InputStream in) { |
235 |
try { |
230 |
try { |
236 |
char lastChar = pattern.charAt(pattern.length() - 1); |
231 |
char lastChar = pattern.charAt(pattern.length() - 1); |
237 |
StringBuffer sb = new StringBuffer(); |
232 |
StringBuffer sb = new StringBuffer(); |
Lines 260-266
Link Here
|
260 |
return CONNECT_CLOSED; |
255 |
return CONNECT_CLOSED; |
261 |
} |
256 |
} |
262 |
|
257 |
|
263 |
public void write(String value) { |
258 |
public void write(String value,PrintStream out) { |
264 |
try { |
259 |
try { |
265 |
out.println(value); |
260 |
out.println(value); |
266 |
out.flush(); |
261 |
out.flush(); |
Lines 498-507
Link Here
|
498 |
private String username; |
493 |
private String username; |
499 |
private String password; |
494 |
private String password; |
500 |
private int status = SUCCESS_CODE; |
495 |
private int status = SUCCESS_CODE; |
|
|
496 |
private InputStream in; |
497 |
private PrintStream out; |
501 |
|
498 |
|
502 |
public LoginThread(String username, String password) { |
499 |
public LoginThread(String username, String password,InputStream in,PrintStream out) { |
503 |
this.username = username; |
500 |
this.username = username; |
504 |
this.password = password; |
501 |
this.password = password; |
|
|
502 |
this.in = in; |
503 |
this.out = out; |
505 |
} |
504 |
} |
506 |
|
505 |
|
507 |
public void run() { |
506 |
public void run() { |
Lines 519-537
Link Here
|
519 |
if (Boolean.valueOf(login_required).booleanValue()) { |
518 |
if (Boolean.valueOf(login_required).booleanValue()) { |
520 |
status = SUCCESS_CODE; |
519 |
status = SUCCESS_CODE; |
521 |
if (login_prompt != null && login_prompt.length() > 0) { |
520 |
if (login_prompt != null && login_prompt.length() > 0) { |
522 |
status = readUntil(login_prompt); |
521 |
status = readUntil(login_prompt,this.in); |
523 |
write(username); |
522 |
write(username,this.out); |
524 |
} |
523 |
} |
525 |
if (status == SUCCESS_CODE && password_prompt != null && password_prompt.length() > 0) { |
524 |
if (status == SUCCESS_CODE && password_prompt != null && password_prompt.length() > 0) { |
526 |
status = readUntil(password_prompt); |
525 |
status = readUntil(password_prompt,this.in); |
527 |
write(password); |
526 |
write(password,this.out); |
528 |
} |
527 |
} |
529 |
if (status == SUCCESS_CODE && command_prompt != null && command_prompt.length() > 0) { |
528 |
if (status == SUCCESS_CODE && command_prompt != null && command_prompt.length() > 0) { |
530 |
status = readUntil(command_prompt); |
529 |
status = readUntil(command_prompt,this.in); |
531 |
} |
530 |
} |
532 |
} else { |
531 |
} else { |
533 |
if (command_prompt != null && command_prompt.length() > 0) { |
532 |
if (command_prompt != null && command_prompt.length() > 0) { |
534 |
status = readUntil(command_prompt); |
533 |
status = readUntil(command_prompt,this.in); |
535 |
} |
534 |
} |
536 |
} |
535 |
} |
537 |
} |
536 |
} |