Skip to content

Commit 98ef4ae

Browse files
committed
GUACAMOLE-1006: Convert LDAP extension to use new StringGuacamoleProperty Collection.
1 parent a8b5001 commit 98ef4ae

File tree

8 files changed

+27
-86
lines changed

8 files changed

+27
-86
lines changed

extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ private Map<String, String> getAttributeTokens(ConnectedLDAPConfiguration config
330330
throws GuacamoleException {
331331

332332
// Get attributes from configuration information
333-
List<String> attrList = config.getAttributes();
333+
Collection<String> attrList = config.getAttributes();
334334

335335
// If there are no attributes there is no reason to search LDAP
336336
if (attrList.isEmpty())

extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/ConnectedLDAPConfiguration.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.apache.guacamole.auth.ldap;
2121

22+
import java.util.Collection;
2223
import java.util.List;
2324
import org.apache.directory.api.ldap.model.filter.ExprNode;
2425
import org.apache.directory.api.ldap.model.message.AliasDerefMode;
@@ -124,7 +125,7 @@ public int getServerPort() throws GuacamoleException {
124125
}
125126

126127
@Override
127-
public List<String> getUsernameAttributes() throws GuacamoleException {
128+
public Collection<String> getUsernameAttributes() throws GuacamoleException {
128129
return config.getUsernameAttributes();
129130
}
130131

@@ -139,7 +140,7 @@ public Dn getConfigurationBaseDN() throws GuacamoleException {
139140
}
140141

141142
@Override
142-
public List<String> getGroupNameAttributes() throws GuacamoleException {
143+
public Collection<String> getGroupNameAttributes() throws GuacamoleException {
143144
return config.getGroupNameAttributes();
144145
}
145146

@@ -209,7 +210,7 @@ public int getNetworkTimeout() throws GuacamoleException {
209210
}
210211

211212
@Override
212-
public List<String> getAttributes() throws GuacamoleException {
213+
public Collection<String> getAttributes() throws GuacamoleException {
213214
return config.getAttributes();
214215
}
215216

extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/conf/EnvironmentLDAPConfiguration.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package org.apache.guacamole.auth.ldap.conf;
2121

22-
import java.util.List;
22+
import java.util.Collection;
2323
import org.apache.directory.api.ldap.model.filter.ExprNode;
2424
import org.apache.directory.api.ldap.model.message.AliasDerefMode;
2525
import org.apache.directory.api.ldap.model.name.Dn;
@@ -75,8 +75,8 @@ public int getServerPort() throws GuacamoleException {
7575
}
7676

7777
@Override
78-
public List<String> getUsernameAttributes() throws GuacamoleException {
79-
return environment.getProperty(
78+
public Collection<String> getUsernameAttributes() throws GuacamoleException {
79+
return environment.getPropertyCollection(
8080
LDAPGuacamoleProperties.LDAP_USERNAME_ATTRIBUTE,
8181
DEFAULT.getUsernameAttributes()
8282
);
@@ -98,8 +98,8 @@ public Dn getConfigurationBaseDN() throws GuacamoleException {
9898
}
9999

100100
@Override
101-
public List<String> getGroupNameAttributes() throws GuacamoleException {
102-
return environment.getProperty(
101+
public Collection<String> getGroupNameAttributes() throws GuacamoleException {
102+
return environment.getPropertyCollection(
103103
LDAPGuacamoleProperties.LDAP_GROUP_NAME_ATTRIBUTE,
104104
DEFAULT.getGroupNameAttributes()
105105
);
@@ -210,8 +210,8 @@ public int getNetworkTimeout() throws GuacamoleException {
210210
}
211211

212212
@Override
213-
public List<String> getAttributes() throws GuacamoleException {
214-
return environment.getProperty(
213+
public Collection<String> getAttributes() throws GuacamoleException {
214+
return environment.getPropertyCollection(
215215
LDAPGuacamoleProperties.LDAP_USER_ATTRIBUTES,
216216
DEFAULT.getAttributes()
217217
);

extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/conf/JacksonLDAPConfiguration.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.fasterxml.jackson.annotation.JsonFormat;
2323
import static com.fasterxml.jackson.annotation.JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY;
2424
import com.fasterxml.jackson.annotation.JsonProperty;
25+
import java.util.Collection;
2526
import java.util.List;
2627
import java.util.regex.Matcher;
2728
import java.util.regex.Pattern;
@@ -331,7 +332,7 @@ public int getServerPort() throws GuacamoleException {
331332
}
332333

333334
@Override
334-
public List<String> getUsernameAttributes() throws GuacamoleException {
335+
public Collection<String> getUsernameAttributes() throws GuacamoleException {
335336
return withDefault(usernameAttributes, defaultConfig::getUsernameAttributes);
336337
}
337338

@@ -348,7 +349,7 @@ public Dn getConfigurationBaseDN() throws GuacamoleException {
348349
}
349350

350351
@Override
351-
public List<String> getGroupNameAttributes() throws GuacamoleException {
352+
public Collection<String> getGroupNameAttributes() throws GuacamoleException {
352353
return withDefault(groupNameAttributes, defaultConfig::getGroupNameAttributes);
353354
}
354355

@@ -424,7 +425,7 @@ public int getNetworkTimeout() throws GuacamoleException {
424425
}
425426

426427
@Override
427-
public List<String> getAttributes() throws GuacamoleException {
428+
public Collection<String> getAttributes() throws GuacamoleException {
428429
return withDefault(userAttributes, defaultConfig::getAttributes);
429430
}
430431

extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/conf/LDAPConfiguration.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.apache.guacamole.auth.ldap.conf;
2121

22+
import java.util.Collection;
2223
import java.util.List;
2324
import org.apache.directory.api.ldap.model.filter.ExprNode;
2425
import org.apache.directory.api.ldap.model.message.AliasDerefMode;
@@ -84,7 +85,7 @@ public interface LDAPConfiguration {
8485
* @throws GuacamoleException
8586
* If the username attributes cannot be retrieved.
8687
*/
87-
List<String> getUsernameAttributes() throws GuacamoleException;
88+
Collection<String> getUsernameAttributes() throws GuacamoleException;
8889

8990
/**
9091
* Returns the base DN under which all Guacamole users will be stored
@@ -125,7 +126,7 @@ public interface LDAPConfiguration {
125126
* @throws GuacamoleException
126127
* If the group name attributes cannot be retrieved.
127128
*/
128-
List<String> getGroupNameAttributes() throws GuacamoleException;
129+
Collection<String> getGroupNameAttributes() throws GuacamoleException;
129130

130131
/**
131132
* Returns the base DN under which all Guacamole role based access control
@@ -305,7 +306,7 @@ public interface LDAPConfiguration {
305306
* If the names of the LDAP user attributes to be exposed as parameter
306307
* tokens cannot be retrieved.
307308
*/
308-
List<String> getAttributes() throws GuacamoleException;
309+
Collection<String> getAttributes() throws GuacamoleException;
309310

310311
/**
311312
* Returns the name of the LDAP attribute used to enumerate members in a

extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/conf/LDAPGuacamoleProperties.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ private LDAPGuacamoleProperties() {}
8484
* one attribute, and the concatenation of that attribute and the value of
8585
* LDAP_USER_BASE_DN must equal the user's full DN.
8686
*/
87-
public static final StringListProperty LDAP_USERNAME_ATTRIBUTE =
88-
new StringListProperty() {
87+
public static final StringGuacamoleProperty LDAP_USERNAME_ATTRIBUTE =
88+
new StringGuacamoleProperty() {
8989

9090
@Override
9191
public String getName() { return "ldap-username-attribute"; }
@@ -97,8 +97,8 @@ private LDAPGuacamoleProperties() {}
9797
* attributes must be present within each Guacamole user group's record in
9898
* the LDAP directory for that group to be visible.
9999
*/
100-
public static final StringListProperty LDAP_GROUP_NAME_ATTRIBUTE =
101-
new StringListProperty() {
100+
public static final StringGuacamoleProperty LDAP_GROUP_NAME_ATTRIBUTE =
101+
new StringGuacamoleProperty() {
102102

103103
@Override
104104
public String getName() { return "ldap-group-name-attribute"; }
@@ -277,8 +277,8 @@ private LDAPGuacamoleProperties() {}
277277
* Custom attribute or attributes to query from Guacamole user's record in
278278
* the LDAP directory.
279279
*/
280-
public static final StringListProperty LDAP_USER_ATTRIBUTES =
281-
new StringListProperty() {
280+
public static final StringGuacamoleProperty LDAP_USER_ATTRIBUTES =
281+
new StringGuacamoleProperty() {
282282

283283
@Override
284284
public String getName() { return "ldap-user-attributes"; }

extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/conf/StringListProperty.java

Lines changed: 0 additions & 62 deletions
This file was deleted.

extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/user/UserService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public Dn deriveUserDN(LDAPConfiguration config, String username)
183183
throws GuacamoleException {
184184

185185
// Pull username attributes from properties
186-
List<String> usernameAttributes = config.getUsernameAttributes();
186+
List<String> usernameAttributes = new ArrayList<>(config.getUsernameAttributes());
187187

188188
// We need exactly one base DN to derive the user DN
189189
if (usernameAttributes.size() != 1) {

0 commit comments

Comments
 (0)