From a710558854092a162161d8e66d1634b5831e1824 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Mon, 31 Dec 2018 12:37:03 -0500 Subject: [PATCH] GUACAMOLE-684: Insufficient credentials should take precedence over other credentials errors. --- .../guacamole/rest/auth/AuthenticationService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/auth/AuthenticationService.java b/guacamole/src/main/java/org/apache/guacamole/rest/auth/AuthenticationService.java index 7f388572a..b168514d9 100644 --- a/guacamole/src/main/java/org/apache/guacamole/rest/auth/AuthenticationService.java +++ b/guacamole/src/main/java/org/apache/guacamole/rest/auth/AuthenticationService.java @@ -36,6 +36,7 @@ import org.apache.guacamole.net.auth.Credentials; import org.apache.guacamole.net.auth.UserContext; import org.apache.guacamole.net.auth.credentials.CredentialsInfo; import org.apache.guacamole.net.auth.credentials.GuacamoleCredentialsException; +import org.apache.guacamole.net.auth.credentials.GuacamoleInsufficientCredentialsException; import org.apache.guacamole.net.auth.credentials.GuacamoleInvalidCredentialsException; import org.apache.guacamole.net.event.AuthenticationFailureEvent; import org.apache.guacamole.net.event.AuthenticationSuccessEvent; @@ -170,7 +171,13 @@ public class AuthenticationService { return authenticatedUser; } - // First failure takes priority for now + // Insufficient credentials should take precedence + catch (GuacamoleInsufficientCredentialsException e) { + if (authFailure == null || authFailure instanceof GuacamoleInvalidCredentialsException) + authFailure = e; + } + + // Catch other credentials exceptions and assign the first one catch (GuacamoleCredentialsException e) { if (authFailure == null) authFailure = e;