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 2017/11/13 02:30:16 UTC

[5/8] incubator-guacamole-client git commit: GUACAMOLE-243: Clean up code, remove unnecessary items, add JavaDocs, etc.

GUACAMOLE-243: Clean up code, remove unnecessary items, add JavaDocs, etc.


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

Branch: refs/heads/staging/0.9.14-incubating
Commit: 1212ba13fac2e4db40afea82ca041eb6e80bef77
Parents: 72c8308
Author: Nick Couchman <vn...@apache.org>
Authored: Tue Oct 24 14:52:57 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Tue Oct 24 14:52:57 2017 -0400

----------------------------------------------------------------------
 .../auth/ldap/LDAPConnectionService.java        |  3 +-
 .../auth/ldap/ReferralAuthHandler.java          | 39 ++++++--------------
 .../auth/ldap/connection/ConnectionService.java |  3 +-
 .../guacamole/auth/ldap/user/UserService.java   |  3 +-
 4 files changed, 14 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/1212ba13/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/LDAPConnectionService.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/LDAPConnectionService.java b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/LDAPConnectionService.java
index a4cb8bb..f849126 100644
--- a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/LDAPConnectionService.java
+++ b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/LDAPConnectionService.java
@@ -121,8 +121,7 @@ public class LDAPConnectionService {
         // Set whether or not we follow referrals
         ldapConstraints.setReferralFollowing(confService.getFollowReferrals());
 
-        // If the referral auth method is set to bind, we set it using the existing
-        // username and password.
+        // Set referral authentication to use the provided credentials.
         if (userDN != null && !userDN.isEmpty())
             ldapConstraints.setReferralHandler(new ReferralAuthHandler(userDN, password));
 

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/1212ba13/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/ReferralAuthHandler.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/ReferralAuthHandler.java b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/ReferralAuthHandler.java
index 21a7644..ed0f07a 100644
--- a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/ReferralAuthHandler.java
+++ b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/ReferralAuthHandler.java
@@ -28,6 +28,10 @@ import org.apache.guacamole.GuacamoleException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * Class that implements the necessary authentication handling
+ * for following referrals in LDAP connections.
+ */
 public class ReferralAuthHandler implements LDAPAuthHandler {
 
     /**
@@ -41,35 +45,14 @@ public class ReferralAuthHandler implements LDAPAuthHandler {
     private final LDAPAuthProvider ldapAuth;
 
     /**
-     * Service for retrieving LDAP server configuration information.
+     * Creates a ReferralAuthHandler object to handle authentication when
+     * following referrals in a LDAP connection, using the provided dn and
+     * password.
+     *
+     * @throws GuacamoleException
+     *     If exceptions are caught while converting the password from a string
+     *     into a byte array.
      */
-    @Inject
-    private ConfigurationService confService;
-
-
-    public ReferralAuthHandler() throws GuacamoleException {
-        String binddn = confService.getSearchBindDN();
-        String password = confService.getSearchBindPassword();
-        byte[] passwordBytes;
-        try {
-
-            // Convert password into corresponding byte array
-            if (password != null)
-                passwordBytes = password.getBytes("UTF-8");
-            else
-                passwordBytes = null;
-
-        }
-        catch (UnsupportedEncodingException e) {
-            logger.error("Unexpected lack of support for UTF-8: {}", e.getMessage());
-            logger.debug("Support for UTF-8 (as required by Java spec) not found.", e);
-            throw new GuacamoleException("Could not set password due to missing support for UTF-8 encoding.");
-        }
-
-        ldapAuth = new LDAPAuthProvider(binddn, passwordBytes);
-
-    }
-
     public ReferralAuthHandler(String dn, String password) throws GuacamoleException {
         byte[] passwordBytes;
         try {

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/1212ba13/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/connection/ConnectionService.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/connection/ConnectionService.java b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/connection/ConnectionService.java
index 0b03c63..a091e44 100644
--- a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/connection/ConnectionService.java
+++ b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/connection/ConnectionService.java
@@ -277,14 +277,13 @@ public class ConnectionService {
 
                 catch (LDAPReferralException e) {
                     if (confService.getFollowReferrals()) {
-                        logger.error("Could not follow referral.", e.getMessage());
+                        logger.error("Could not follow referral: {}", e.getFailedReferral());
                         logger.debug("Error encountered trying to follow referral.", e);
                         throw new GuacamoleServerException("Could not follow LDAP referral.", e);
                     }
                     else {
                         logger.warn("Given a referral, but referrals are disabled.", e.getMessage());
                         logger.debug("Got a referral, but configured to not follow them.", e);
-                        continue;
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/1212ba13/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/user/UserService.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/user/UserService.java b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/user/UserService.java
index bd8f183..fc7d5a3 100644
--- a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/user/UserService.java
+++ b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/user/UserService.java
@@ -129,14 +129,13 @@ public class UserService {
                 // Deal with errors trying to follow referrals
                 catch (LDAPReferralException e) {
                     if (confService.getFollowReferrals()) {
-                        logger.error("Could not follow referral.", e.getFailedReferral());
+                        logger.error("Could not follow referral: {}", e.getFailedReferral());
                         logger.debug("Error encountered trying to follow referral.", e);
                         throw new GuacamoleServerException("Could not follow LDAP referral.", e);
                     }
                     else {
                         logger.warn("Given a referral, but referrals are disabled.", e.getMessage());
                         logger.debug("Got a referral, but configured to not follow them.", e);
-                        continue;
                     }
                 }