mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUACAMOLE-524: Fixed try block, exceptions, and import order
This commit is contained in:
@@ -27,8 +27,8 @@ import com.novell.ldap.LDAPEntry;
|
|||||||
import com.novell.ldap.LDAPAttribute;
|
import com.novell.ldap.LDAPAttribute;
|
||||||
import com.novell.ldap.LDAPException;
|
import com.novell.ldap.LDAPException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.apache.guacamole.auth.ldap.user.AuthenticatedUser;
|
import org.apache.guacamole.auth.ldap.user.AuthenticatedUser;
|
||||||
import org.apache.guacamole.auth.ldap.user.UserContext;
|
import org.apache.guacamole.auth.ldap.user.UserContext;
|
||||||
@@ -241,9 +241,6 @@ public class AuthenticationProviderService {
|
|||||||
return authenticatedUser;
|
return authenticatedUser;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (LDAPException e) {
|
|
||||||
throw new GuacamoleServerException("Error while querying for User Attributes.", e);
|
|
||||||
}
|
|
||||||
// Always disconnect
|
// Always disconnect
|
||||||
finally {
|
finally {
|
||||||
ldapService.disconnect(ldapConnection);
|
ldapService.disconnect(ldapConnection);
|
||||||
@@ -258,6 +255,7 @@ public class AuthenticationProviderService {
|
|||||||
*
|
*
|
||||||
* @param ldapConnection
|
* @param ldapConnection
|
||||||
* LDAP connection to find the custom LDAP attributes.
|
* LDAP connection to find the custom LDAP attributes.
|
||||||
|
*
|
||||||
* @param username
|
* @param username
|
||||||
* The username of the user whose attributes are queried.
|
* The username of the user whose attributes are queried.
|
||||||
*
|
*
|
||||||
@@ -273,7 +271,7 @@ public class AuthenticationProviderService {
|
|||||||
* If an error occurs retrieving the user DN.
|
* If an error occurs retrieving the user DN.
|
||||||
*/
|
*/
|
||||||
private Map<String, String> getLDAPAttributes(LDAPConnection ldapConnection,
|
private Map<String, String> getLDAPAttributes(LDAPConnection ldapConnection,
|
||||||
String username) throws LDAPException {
|
String username) throws GuacamoleException {
|
||||||
|
|
||||||
// Get attributes from configuration information
|
// Get attributes from configuration information
|
||||||
List<String> attrList = confService.getAttributes();
|
List<String> attrList = confService.getAttributes();
|
||||||
@@ -286,18 +284,23 @@ public class AuthenticationProviderService {
|
|||||||
String[] attrArray = attrList.toArray(new String[attrList.size()]);
|
String[] attrArray = attrList.toArray(new String[attrList.size()]);
|
||||||
String userDN = getUserBindDN(username);
|
String userDN = getUserBindDN(username);
|
||||||
|
|
||||||
|
Map<String, String> attrMap = new HashMap<String, String>();
|
||||||
|
try {
|
||||||
// Get LDAP attributes by querying LDAP
|
// Get LDAP attributes by querying LDAP
|
||||||
LDAPEntry userEntry = ldapConnection.read(userDN, attrArray);
|
LDAPEntry userEntry = ldapConnection.read(userDN, attrArray);
|
||||||
LDAPAttributeSet attrSet = userEntry.getAttributeSet();
|
LDAPAttributeSet attrSet = userEntry.getAttributeSet();
|
||||||
|
|
||||||
// Add each attribute into Map
|
// Add each attribute into Map
|
||||||
Map<String, String> attrMap = new HashMap<String, String>();
|
|
||||||
for (Object attrObj : attrSet) {
|
for (Object attrObj : attrSet) {
|
||||||
LDAPAttribute attr = (LDAPAttribute)attrObj;
|
LDAPAttribute attr = (LDAPAttribute)attrObj;
|
||||||
String attrName = attr.getName();
|
String attrName = attr.getName();
|
||||||
String attrValue = attr.getStringValue();
|
String attrValue = attr.getStringValue();
|
||||||
attrMap.put(attrName, attrValue);
|
attrMap.put(attrName, attrValue);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (LDAPException e) {
|
||||||
|
throw new GuacamoleServerException("Error while querying for User Attributes.", e);
|
||||||
|
}
|
||||||
|
|
||||||
return attrMap;
|
return attrMap;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user