Skip to content

Commit

Permalink
Format the files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitrii Beliakov committed Aug 16, 2024
1 parent 7c8f530 commit 794389c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/main/java/com/jcraft/jsch/JSch.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ public class JSch {
"hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1"));
config.put("compression.s2c", Util.getSystemProperty("jsch.compression", "none"));
config.put("compression.c2s", Util.getSystemProperty("jsch.compression", "none"));
// Do not ask re-entering password after the first failure. Useful when authenticating with a script that uses the same password every time. Set true to activate.
config.put("user_auth_keyboard_interactive_single_attempt", Util.getSystemProperty("jsch.user_auth_keyboard_interactive_single_attempt", "false"));
config.put("user_auth_single_attempt", Util.getSystemProperty("jsch.user_auth_single_attempt", "false"));
// Do not ask re-entering password after the first failure. Useful when authenticating with a
// script that uses the same password every time. Set true to activate.
config.put("user_auth_keyboard_interactive_single_attempt",
Util.getSystemProperty("jsch.user_auth_keyboard_interactive_single_attempt", "false"));
config.put("user_auth_single_attempt",
Util.getSystemProperty("jsch.user_auth_single_attempt", "false"));

config.put("lang.s2c", Util.getSystemProperty("jsch.lang", ""));
config.put("lang.c2s", Util.getSystemProperty("jsch.lang", ""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public boolean start(Session session) throws Exception {
if (session.getTimeout() > 0 && System.currentTimeMillis() > timeout) {
throw new JSchAuthCancelException("keyboard-interactive");
}
// Do not ask re-entering password after the first failure. Useful when authenticating with a script that uses the same password every time.
// Do not ask re-entering password after the first failure. Useful when authenticating with
// a script that uses the same password every time.
if (isMaxFailuresReached(auth_failures_initial, session.auth_failures)) {
return false;
}
Expand Down Expand Up @@ -205,6 +206,7 @@ public boolean start(Session session) throws Exception {
}

private boolean isMaxFailuresReached(int initial, int current) {
return Boolean.parseBoolean(JSch.getConfig("user_auth_keyboard_interactive_single_attempt")) && current > initial;
return Boolean.parseBoolean(JSch.getConfig("user_auth_keyboard_interactive_single_attempt"))
&& current > initial;
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/jcraft/jsch/UserAuthPassword.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ public boolean start(Session session) throws Exception {
}
session.auth_failures++;

// Do not ask re-entering password after the first failure. Useful when authenticating with a script that uses the same password every time.
// Do not ask re-entering password after the first failure. Useful when authenticating
// with a script that uses the same password every time.
if (Boolean.parseBoolean(JSch.getConfig("user_auth_single_attempt"))) {
return false;
}
Expand Down

0 comments on commit 794389c

Please sign in to comment.