GUACAMOLE-197: Handle IllegalArgumentException when parsing state string.

Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/0729fa09
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/0729fa09
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/0729fa09

Branch: refs/heads/master
Commit: 0729fa09cdd41eb497bb4542bce0be40b11442c6
Parents: 41dd9fc
Author: Nick Couchman <vn...@apache.org>
Authored: Sat Feb 3 23:23:27 2018 -0500
Committer: Nick Couchman <vn...@apache.org>
Committed: Sat Feb 3 23:23:27 2018 -0500

----------------------------------------------------------------------
 .../guacamole/auth/radius/AuthenticationProviderService.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/0729fa09/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/AuthenticationProviderService.java
----------------------------------------------------------------------
diff --git 
a/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/AuthenticationProviderService.java
 
b/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/AuthenticationProviderService.java
index bee0433..2418c8e 100644
--- 
a/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/AuthenticationProviderService.java
+++ 
b/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/AuthenticationProviderService.java
@@ -21,6 +21,7 @@ package org.apache.guacamole.auth.radius;
 
 import com.google.inject.Inject;
 import com.google.inject.Provider;
+import java.lang.IllegalArgumentException;
 import java.nio.charset.Charset;
 import java.util.Arrays;
 import javax.servlet.http.HttpServletRequest;
@@ -161,7 +162,7 @@ public class AuthenticationProviderService {
                 if (stateString == null) {
                     logger.error("Could not retrieve RADIUS state.");
                     logger.debug("Received null value while retrieving RADIUS 
state parameter.");
-                    throws new 
GuacamoleInvalidCredentialsException("Authentication error.", 
CredentialsInfo.USERNAME_PASSWORD);
+                    throw new 
GuacamoleInvalidCredentialsException("Authentication error.", 
CredentialsInfo.USERNAME_PASSWORD);
                 }
 
                 byte[] stateBytes = 
DatatypeConverter.parseHexBinary(stateString);
@@ -169,6 +170,11 @@ public class AuthenticationProviderService {
                                                               
challengeResponse,
                                                               stateBytes);
             }
+            catch (IllegalArgumentException e) {
+                logger.error("Illegal argument while parsing RADIUS state 
string.", e.getMessage());
+                logger.debug("Illegal argument found while parsing the RADIUS 
state string.", e);
+                throw new GuacamoleInvalidCredentialsException("Authentication 
error.", CredentialsInfo.USERNAME_PASSWORD);
+            }
             catch (GuacamoleException e) {
                 logger.error("Cannot configure RADIUS server: {}", 
e.getMessage());
                 logger.debug("Error configuring RADIUS server.", e);

Reply via email to