@@ -40,7 +40,7 @@ public class UserAuthImpl
40
40
extends AbstractService
41
41
implements UserAuth {
42
42
43
- private final Promise <Boolean , UserAuthException > authenticated ;
43
+ private final Promise <AuthResult , UserAuthException > authenticated ;
44
44
45
45
// Externally available
46
46
private volatile String banner = "" ;
@@ -53,13 +53,13 @@ public class UserAuthImpl
53
53
54
54
public UserAuthImpl (Transport trans ) {
55
55
super ("ssh-userauth" , trans );
56
- authenticated = new Promise <Boolean , UserAuthException >("authenticated" , UserAuthException .chainer , trans .getConfig ().getLoggerFactory ());
56
+ authenticated = new Promise <AuthResult , UserAuthException >("authenticated" , UserAuthException .chainer , trans .getConfig ().getLoggerFactory ());
57
57
}
58
58
59
59
@ Override
60
- public boolean authenticate (String username , Service nextService , AuthMethod method , int timeoutMs )
60
+ public AuthResult authenticate (String username , Service nextService , AuthMethod method , int timeoutMs )
61
61
throws UserAuthException , TransportException {
62
- final boolean outcome ;
62
+ final AuthResult outcome ;
63
63
64
64
authenticated .lock ();
65
65
try {
@@ -73,8 +73,10 @@ public boolean authenticate(String username, Service nextService, AuthMethod met
73
73
currentMethod .request ();
74
74
outcome = authenticated .retrieve (timeoutMs , TimeUnit .MILLISECONDS );
75
75
76
- if (outcome ) {
76
+ if (outcome == AuthResult . SUCCESS ) {
77
77
log .debug ("`{}` auth successful" , method .getName ());
78
+ } else if (outcome == AuthResult .PARTIAL ) {
79
+ log .debug ("`{}` auth partially successful" , method .getName ());
78
80
} else {
79
81
log .debug ("`{}` auth failed" , method .getName ());
80
82
}
@@ -124,7 +126,7 @@ public void handle(Message msg, SSHPacket buf)
124
126
// Should fix https://github.com/hierynomus/sshj/issues/237
125
127
trans .setAuthenticated (); // So it can put delayed compression into force if applicable
126
128
trans .setService (nextService ); // We aren't in charge anymore, next service is
127
- authenticated .deliver (true );
129
+ authenticated .deliver (AuthResult . SUCCESS );
128
130
break ;
129
131
130
132
case USERAUTH_FAILURE :
@@ -133,7 +135,7 @@ public void handle(Message msg, SSHPacket buf)
133
135
if (allowedMethods .contains (currentMethod .getName ()) && currentMethod .shouldRetry ()) {
134
136
currentMethod .request ();
135
137
} else {
136
- authenticated .deliver (false );
138
+ authenticated .deliver (partialSuccess ? AuthResult . PARTIAL : AuthResult . FAILURE );
137
139
}
138
140
break ;
139
141
0 commit comments