GUACAMOLE-580: Return an empty map instead of null when nothing is specified or 
found.

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

Branch: refs/heads/master
Commit: 2da04057981b2f00bd7b85bb7f74066a1f9b4ec6
Parents: 50baf1c
Author: Nick Couchman <vn...@apache.org>
Authored: Fri Jun 22 20:21:43 2018 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Fri Jun 22 20:21:43 2018 -0400

----------------------------------------------------------------------
 .../auth/ldap/AuthenticationProviderService.java       | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/2da04057/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java
----------------------------------------------------------------------
diff --git 
a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java
 
b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java
index cd3ac37..e359221 100644
--- 
a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java
+++ 
b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java
@@ -250,7 +250,8 @@ public class AuthenticationProviderService {
     /**
      * Returns all custom LDAP attributes on the user currently bound under
      * the given LDAP connection. The custom attributes are specified in
-     * guacamole.properties.
+     * guacamole.properties.  If no attributes are specified or none are
+     * found on the LDAP user object, an empty map is returned.
      *
      * @param ldapConnection
      *     LDAP connection to find the custom LDAP attributes.
@@ -261,7 +262,9 @@ public class AuthenticationProviderService {
      * @return
      *     All attributes on the user currently bound under the
      *     given LDAP connection, as a map of attribute name to
-     *     corresponding attribute value.
+     *     corresponding attribute value, or an empty map if no
+     *     attributes are specified or none are found on the user
+     *     object.
      *
      * @throws GuacamoleException
      *     If an error occurs retrieving the user DN or the attributes.
@@ -274,7 +277,7 @@ public class AuthenticationProviderService {
 
         // If there are no attributes there is no reason to search LDAP
         if (attrList == null || attrList.isEmpty())
-            return null;
+            return Collections.<String, String>emptyMap();
 
         // Build LDAP query parameters
         String[] attrArray = attrList.toArray(new String[attrList.size()]);
@@ -285,11 +288,11 @@ public class AuthenticationProviderService {
             // Get LDAP attributes by querying LDAP
             LDAPEntry userEntry = ldapConnection.read(userDN, attrArray);
             if (userEntry == null)
-                return null;
+                return Collections.<String, String>emptyMap();
 
             LDAPAttributeSet attrSet = userEntry.getAttributeSet();
             if (attrSet == null)
-                return null;
+                return Collections.<String, String>emptyMap();
 
             // Add each attribute into Map
             for (Object attrObj : attrSet) {

Reply via email to