You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2018/01/30 23:44:33 UTC

[21/50] guacamole-client git commit: GUACAMOLE-197: Remove unnecessary null/empty checks in setupRadiusAuthenticator, and throw exceptions instead of returning null.

GUACAMOLE-197: Remove unnecessary null/empty checks in setupRadiusAuthenticator, and throw exceptions instead of returning null.


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

Branch: refs/heads/master
Commit: ba837cb31bf84331389e500bdf468d39112b76d7
Parents: d773614
Author: Nick Couchman <ni...@yahoo.com>
Authored: Tue Apr 11 10:19:00 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Mon Jan 29 17:08:10 2018 -0500

----------------------------------------------------------------------
 .../auth/radius/RadiusConnectionService.java    | 39 +++++++-------------
 1 file changed, 13 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/ba837cb3/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/RadiusConnectionService.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/RadiusConnectionService.java b/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/RadiusConnectionService.java
index 3b37199..68d7823 100644
--- a/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/RadiusConnectionService.java
+++ b/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/RadiusConnectionService.java
@@ -119,14 +119,11 @@ public class RadiusConnectionService {
             return null;
         }
 
-        String radAuthName;
         String caFile;
         String caPassword;
         String caType;
         String keyFile;
         String keyPassword;
-        String keyType;
-        Boolean trustAll;
         String innerProtocol;
         LocalEnvironment guacEnv;
         String basePath;
@@ -134,52 +131,42 @@ public class RadiusConnectionService {
         // Pull configuration parameters from guacamole.properties
         guacEnv = new LocalEnvironment();
         basePath = guacEnv.getGuacamoleHome().getAbsolutePath() + '/';
-        radAuthName = confService.getRadiusAuthProtocol();
         caFile = confService.getRadiusCAFile();
         caPassword = confService.getRadiusCAPassword();
-        caType = confService.getRadiusCAType();
         keyFile = confService.getRadiusKeyFile();
         keyPassword = confService.getRadiusKeyPassword();
-        keyType = confService.getRadiusKeyType();
-        trustAll = confService.getRadiusTrustAll();
         innerProtocol = confService.getRadiusEAPTTLSInnerProtocol();
             
-        RadiusAuthenticator radAuth = radiusClient.getAuthProtocol(radAuthName);
+        RadiusAuthenticator radAuth = radiusClient.getAuthProtocol(confService.getRadiusAuthProtocol());
         if (radAuth == null)
-            return null;
+            throw new GuacamoleException("Could not get a valid RadiusAuthenticator for specified protocol: " + confService.getRadiusAuthProtocol());
 
         // If we're using any of the TLS protocols, we need to configure them
         if (radAuth instanceof PEAPAuthenticator || 
             radAuth instanceof EAPTLSAuthenticator || 
             radAuth instanceof EAPTTLSAuthenticator) {
 
-            if (caFile != null && !caFile.isEmpty())
+            if (caFile != null) {
                 ((EAPTLSAuthenticator)radAuth).setCaFile(basePath + caFile);
+                ((EAPTLSAuthenticator)radAuth).setCaFileType(confService.getRadiusCAType());
+                if (caPassword != null)
+                    ((EAPTLSAuthenticator)radAuth).setCaPassword(caPassword);
+            }
 
-            if (caType != null && !caType.isEmpty())
-                ((EAPTLSAuthenticator)radAuth).setCaFileType(caType);
-
-            if (caPassword != null && !caPassword.isEmpty())
-                ((EAPTLSAuthenticator)radAuth).setCaPassword(caPassword);
-
-            if (keyFile != null && !keyFile.isEmpty())
-                ((EAPTLSAuthenticator)radAuth).setKeyFile(basePath + keyFile);
-
-            if (keyType != null && !keyType.isEmpty())
-                ((EAPTLSAuthenticator)radAuth).setKeyFileType(keyType);
-
-            if (keyPassword != null && !keyPassword.isEmpty())
+            if (keyPassword != null)
                 ((EAPTLSAuthenticator)radAuth).setKeyPassword(keyPassword);
 
-            ((EAPTLSAuthenticator)radAuth).setTrustAll(trustAll);
+            ((EAPTLSAuthenticator)radAuth).setKeyFile(basePath + keyFile);
+            ((EAPTLSAuthenticator)radAuth).setKeyFileType(confService.getRadiusKeyType());
+            ((EAPTLSAuthenticator)radAuth).setTrustAll(confService.getRadiusTrustAll());
 
         }
 
         // If we're using EAP-TTLS, we need to define tunneled protocol
         if (radAuth instanceof EAPTTLSAuthenticator) {
 
-            if (innerProtocol == null || innerProtocol.isEmpty())
-                return null;
+            if (innerProtocol == null)
+                throw new GuacamoleException("Trying to use EAP-TTLS, but no inner protocol specified.");
 
             ((EAPTTLSAuthenticator)radAuth).setInnerProtocol(innerProtocol);