0

I am novice with JSch library.
I need to validate login credentials.
How can I make it? connect and check response code?

P.S. I cannot find information in doc.

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
  • Do you really have no other source of user credentials? An LDAP server or database or something like that? Barring that ... yes, your option pretty much is to attempt a connection and see how that goes. JSch has no way of knowing if they're valid without making the attempt. – dcsohl Jun 08 '15 at 14:51
  • @dcsohl I would not mind to attempt connection. I need to differ when problem on remote server and problem with my credentials. – gstackoverflow Jun 08 '15 at 14:54
  • Bearing in mind that a high-security server may not tell you the difference (giving minimal clues to would-be hackers), I would say you need to try it out in your specific situation. [The source code is readily available](http://grepcode.com/snapshot/repo1.maven.org/maven2/com.jcraft/jsch/0.1.52/) so you can examine that for more information as well. – dcsohl Jun 08 '15 at 14:58

1 Answers1

0
try {
       session.connect();
} catch (JSchException e) {
       if ("Auth fail".equals(e.getMessage())) {
            isSuccess = false; //Auth fail
       }
}
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710