Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUACAMOLE-1006: Provide implementations for List properties. #490

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.environment.Environment;
import org.apache.guacamole.properties.ByteArrayProperty;
import org.apache.guacamole.properties.StringListProperty;
import org.apache.guacamole.properties.StringGuacamoleProperty;

/**
* Service for retrieving configuration information regarding the JSON
Expand Down Expand Up @@ -56,7 +56,7 @@ public String getName() {
* be allowed to perform authentication. If not specified, ALL address will
* be allowed.
*/
private static final StringListProperty JSON_TRUSTED_NETWORKS = new StringListProperty() {
private static final StringGuacamoleProperty JSON_TRUSTED_NETWORKS = new StringGuacamoleProperty() {

@Override
public String getName() {
Expand Down Expand Up @@ -95,7 +95,7 @@ public byte[] getSecretKey() throws GuacamoleException {
* If guacamole.properties cannot be parsed.
*/
public Collection<String> getTrustedNetworks() throws GuacamoleException {
return environment.getProperty(JSON_TRUSTED_NETWORKS, Collections.<String>emptyList());
return environment.getPropertyCollection(JSON_TRUSTED_NETWORKS, Collections.<String>emptyList());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ private Map<String, String> getAttributeTokens(ConnectedLDAPConfiguration config
throws GuacamoleException {

// Get attributes from configuration information
List<String> attrList = config.getAttributes();
Collection<String> attrList = config.getAttributes();

// If there are no attributes there is no reason to search LDAP
if (attrList.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.guacamole.auth.ldap;

import java.util.Collection;
import java.util.List;
import org.apache.directory.api.ldap.model.filter.ExprNode;
import org.apache.directory.api.ldap.model.message.AliasDerefMode;
Expand Down Expand Up @@ -124,7 +125,7 @@ public int getServerPort() throws GuacamoleException {
}

@Override
public List<String> getUsernameAttributes() throws GuacamoleException {
public Collection<String> getUsernameAttributes() throws GuacamoleException {
return config.getUsernameAttributes();
}

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

@Override
public List<String> getGroupNameAttributes() throws GuacamoleException {
public Collection<String> getGroupNameAttributes() throws GuacamoleException {
return config.getGroupNameAttributes();
}

Expand Down Expand Up @@ -209,7 +210,7 @@ public int getNetworkTimeout() throws GuacamoleException {
}

@Override
public List<String> getAttributes() throws GuacamoleException {
public Collection<String> getAttributes() throws GuacamoleException {
return config.getAttributes();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

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

import java.util.List;
import java.util.Collection;
import org.apache.directory.api.ldap.model.filter.ExprNode;
import org.apache.directory.api.ldap.model.message.AliasDerefMode;
import org.apache.directory.api.ldap.model.name.Dn;
Expand Down Expand Up @@ -75,8 +75,8 @@ public int getServerPort() throws GuacamoleException {
}

@Override
public List<String> getUsernameAttributes() throws GuacamoleException {
return environment.getProperty(
public Collection<String> getUsernameAttributes() throws GuacamoleException {
return environment.getPropertyCollection(
LDAPGuacamoleProperties.LDAP_USERNAME_ATTRIBUTE,
DEFAULT.getUsernameAttributes()
);
Expand All @@ -98,8 +98,8 @@ public Dn getConfigurationBaseDN() throws GuacamoleException {
}

@Override
public List<String> getGroupNameAttributes() throws GuacamoleException {
return environment.getProperty(
public Collection<String> getGroupNameAttributes() throws GuacamoleException {
return environment.getPropertyCollection(
LDAPGuacamoleProperties.LDAP_GROUP_NAME_ATTRIBUTE,
DEFAULT.getGroupNameAttributes()
);
Expand Down Expand Up @@ -210,8 +210,8 @@ public int getNetworkTimeout() throws GuacamoleException {
}

@Override
public List<String> getAttributes() throws GuacamoleException {
return environment.getProperty(
public Collection<String> getAttributes() throws GuacamoleException {
return environment.getPropertyCollection(
LDAPGuacamoleProperties.LDAP_USER_ATTRIBUTES,
DEFAULT.getAttributes()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import static com.fasterxml.jackson.annotation.JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collection;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -331,7 +332,7 @@ public int getServerPort() throws GuacamoleException {
}

@Override
public List<String> getUsernameAttributes() throws GuacamoleException {
public Collection<String> getUsernameAttributes() throws GuacamoleException {
return withDefault(usernameAttributes, defaultConfig::getUsernameAttributes);
}

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

@Override
public List<String> getGroupNameAttributes() throws GuacamoleException {
public Collection<String> getGroupNameAttributes() throws GuacamoleException {
return withDefault(groupNameAttributes, defaultConfig::getGroupNameAttributes);
}

Expand Down Expand Up @@ -424,7 +425,7 @@ public int getNetworkTimeout() throws GuacamoleException {
}

@Override
public List<String> getAttributes() throws GuacamoleException {
public Collection<String> getAttributes() throws GuacamoleException {
return withDefault(userAttributes, defaultConfig::getAttributes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

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

import java.util.Collection;
import java.util.List;
import org.apache.directory.api.ldap.model.filter.ExprNode;
import org.apache.directory.api.ldap.model.message.AliasDerefMode;
Expand Down Expand Up @@ -84,7 +85,7 @@ public interface LDAPConfiguration {
* @throws GuacamoleException
* If the username attributes cannot be retrieved.
*/
List<String> getUsernameAttributes() throws GuacamoleException;
Collection<String> getUsernameAttributes() throws GuacamoleException;

/**
* Returns the base DN under which all Guacamole users will be stored
Expand Down Expand Up @@ -125,7 +126,7 @@ public interface LDAPConfiguration {
* @throws GuacamoleException
* If the group name attributes cannot be retrieved.
*/
List<String> getGroupNameAttributes() throws GuacamoleException;
Collection<String> getGroupNameAttributes() throws GuacamoleException;

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

/**
* Returns the name of the LDAP attribute used to enumerate members in a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ private LDAPGuacamoleProperties() {}
* one attribute, and the concatenation of that attribute and the value of
* LDAP_USER_BASE_DN must equal the user's full DN.
*/
public static final StringListProperty LDAP_USERNAME_ATTRIBUTE =
new StringListProperty() {
public static final StringGuacamoleProperty LDAP_USERNAME_ATTRIBUTE =
new StringGuacamoleProperty() {

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

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

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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public Dn deriveUserDN(LDAPConfiguration config, String username)
throws GuacamoleException {

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

// We need exactly one base DN to derive the user DN
if (usernameAttributes.size() != 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
package org.apache.guacamole.auth.quickconnect.conf;

import com.google.inject.Inject;
import java.util.Collection;
import java.util.List;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.environment.Environment;
import org.apache.guacamole.properties.StringListProperty;
import org.apache.guacamole.properties.StringGuacamoleProperty;

/**
* Configuration options to control the QuickConnect module.
Expand All @@ -42,7 +43,7 @@ public class ConfigurationService {
* the parameters defined in this list. Defaults to null (all parameters
* are allowed).
*/
public static final StringListProperty QUICKCONNECT_ALLOWED_PARAMETERS = new StringListProperty() {
public static final StringGuacamoleProperty QUICKCONNECT_ALLOWED_PARAMETERS = new StringGuacamoleProperty() {

@Override
public String getName() { return "quickconnect-allowed-parameters"; }
Expand All @@ -55,7 +56,7 @@ public class ConfigurationService {
* except the ones defined in this list. Defaults to null (all parameters
* are allowed).
*/
public static final StringListProperty QUICKCONNECT_DENIED_PARAMETERS = new StringListProperty() {
public static final StringGuacamoleProperty QUICKCONNECT_DENIED_PARAMETERS = new StringGuacamoleProperty() {

@Override
public String getName() { return "quickconnect-denied-parameters"; }
Expand All @@ -74,8 +75,8 @@ public class ConfigurationService {
* @throws GuacamoleException
* If guacamole.properties cannot be parsed.
*/
public List<String> getAllowedParameters() throws GuacamoleException {
return environment.getProperty(QUICKCONNECT_ALLOWED_PARAMETERS);
public Collection<String> getAllowedParameters() throws GuacamoleException {
return environment.getPropertyCollection(QUICKCONNECT_ALLOWED_PARAMETERS);
}

/**
Expand All @@ -90,8 +91,8 @@ public List<String> getAllowedParameters() throws GuacamoleException {
* @throws GuacamoleException
* If guacamole.properties cannot be parsed.
*/
public List<String> getDeniedParameters() throws GuacamoleException {
return environment.getProperty(QUICKCONNECT_DENIED_PARAMETERS);
public Collection<String> getDeniedParameters() throws GuacamoleException {
return environment.getPropertyCollection(QUICKCONNECT_DENIED_PARAMETERS);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -60,13 +61,13 @@ public class QCParser {
* by this parser. If not defined, all parameters will be allowed unless
* explicitly denied.
*/
private final List<String> allowedParams;
private final Collection<String> allowedParams;

/**
* The list of parameters that are explicitly denied from being placed into
* a configuration by this parser.
*/
private final List<String> deniedParams;
private final Collection<String> deniedParams;

/**
* Create a new instance of the QCParser class, with the provided allowed
Expand All @@ -81,7 +82,7 @@ public class QCParser {
* A list of parameters, if any, that should be explicitly denied from
* being placed into a connection configuration.
*/
public QCParser(List<String> allowedParams, List<String> deniedParams) {
public QCParser(Collection<String> allowedParams, Collection<String> deniedParams) {
this.allowedParams = allowedParams;
this.deniedParams = deniedParams;
}
Expand Down
Loading
Loading