GUACAMOLE-1006: Merge support for reading any property value as a Collection.

This commit is contained in:
Mike Jumper
2024-08-30 10:44:51 -07:00
committed by GitHub
26 changed files with 517 additions and 143 deletions

View File

@@ -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.
@@ -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"; }
@@ -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"; }
@@ -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);
}
/**
@@ -90,8 +91,8 @@ public class ConfigurationService {
* @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);
}
}

View File

@@ -25,6 +25,7 @@ import java.net.URI;
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;
@@ -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
@@ -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;
}