forked from shaba/openuds
Replace complex "udsfile" logic with simplified "uds-base-url" property.
This commit is contained in:
parent
4cc11d783a
commit
857f8602b8
@ -78,7 +78,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.guacamole</groupId>
|
<groupId>org.apache.guacamole</groupId>
|
||||||
<artifactId>guacamole-ext</artifactId>
|
<artifactId>guacamole-ext</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.2.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ import java.net.URISyntaxException;
|
|||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.GuacamoleServerException;
|
import org.apache.guacamole.GuacamoleServerException;
|
||||||
import org.apache.guacamole.environment.Environment;
|
import org.apache.guacamole.environment.Environment;
|
||||||
import org.apache.guacamole.properties.StringGuacamoleProperty;
|
import org.apache.guacamole.properties.URIGuacamoleProperty;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -55,26 +55,18 @@ public class ConfigurationService {
|
|||||||
private final Logger logger = LoggerFactory.getLogger(ConfigurationService.class);
|
private final Logger logger = LoggerFactory.getLogger(ConfigurationService.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the property within tunnel.properties which defines the file
|
* The name of the property within guacamole.properties which defines the
|
||||||
* whose content dictates the base URL of the service providing connection
|
* base URL of the service providing connection configuration information.
|
||||||
* configuration information.
|
|
||||||
*/
|
*/
|
||||||
private static final StringGuacamoleProperty UDSFILE_PROPERTY = new StringGuacamoleProperty() {
|
private static final URIGuacamoleProperty UDS_BASE_URL_PROPERTY = new URIGuacamoleProperty() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "udsfile";
|
return "uds-base-url";
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* The path beneath the OpenUDS service base URI (scheme + hostname) at
|
|
||||||
* which the connection configuration service can be found. Currently, this
|
|
||||||
* is hard-coded as "/guacamole/".
|
|
||||||
*/
|
|
||||||
private static final String UDS_CONNECTION_PATH = "/guacamole/";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Guacamole server environment.
|
* The Guacamole server environment.
|
||||||
*/
|
*/
|
||||||
@ -137,34 +129,6 @@ public class ConfigurationService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Given an arbitrary URI, returns a new URI which contains only the scheme
|
|
||||||
* and host. The path, fragment, etc. of the given URI, if any, are
|
|
||||||
* discarded.
|
|
||||||
*
|
|
||||||
* @param uri
|
|
||||||
* An arbitrary URI from which a base URI should be derived.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* A new URI containing only the scheme and host of the provided URI.
|
|
||||||
*
|
|
||||||
* @throws GuacamoleException
|
|
||||||
* If the new URI could not be generated because the result is not a
|
|
||||||
* valid URI.
|
|
||||||
*/
|
|
||||||
private URI getBaseURI(URI uri) throws GuacamoleException {
|
|
||||||
|
|
||||||
// Build base URI from only the scheme and host of the given URI
|
|
||||||
try {
|
|
||||||
return new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(),
|
|
||||||
null, null, null);
|
|
||||||
}
|
|
||||||
catch (URISyntaxException e) {
|
|
||||||
throw new GuacamoleServerException("Failed to derive base URI.", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the base URI of the OpenUDS service. All services providing data
|
* Returns the base URI of the OpenUDS service. All services providing data
|
||||||
* to this Guacamole integration are hosted beneath this base URI.
|
* to this Guacamole integration are hosted beneath this base URI.
|
||||||
@ -178,27 +142,7 @@ public class ConfigurationService {
|
|||||||
* started.
|
* started.
|
||||||
*/
|
*/
|
||||||
public URI getUDSBaseURI() throws GuacamoleException {
|
public URI getUDSBaseURI() throws GuacamoleException {
|
||||||
|
return environment.getRequiredProperty(UDS_BASE_URL_PROPERTY);
|
||||||
// Parse URI from the UDS file (if defined)
|
|
||||||
String udsFile = environment.getRequiredProperty(UDSFILE_PROPERTY);
|
|
||||||
|
|
||||||
// Attempt to parse base URI from the UDS file
|
|
||||||
return getBaseURI(readServiceURI(udsFile));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the path beneath the OpenUDS base URI at which the connection
|
|
||||||
* configuration service can be found. This service is expected to respond
|
|
||||||
* to HTTP GET requests, returning the configuration of requested
|
|
||||||
* connections.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* The path beneath the OpenUDS base URI at which the connection
|
|
||||||
* configuration service can be found.
|
|
||||||
*/
|
|
||||||
public String getUDSConnectionPath() {
|
|
||||||
return UDS_CONNECTION_PATH;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,6 @@ public class ConnectionService {
|
|||||||
|
|
||||||
// Build URI of remote service from the base URI and given data
|
// Build URI of remote service from the base URI and given data
|
||||||
URI serviceURI = UriBuilder.fromUri(configService.getUDSBaseURI())
|
URI serviceURI = UriBuilder.fromUri(configService.getUDSBaseURI())
|
||||||
.path(configService.getUDSConnectionPath())
|
|
||||||
.path(data)
|
.path(data)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
"guacamoleVersion" : "1.1.0",
|
"guacamoleVersion" : "1.2.0",
|
||||||
|
|
||||||
"name" : "UDS Integration Extension for Apache Guacamole",
|
"name" : "UDS Integration Extension for Apache Guacamole",
|
||||||
"namespace" : "uds",
|
"namespace" : "uds",
|
||||||
|
Loading…
Reference in New Issue
Block a user