I couldn't figure out the reason why I was getting an auth cancel
exception, because JSch swallows its JSchAuthCancelException, instead
setting a boolean auth_cancel=true and throwing a generic JSchException
long after the fact.
In the patch below, I attach the JSchAuthCancelException to the
JSchException; this displays the reason for the AuthCancelException
("password", "keyboard-interactive", "publickey") in the stack trace,
which helps a lot.
---
src/com/jcraft/jsch/Session.java | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/com/jcraft/jsch/Session.java b/src/com/jcraft/jsch/Session.java
index bb69a5a..0956fff 100644
--- a/src/com/jcraft/jsch/Session.java
+++ b/src/com/jcraft/jsch/Session.java
@@ -330,7 +330,7 @@ public class Session implements Runnable{
}
boolean auth=false;
- boolean auth_cancel=false;
+ JSchAuthCancelException auth_cancel=null;
UserAuth ua=null;
try{
@@ -414,7 +414,7 @@ public class Session implements Runnable{
}
if(ua!=null){
- auth_cancel=false;
+ auth_cancel=null;
try{
auth=ua.start(this);
if(auth &&
@@ -424,14 +424,14 @@ public class Session implements Runnable{
}
}
catch(JSchAuthCancelException ee){
- auth_cancel=true;
+ auth_cancel=ee;
}
catch(JSchPartialAuthException ee){
smethods=ee.getMethods();
smethoda=Util.split(smethods, ",");
methodi=0;
//System.err.println("PartialAuth: "+methods);
- auth_cancel=false;
+ auth_cancel=null;
continue loop;
}
catch(RuntimeException ee){
@@ -447,8 +447,8 @@ public class Session implements Runnable{
}
if(!auth){
- if(auth_cancel)
- throw new JSchException("Auth cancel");
+ if(auth_cancel != null)
+ throw new JSchException("Auth cancel", auth_cancel);
throw new JSchException("Auth fail");
}
--
1.7.0.2
------------------------------------------------------------------------------
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users