You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@guacamole.apache.org by mike-jumper <gi...@git.apache.org> on 2017/11/06 19:59:03 UTC
[GitHub] incubator-guacamole-client pull request #202: GUACAMOLE-243: Allow LDAP refe...
Github user mike-jumper commented on a diff in the pull request:
https://github.com/apache/incubator-guacamole-client/pull/202#discussion_r149183803
--- Diff: extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/connection/ConnectionService.java ---
@@ -129,62 +130,79 @@
Map<String, Connection> connections = new HashMap<String, Connection>();
while (results.hasMore()) {
- LDAPEntry entry = results.next();
+ try {
- // Get common name (CN)
- LDAPAttribute cn = entry.getAttribute("cn");
- if (cn == null) {
- logger.warn("guacConfigGroup is missing a cn.");
- continue;
- }
+ LDAPEntry entry = results.next();
- // Get associated protocol
- LDAPAttribute protocol = entry.getAttribute("guacConfigProtocol");
- if (protocol == null) {
- logger.warn("guacConfigGroup \"{}\" is missing the "
- + "required \"guacConfigProtocol\" attribute.",
- cn.getStringValue());
- continue;
- }
+ // Get common name (CN)
+ LDAPAttribute cn = entry.getAttribute("cn");
+ if (cn == null) {
+ logger.warn("guacConfigGroup is missing a cn.");
+ continue;
+ }
+
+ // Get associated protocol
+ LDAPAttribute protocol = entry.getAttribute("guacConfigProtocol");
+ if (protocol == null) {
+ logger.warn("guacConfigGroup \"{}\" is missing the "
+ + "required \"guacConfigProtocol\" attribute.",
+ cn.getStringValue());
+ continue;
+ }
- // Set protocol
- GuacamoleConfiguration config = new GuacamoleConfiguration();
- config.setProtocol(protocol.getStringValue());
+ // Set protocol
+ GuacamoleConfiguration config = new GuacamoleConfiguration();
+ config.setProtocol(protocol.getStringValue());
- // Get parameters, if any
- LDAPAttribute parameterAttribute = entry.getAttribute("guacConfigParameter");
- if (parameterAttribute != null) {
+ // Get parameters, if any
+ LDAPAttribute parameterAttribute = entry.getAttribute("guacConfigParameter");
+ if (parameterAttribute != null) {
- // For each parameter
- Enumeration<?> parameters = parameterAttribute.getStringValues();
- while (parameters.hasMoreElements()) {
+ // For each parameter
+ Enumeration<?> parameters = parameterAttribute.getStringValues();
+ while (parameters.hasMoreElements()) {
- String parameter = (String) parameters.nextElement();
+ String parameter = (String) parameters.nextElement();
- // Parse parameter
- int equals = parameter.indexOf('=');
- if (equals != -1) {
+ // Parse parameter
+ int equals = parameter.indexOf('=');
+ if (equals != -1) {
- // Parse name
- String name = parameter.substring(0, equals);
- String value = parameter.substring(equals+1);
+ // Parse name
+ String name = parameter.substring(0, equals);
+ String value = parameter.substring(equals+1);
- config.setParameter(name, value);
+ config.setParameter(name, value);
+
+ }
}
}
- }
+ // Filter the configuration, substituting all defined tokens
+ tokenFilter.filterValues(config.getParameters());
- // Filter the configuration, substituting all defined tokens
- tokenFilter.filterValues(config.getParameters());
+ // Store connection using cn for both identifier and name
+ String name = cn.getStringValue();
+ Connection connection = new SimpleConnection(name, name, config);
+ connection.setParentIdentifier(LDAPAuthenticationProvider.ROOT_CONNECTION_GROUP);
+ connections.put(name, connection);
- // Store connection using cn for both identifier and name
- String name = cn.getStringValue();
- Connection connection = new SimpleConnection(name, name, config);
- connection.setParentIdentifier(LDAPAuthenticationProvider.ROOT_CONNECTION_GROUP);
- connections.put(name, connection);
+ }
+
+ // Deal with issues following LDAP referrals
+ catch (LDAPReferralException e) {
+ if (confService.getFollowReferrals()) {
+ logger.error("Could not follow referral.", e.getFailedReferral());
--- End diff --
If the intent is to include `e.getFailedReferral()` within the logged message, then the `{}` string must be present in the message at the location the value should be inserted.
---