mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-1006: Implement Collection support within GuacamoleProperty classes.
This commit is contained in:
@@ -25,7 +25,7 @@ import java.util.Collections;
|
|||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.environment.Environment;
|
import org.apache.guacamole.environment.Environment;
|
||||||
import org.apache.guacamole.properties.ByteArrayProperty;
|
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
|
* Service for retrieving configuration information regarding the JSON
|
||||||
@@ -56,7 +56,7 @@ public class ConfigurationService {
|
|||||||
* be allowed to perform authentication. If not specified, ALL address will
|
* be allowed to perform authentication. If not specified, ALL address will
|
||||||
* be allowed.
|
* be allowed.
|
||||||
*/
|
*/
|
||||||
private static final StringListProperty JSON_TRUSTED_NETWORKS = new StringListProperty() {
|
private static final StringGuacamoleProperty JSON_TRUSTED_NETWORKS = new StringGuacamoleProperty() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -95,7 +95,7 @@ public class ConfigurationService {
|
|||||||
* If guacamole.properties cannot be parsed.
|
* If guacamole.properties cannot be parsed.
|
||||||
*/
|
*/
|
||||||
public Collection<String> getTrustedNetworks() throws GuacamoleException {
|
public Collection<String> getTrustedNetworks() throws GuacamoleException {
|
||||||
return environment.getProperty(JSON_TRUSTED_NETWORKS, Collections.<String>emptyList());
|
return environment.getPropertyCollection(JSON_TRUSTED_NETWORKS, Collections.<String>emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -20,10 +20,11 @@
|
|||||||
package org.apache.guacamole.auth.quickconnect.conf;
|
package org.apache.guacamole.auth.quickconnect.conf;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.environment.Environment;
|
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.
|
* 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
|
* the parameters defined in this list. Defaults to null (all parameters
|
||||||
* are allowed).
|
* are allowed).
|
||||||
*/
|
*/
|
||||||
public static final StringListProperty QUICKCONNECT_ALLOWED_PARAMETERS = new StringListProperty() {
|
public static final StringGuacamoleProperty QUICKCONNECT_ALLOWED_PARAMETERS = new StringGuacamoleProperty() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() { return "quickconnect-allowed-parameters"; }
|
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
|
* except the ones defined in this list. Defaults to null (all parameters
|
||||||
* are allowed).
|
* are allowed).
|
||||||
*/
|
*/
|
||||||
public static final StringListProperty QUICKCONNECT_DENIED_PARAMETERS = new StringListProperty() {
|
public static final StringGuacamoleProperty QUICKCONNECT_DENIED_PARAMETERS = new StringGuacamoleProperty() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() { return "quickconnect-denied-parameters"; }
|
public String getName() { return "quickconnect-denied-parameters"; }
|
||||||
@@ -74,8 +75,8 @@ public class ConfigurationService {
|
|||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If guacamole.properties cannot be parsed.
|
* If guacamole.properties cannot be parsed.
|
||||||
*/
|
*/
|
||||||
public List<String> getAllowedParameters() throws GuacamoleException {
|
public Collection<String> getAllowedParameters() throws GuacamoleException {
|
||||||
return environment.getProperty(QUICKCONNECT_ALLOWED_PARAMETERS);
|
return environment.getPropertyCollection(QUICKCONNECT_ALLOWED_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,8 +91,8 @@ public class ConfigurationService {
|
|||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If guacamole.properties cannot be parsed.
|
* If guacamole.properties cannot be parsed.
|
||||||
*/
|
*/
|
||||||
public List<String> getDeniedParameters() throws GuacamoleException {
|
public Collection<String> getDeniedParameters() throws GuacamoleException {
|
||||||
return environment.getProperty(QUICKCONNECT_DENIED_PARAMETERS);
|
return environment.getPropertyCollection(QUICKCONNECT_DENIED_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,7 @@ import java.net.URI;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -60,13 +61,13 @@ public class QCParser {
|
|||||||
* by this parser. If not defined, all parameters will be allowed unless
|
* by this parser. If not defined, all parameters will be allowed unless
|
||||||
* explicitly denied.
|
* explicitly denied.
|
||||||
*/
|
*/
|
||||||
private final List<String> allowedParams;
|
private final Collection<String> allowedParams;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of parameters that are explicitly denied from being placed into
|
* The list of parameters that are explicitly denied from being placed into
|
||||||
* a configuration by this parser.
|
* 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
|
* 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
|
* A list of parameters, if any, that should be explicitly denied from
|
||||||
* being placed into a connection configuration.
|
* 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.allowedParams = allowedParams;
|
||||||
this.deniedParams = deniedParams;
|
this.deniedParams = deniedParams;
|
||||||
}
|
}
|
||||||
|
@@ -21,13 +21,13 @@ package org.apache.guacamole.auth.openid.conf;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.environment.Environment;
|
import org.apache.guacamole.environment.Environment;
|
||||||
import org.apache.guacamole.properties.IntegerGuacamoleProperty;
|
import org.apache.guacamole.properties.IntegerGuacamoleProperty;
|
||||||
import org.apache.guacamole.properties.StringGuacamoleProperty;
|
import org.apache.guacamole.properties.StringGuacamoleProperty;
|
||||||
import org.apache.guacamole.properties.StringListProperty;
|
|
||||||
import org.apache.guacamole.properties.URIGuacamoleProperty;
|
import org.apache.guacamole.properties.URIGuacamoleProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,8 +138,8 @@ public class ConfigurationService {
|
|||||||
* The claims within any valid JWT that should be mapped to
|
* The claims within any valid JWT that should be mapped to
|
||||||
* the authenticated user's tokens, as configured with guacamole.properties.
|
* the authenticated user's tokens, as configured with guacamole.properties.
|
||||||
*/
|
*/
|
||||||
private static final StringListProperty OPENID_ATTRIBUTES_CLAIM_TYPE =
|
private static final StringGuacamoleProperty OPENID_ATTRIBUTES_CLAIM_TYPE =
|
||||||
new StringListProperty() {
|
new StringGuacamoleProperty() {
|
||||||
@Override
|
@Override
|
||||||
public String getName() { return "openid-attributes-claim-type"; }
|
public String getName() { return "openid-attributes-claim-type"; }
|
||||||
};
|
};
|
||||||
@@ -356,8 +356,8 @@ public class ConfigurationService {
|
|||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If guacamole.properties cannot be parsed.
|
* If guacamole.properties cannot be parsed.
|
||||||
*/
|
*/
|
||||||
public List<String> getAttributesClaimType() throws GuacamoleException {
|
public Collection<String> getAttributesClaimType() throws GuacamoleException {
|
||||||
return environment.getProperty(OPENID_ATTRIBUTES_CLAIM_TYPE, DEFAULT_ATTRIBUTES_CLAIM_TYPE);
|
return environment.getPropertyCollection(OPENID_ATTRIBUTES_CLAIM_TYPE, DEFAULT_ATTRIBUTES_CLAIM_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
package org.apache.guacamole.auth.openid.token;
|
package org.apache.guacamole.auth.openid.token;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -229,7 +230,7 @@ public class TokenValidationService {
|
|||||||
* If guacamole.properties could not be parsed.
|
* If guacamole.properties could not be parsed.
|
||||||
*/
|
*/
|
||||||
public Map<String, String> processAttributes(JwtClaims claims) throws GuacamoleException {
|
public Map<String, String> processAttributes(JwtClaims claims) throws GuacamoleException {
|
||||||
List<String> attributesClaim = confService.getAttributesClaimType();
|
Collection<String> attributesClaim = confService.getAttributesClaimType();
|
||||||
|
|
||||||
if (claims != null && !attributesClaim.isEmpty()) {
|
if (claims != null && !attributesClaim.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
|
@@ -26,6 +26,7 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -214,7 +215,7 @@ public class SSLClientAuthenticationResource extends SSOResource {
|
|||||||
|
|
||||||
// Verify that the username is specified with one of the allowed
|
// Verify that the username is specified with one of the allowed
|
||||||
// attributes
|
// attributes
|
||||||
List<String> usernameAttributes = confService.getSubjectUsernameAttributes();
|
Collection<String> usernameAttributes = confService.getSubjectUsernameAttributes();
|
||||||
if (usernameAttributes != null && !usernameAttributes.stream().anyMatch(nameRdn.getType()::equalsIgnoreCase))
|
if (usernameAttributes != null && !usernameAttributes.stream().anyMatch(nameRdn.getType()::equalsIgnoreCase))
|
||||||
throw new GuacamoleClientException("Subject DN \"" + dn + "\" "
|
throw new GuacamoleClientException("Subject DN \"" + dn + "\" "
|
||||||
+ "does not contain an acceptable username attribute.");
|
+ "does not contain an acceptable username attribute.");
|
||||||
|
@@ -22,7 +22,7 @@ package org.apache.guacamole.auth.ssl.conf;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.List;
|
import java.util.Collection;
|
||||||
import javax.naming.ldap.LdapName;
|
import javax.naming.ldap.LdapName;
|
||||||
import javax.ws.rs.core.UriBuilder;
|
import javax.ws.rs.core.UriBuilder;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
@@ -30,7 +30,6 @@ import org.apache.guacamole.GuacamoleServerException;
|
|||||||
import org.apache.guacamole.environment.Environment;
|
import org.apache.guacamole.environment.Environment;
|
||||||
import org.apache.guacamole.properties.IntegerGuacamoleProperty;
|
import org.apache.guacamole.properties.IntegerGuacamoleProperty;
|
||||||
import org.apache.guacamole.properties.StringGuacamoleProperty;
|
import org.apache.guacamole.properties.StringGuacamoleProperty;
|
||||||
import org.apache.guacamole.properties.StringListProperty;
|
|
||||||
import org.apache.guacamole.properties.URIGuacamoleProperty;
|
import org.apache.guacamole.properties.URIGuacamoleProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -146,8 +145,8 @@ public class ConfigurationService {
|
|||||||
* one of these attributes, the certificate will be rejected. By default,
|
* one of these attributes, the certificate will be rejected. By default,
|
||||||
* any attribute is accepted.
|
* any attribute is accepted.
|
||||||
*/
|
*/
|
||||||
private static final StringListProperty SSL_SUBJECT_USERNAME_ATTRIBUTE =
|
private static final StringGuacamoleProperty SSL_SUBJECT_USERNAME_ATTRIBUTE =
|
||||||
new StringListProperty () {
|
new StringGuacamoleProperty () {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() { return "ssl-subject-username-attribute"; }
|
public String getName() { return "ssl-subject-username-attribute"; }
|
||||||
@@ -433,8 +432,8 @@ public class ConfigurationService {
|
|||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If the configured set of username attributes cannot be read.
|
* If the configured set of username attributes cannot be read.
|
||||||
*/
|
*/
|
||||||
public List<String> getSubjectUsernameAttributes() throws GuacamoleException {
|
public Collection<String> getSubjectUsernameAttributes() throws GuacamoleException {
|
||||||
return environment.getProperty(SSL_SUBJECT_USERNAME_ATTRIBUTE);
|
return environment.getPropertyCollection(SSL_SUBJECT_USERNAME_ATTRIBUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
package org.apache.guacamole.environment;
|
package org.apache.guacamole.environment;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration;
|
import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration;
|
||||||
@@ -74,11 +75,35 @@ public class DelegatingEnvironment implements Environment {
|
|||||||
return environment.getProperty(property, defaultValue);
|
return environment.getProperty(property, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <Type> Collection<Type> getPropertyCollection(GuacamoleProperty<Type> property)
|
||||||
|
throws GuacamoleException {
|
||||||
|
return environment.getPropertyCollection(property);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <Type> Collection<Type> getPropertyCollection(GuacamoleProperty<Type> property,
|
||||||
|
Type defaultValue) throws GuacamoleException {
|
||||||
|
return environment.getPropertyCollection(property, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <Type> Collection<Type> getPropertyCollection(GuacamoleProperty<Type> property,
|
||||||
|
Collection<Type> defaultValue) throws GuacamoleException {
|
||||||
|
return environment.getPropertyCollection(property, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <Type> Type getRequiredProperty(GuacamoleProperty<Type> property) throws GuacamoleException {
|
public <Type> Type getRequiredProperty(GuacamoleProperty<Type> property) throws GuacamoleException {
|
||||||
return environment.getRequiredProperty(property);
|
return environment.getRequiredProperty(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <Type> Collection<Type> getRequiredPropertyCollection(GuacamoleProperty<Type> property)
|
||||||
|
throws GuacamoleException {
|
||||||
|
return environment.getRequiredPropertyCollection(property);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GuacamoleProxyConfiguration getDefaultGuacamoleProxyConfiguration() throws GuacamoleException {
|
public GuacamoleProxyConfiguration getDefaultGuacamoleProxyConfiguration() throws GuacamoleException {
|
||||||
return environment.getDefaultGuacamoleProxyConfiguration();
|
return environment.getDefaultGuacamoleProxyConfiguration();
|
||||||
|
@@ -21,6 +21,8 @@ package org.apache.guacamole.environment;
|
|||||||
|
|
||||||
import org.apache.guacamole.properties.GuacamoleProperties;
|
import org.apache.guacamole.properties.GuacamoleProperties;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||||
@@ -102,13 +104,18 @@ public interface Environment {
|
|||||||
* Given a GuacamoleProperty, parses and returns the value set for that
|
* Given a GuacamoleProperty, parses and returns the value set for that
|
||||||
* property in guacamole.properties, if any.
|
* property in guacamole.properties, if any.
|
||||||
*
|
*
|
||||||
* @param <Type> The type that the given property is parsed into.
|
* @param <Type>
|
||||||
* @param property The property to read from guacamole.properties.
|
* The type that the given property is parsed into.
|
||||||
* @return The parsed value of the property as read from
|
*
|
||||||
* guacamole.properties.
|
* @param property
|
||||||
* @throws GuacamoleException If an error occurs while parsing the value
|
* The property to read from guacamole.properties.
|
||||||
* for the given property in
|
*
|
||||||
* guacamole.properties.
|
* @return
|
||||||
|
* The parsed value of the property as read from guacamole.properties.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs while parsing the value for the given property in
|
||||||
|
* guacamole.properties.
|
||||||
*/
|
*/
|
||||||
public <Type> Type getProperty(GuacamoleProperty<Type> property)
|
public <Type> Type getProperty(GuacamoleProperty<Type> property)
|
||||||
throws GuacamoleException;
|
throws GuacamoleException;
|
||||||
@@ -118,20 +125,161 @@ public interface Environment {
|
|||||||
* property in guacamole.properties, if any. If no value is found, the
|
* property in guacamole.properties, if any. If no value is found, the
|
||||||
* provided default value is returned.
|
* provided default value is returned.
|
||||||
*
|
*
|
||||||
* @param <Type> The type that the given property is parsed into.
|
* @param <Type>
|
||||||
* @param property The property to read from guacamole.properties.
|
* The type that the given property is parsed into.
|
||||||
* @param defaultValue The value to return if no value was given in
|
*
|
||||||
* guacamole.properties.
|
* @param property
|
||||||
* @return The parsed value of the property as read from
|
* The property to read from guacamole.properties.
|
||||||
* guacamole.properties, or the provided default value if no value
|
*
|
||||||
* was found.
|
* @param defaultValue
|
||||||
* @throws GuacamoleException If an error occurs while parsing the value
|
* The value to return if no value was given in guacamole.properties.
|
||||||
* for the given property in
|
*
|
||||||
* guacamole.properties.
|
* @return
|
||||||
|
* The parsed value of the property as read from guacamole.properties,
|
||||||
|
* or the provided default value if no value was found.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs while parsing the value for the given property in
|
||||||
|
* guacamole.properties.
|
||||||
*/
|
*/
|
||||||
public <Type> Type getProperty(GuacamoleProperty<Type> property,
|
public <Type> Type getProperty(GuacamoleProperty<Type> property,
|
||||||
Type defaultValue) throws GuacamoleException;
|
Type defaultValue) throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a GuacamoleProperty, parses and returns a sorted Collection of the
|
||||||
|
* value set for that property in guacamole.properties, if any. The
|
||||||
|
* implementation of parsing and returning a collection of multiple
|
||||||
|
* values is up to the individual property implementations, and not all
|
||||||
|
* implementations will support reading and returning multiple values.
|
||||||
|
*
|
||||||
|
* @param <Type>
|
||||||
|
* The type that the given property is parsed into.
|
||||||
|
*
|
||||||
|
* @param property
|
||||||
|
* The property to read from guacamole.properties.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* A sorted collection of the the parsed values of the property as read
|
||||||
|
* from guacamole.properties.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs while parsing the value for the given property in
|
||||||
|
* guacamole.properties.
|
||||||
|
*/
|
||||||
|
public default <Type> Collection<Type> getPropertyCollection(
|
||||||
|
GuacamoleProperty<Type> property) throws GuacamoleException {
|
||||||
|
|
||||||
|
/* Pull the given property as a string. */
|
||||||
|
StringGuacamoleProperty stringProperty = new StringGuacamoleProperty() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return property.getName(); }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Parse the string to a Collection of the desired type. */
|
||||||
|
return property.parseValueCollection(getProperty(stringProperty));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a GuacamoleProperty, parses and returns the value set for that
|
||||||
|
* property in guacamole.properties, if any. If no value is found, a
|
||||||
|
* Collection is returned with the provided default value. The
|
||||||
|
* implementation of parsing and returning a collection of multiple
|
||||||
|
* values is up to the individual property implementations, and not all
|
||||||
|
* implementations will support reading and returning multiple values.
|
||||||
|
*
|
||||||
|
* @param <Type>
|
||||||
|
* The type that the given property is parsed into.
|
||||||
|
*
|
||||||
|
* @param property
|
||||||
|
* The property to read from guacamole.properties.
|
||||||
|
*
|
||||||
|
* @param defaultValue
|
||||||
|
* The single value to return in the Collection if no value was given
|
||||||
|
* in guacamole.properties.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* A sorted collection of the the parsed values of the property as read
|
||||||
|
* from guacamole.properties, or a Collection with the single default
|
||||||
|
* value provided.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs while parsing the value for the given property in
|
||||||
|
* guacamole.properties.
|
||||||
|
*/
|
||||||
|
public default <Type> Collection<Type> getPropertyCollection(
|
||||||
|
GuacamoleProperty<Type> property, Type defaultValue)
|
||||||
|
throws GuacamoleException {
|
||||||
|
|
||||||
|
/* Pull the given property as a string. */
|
||||||
|
StringGuacamoleProperty stringProperty = new StringGuacamoleProperty() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return property.getName(); }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Check the value and return the default if null. */
|
||||||
|
String stringValue = getProperty(stringProperty);
|
||||||
|
if (stringValue == null)
|
||||||
|
return Collections.singletonList(defaultValue);
|
||||||
|
|
||||||
|
/* Parse the string and return the collection. */
|
||||||
|
return property.parseValueCollection(stringValue);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a GuacamoleProperty, parses and returns the value set for that
|
||||||
|
* property in guacamole.properties, if any. If no value is found, the
|
||||||
|
* provided Collection of default values is returned. The
|
||||||
|
* implementation of parsing and returning a collection of multiple
|
||||||
|
* values is up to the individual property implementations, and not all
|
||||||
|
* implementations will support reading and returning multiple values.
|
||||||
|
*
|
||||||
|
* @param <Type>
|
||||||
|
* The type that the given property is parsed into.
|
||||||
|
*
|
||||||
|
* @param property
|
||||||
|
* The property to read from guacamole.properties.
|
||||||
|
*
|
||||||
|
* @param defaultValue
|
||||||
|
* The Collection of values to return in the Collection if no value was
|
||||||
|
* given in guacamole.properties.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* A sorted collection of the the parsed values of the property as read
|
||||||
|
* from guacamole.properties, or a Collection with the single default
|
||||||
|
* value provided.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs while parsing the value for the given property in
|
||||||
|
* guacamole.properties.
|
||||||
|
*/
|
||||||
|
public default <Type> Collection<Type> getPropertyCollection(
|
||||||
|
GuacamoleProperty<Type> property, Collection<Type> defaultValue)
|
||||||
|
throws GuacamoleException {
|
||||||
|
|
||||||
|
/* Pull the given property as a string. */
|
||||||
|
StringGuacamoleProperty stringProperty = new StringGuacamoleProperty() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return property.getName(); }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Check the value and return the default if null. */
|
||||||
|
String stringValue = getProperty(stringProperty);
|
||||||
|
if (stringValue == null)
|
||||||
|
return defaultValue;
|
||||||
|
|
||||||
|
/* Parse the string and return the collection. */
|
||||||
|
return property.parseValueCollection(stringValue);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a GuacamoleProperty, parses and returns the value set for that
|
* Given a GuacamoleProperty, parses and returns the value set for that
|
||||||
* property in guacamole.properties. An exception is thrown if the value
|
* property in guacamole.properties. An exception is thrown if the value
|
||||||
@@ -149,6 +297,43 @@ public interface Environment {
|
|||||||
public <Type> Type getRequiredProperty(GuacamoleProperty<Type> property)
|
public <Type> Type getRequiredProperty(GuacamoleProperty<Type> property)
|
||||||
throws GuacamoleException;
|
throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a GuacamoleProperty, parses and returns a sorted Collection of
|
||||||
|
* values for that property in guacamole.properties. An exception is thrown
|
||||||
|
* if the value is not provided. The implementation of parsing and returning
|
||||||
|
* a collection of multiple values is up to the individual property
|
||||||
|
* implementations, and not all implementations will support reading and
|
||||||
|
* returning multiple values.
|
||||||
|
*
|
||||||
|
* @param <Type>
|
||||||
|
* The type that the given property is parsed into.
|
||||||
|
*
|
||||||
|
* @param property
|
||||||
|
* The property to read from guacamole.properties.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* A sorted Collection of the property as read from guacamole.properties.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs while parsing the value for the given property in
|
||||||
|
* guacamole.properties, or if the property is not specified.
|
||||||
|
*/
|
||||||
|
public default <Type> Collection<Type> getRequiredPropertyCollection(
|
||||||
|
GuacamoleProperty<Type> property) throws GuacamoleException {
|
||||||
|
|
||||||
|
/* Pull the given property as a string. */
|
||||||
|
StringGuacamoleProperty stringProperty = new StringGuacamoleProperty() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return property.getName(); }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Parse the string to a Collection of the desired type. */
|
||||||
|
return property.parseValueCollection(getRequiredProperty(stringProperty));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the connection information which should be used, by default, to
|
* Returns the connection information which should be used, by default, to
|
||||||
* connect to guacd when establishing a remote desktop connection.
|
* connect to guacd when establishing a remote desktop connection.
|
||||||
|
@@ -25,6 +25,8 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -354,6 +356,38 @@ public class LocalEnvironment implements Environment {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <Type> Collection<Type> getPropertyCollection(GuacamoleProperty<Type> property)
|
||||||
|
throws GuacamoleException {
|
||||||
|
|
||||||
|
return property.parseValueCollection(getPropertyValue(property.getName()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <Type> Collection<Type> getPropertyCollection(GuacamoleProperty<Type> property,
|
||||||
|
Type defaultValue) throws GuacamoleException {
|
||||||
|
|
||||||
|
Collection<Type> value = getPropertyCollection(property);
|
||||||
|
if (value == null)
|
||||||
|
return Collections.singletonList(defaultValue);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <Type> Collection<Type> getPropertyCollection(GuacamoleProperty<Type> property,
|
||||||
|
Collection<Type> defaultValue) throws GuacamoleException {
|
||||||
|
|
||||||
|
Collection<Type> value = getPropertyCollection(property);
|
||||||
|
if (value == null)
|
||||||
|
return defaultValue;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <Type> Type getRequiredProperty(GuacamoleProperty<Type> property)
|
public <Type> Type getRequiredProperty(GuacamoleProperty<Type> property)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
@@ -366,6 +400,18 @@ public class LocalEnvironment implements Environment {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <Type> Collection<Type> getRequiredPropertyCollection(GuacamoleProperty<Type> property)
|
||||||
|
throws GuacamoleException {
|
||||||
|
|
||||||
|
Collection<Type> value = getPropertyCollection(property);
|
||||||
|
if (value == null)
|
||||||
|
throw new GuacamoleServerException("Property " + property.getName() + " is required.");
|
||||||
|
|
||||||
|
return value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ProtocolInfo> getProtocols() {
|
public Map<String, ProtocolInfo> getProtocols() {
|
||||||
return availableProtocols;
|
return availableProtocols;
|
||||||
|
@@ -20,6 +20,9 @@
|
|||||||
package org.apache.guacamole.properties;
|
package org.apache.guacamole.properties;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,4 +41,26 @@ public abstract class FileGuacamoleProperty implements GuacamoleProperty<File> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<File> parseValueCollection(String value) throws GuacamoleException {
|
||||||
|
|
||||||
|
// If no property is provided, return null.
|
||||||
|
if (value == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Split string into a list of individual values
|
||||||
|
List<String> stringValues = Arrays.asList(DELIMITER_PATTERN.split(value));
|
||||||
|
if (stringValues.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Translate values to Files and add to result array.
|
||||||
|
List<File> fileValues = new ArrayList<>();
|
||||||
|
for (String stringFile : stringValues) {
|
||||||
|
fileValues.add(new File(stringFile));
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileValues;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
package org.apache.guacamole.properties;
|
package org.apache.guacamole.properties;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,12 +33,21 @@ import org.apache.guacamole.GuacamoleException;
|
|||||||
*/
|
*/
|
||||||
public interface GuacamoleProperty<Type> {
|
public interface GuacamoleProperty<Type> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A pattern which matches against the delimiters between values. This is
|
||||||
|
* currently simply a semicolon and any following whitespace. Parts of the
|
||||||
|
* input string which match this pattern will not be included in the parsed
|
||||||
|
* result.
|
||||||
|
*/
|
||||||
|
static final Pattern DELIMITER_PATTERN = Pattern.compile(";\\s*");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the property in guacamole.properties that this
|
* Returns the name of the property in guacamole.properties that this
|
||||||
* GuacamoleProperty will parse.
|
* GuacamoleProperty will parse.
|
||||||
*
|
*
|
||||||
* @return The name of the property in guacamole.properties that this
|
* @return
|
||||||
* GuacamoleProperty will parse.
|
* The name of the property in guacamole.properties that this
|
||||||
|
* GuacamoleProperty will parse.
|
||||||
*/
|
*/
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
@@ -43,11 +55,37 @@ public interface GuacamoleProperty<Type> {
|
|||||||
* Parses the given string value into the type associated with this
|
* Parses the given string value into the type associated with this
|
||||||
* GuacamoleProperty.
|
* GuacamoleProperty.
|
||||||
*
|
*
|
||||||
* @param value The string value to parse.
|
* @param value
|
||||||
* @return The parsed value.
|
* The string value to parse.
|
||||||
* @throws GuacamoleException If an error occurs while parsing the
|
*
|
||||||
* provided value.
|
* @return
|
||||||
|
* The parsed value.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs while parsing the provided value.
|
||||||
*/
|
*/
|
||||||
public Type parseValue(String value) throws GuacamoleException;
|
public Type parseValue(String value) throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the given string value into a Collection of values of the type
|
||||||
|
* associated with this GuacamoleProperty. The default implementation
|
||||||
|
* simply returns a list containing a single item as parsed by the
|
||||||
|
* parseValue method.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* The string value to parse.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* A sorted Collection of the parsed values.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs while parsing the provided value.
|
||||||
|
*/
|
||||||
|
default public Collection<Type> parseValueCollection(String value)
|
||||||
|
throws GuacamoleException {
|
||||||
|
|
||||||
|
return Collections.singletonList(parseValue(value));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
package org.apache.guacamole.properties;
|
package org.apache.guacamole.properties;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.GuacamoleServerException;
|
import org.apache.guacamole.GuacamoleServerException;
|
||||||
|
|
||||||
@@ -43,4 +46,25 @@ public abstract class IntegerGuacamoleProperty implements GuacamoleProperty<Inte
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Integer> parseValueCollection(String value) throws GuacamoleException {
|
||||||
|
|
||||||
|
if (value == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Split string into a list of individual values
|
||||||
|
List<String> stringValues = Arrays.asList(DELIMITER_PATTERN.split(value));
|
||||||
|
if (stringValues.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Translate values to Integers, validating along the way.
|
||||||
|
List<Integer> intValues = new ArrayList<>();
|
||||||
|
for (String stringInt : stringValues) {
|
||||||
|
intValues.add(parseValue(stringInt));
|
||||||
|
}
|
||||||
|
|
||||||
|
return intValues;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
package org.apache.guacamole.properties;
|
package org.apache.guacamole.properties;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.GuacamoleServerException;
|
import org.apache.guacamole.GuacamoleServerException;
|
||||||
|
|
||||||
@@ -43,4 +46,25 @@ public abstract class LongGuacamoleProperty implements GuacamoleProperty<Long> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Long> parseValueCollection(String value) throws GuacamoleException {
|
||||||
|
|
||||||
|
if (value == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Split string into a list of individual values
|
||||||
|
List<String> stringValues = Arrays.asList(DELIMITER_PATTERN.split(value));
|
||||||
|
if (stringValues.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Translate values to Longs, validating along the way.
|
||||||
|
List<Long> longValues = new ArrayList<>();
|
||||||
|
for (String stringLong : stringValues) {
|
||||||
|
longValues.add(parseValue(stringLong));
|
||||||
|
}
|
||||||
|
|
||||||
|
return longValues;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package org.apache.guacamole.properties;
|
package org.apache.guacamole.properties;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,4 +33,19 @@ public abstract class StringGuacamoleProperty implements GuacamoleProperty<Strin
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> parseValueCollection(String value) throws GuacamoleException {
|
||||||
|
|
||||||
|
if (value == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Split string into a list of individual values
|
||||||
|
List<String> stringValues = Arrays.asList(DELIMITER_PATTERN.split(value));
|
||||||
|
if (stringValues.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return stringValues;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -31,17 +31,14 @@ import org.apache.guacamole.GuacamoleException;
|
|||||||
* compatibility with the behavior of Java properties in general, only
|
* compatibility with the behavior of Java properties in general, only
|
||||||
* whitespace at the beginning of each value is ignored; trailing whitespace
|
* whitespace at the beginning of each value is ignored; trailing whitespace
|
||||||
* becomes part of the value.
|
* becomes part of the value.
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
|
* This class is now deprecated in favor of using the StringGuacamoleProperty
|
||||||
|
* class with the parseValueCollection method.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public abstract class StringListProperty implements GuacamoleProperty<List<String>> {
|
public abstract class StringListProperty implements GuacamoleProperty<List<String>> {
|
||||||
|
|
||||||
/**
|
|
||||||
* A pattern which matches against the delimiters between values. This is
|
|
||||||
* currently simply a comma and any following whitespace. Parts of the
|
|
||||||
* input string which match this pattern will not be included in the parsed
|
|
||||||
* result.
|
|
||||||
*/
|
|
||||||
private static final Pattern DELIMITER_PATTERN = Pattern.compile(",\\s*");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> parseValue(String values) throws GuacamoleException {
|
public List<String> parseValue(String values) throws GuacamoleException {
|
||||||
|
|
||||||
|
@@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
package org.apache.guacamole.properties;
|
package org.apache.guacamole.properties;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
@@ -57,4 +60,25 @@ public abstract class TimeZoneGuacamoleProperty
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TimeZone> parseValueCollection(String value) throws GuacamoleException {
|
||||||
|
|
||||||
|
if (value == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Split string into a list of individual values
|
||||||
|
List<String> stringValues = Arrays.asList(DELIMITER_PATTERN.split(value));
|
||||||
|
if (stringValues.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Translate values to Integers, validating along the way.
|
||||||
|
List<TimeZone> tzValues = new ArrayList<>();
|
||||||
|
for (String stringTz : stringValues) {
|
||||||
|
tzValues.add(parseValue(stringTz));
|
||||||
|
}
|
||||||
|
|
||||||
|
return tzValues;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,9 @@ package org.apache.guacamole.properties;
|
|||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.GuacamoleServerException;
|
import org.apache.guacamole.GuacamoleServerException;
|
||||||
|
|
||||||
@@ -46,4 +49,26 @@ public abstract class URIGuacamoleProperty implements GuacamoleProperty<URI> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<URI> parseValueCollection(String value) throws GuacamoleException {
|
||||||
|
|
||||||
|
// Nothing provided, return nothing.
|
||||||
|
if (value == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Split string into a list of individual values
|
||||||
|
List<String> stringValues = Arrays.asList(DELIMITER_PATTERN.split(value));
|
||||||
|
if (stringValues.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// Translate values to URIs, validating along the way.
|
||||||
|
List<URI> uriValues = new ArrayList<>();
|
||||||
|
for (String stringUri : stringValues) {
|
||||||
|
uriValues.add(parseValue(stringUri));
|
||||||
|
}
|
||||||
|
|
||||||
|
return uriValues;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user