GUACAMOLE-38: Remove default protocol and port, throw errors if not specified.

This commit is contained in:
Nick Couchman
2018-05-21 09:56:50 -04:00
parent 84e71a029c
commit 8c130215f4

View File

@@ -41,17 +41,6 @@ import org.apache.guacamole.protocol.GuacamoleConfiguration;
*/ */
public class QCParser { public class QCParser {
/**
* The default protocol to use if one is not provided in
* the incoming URI.
*/
public static final String DEFAULT_URI_PROTOCOL = "ssh";
/**
* The default host to use if one is not defined.
*/
public static final String DEFAULT_URI_HOST = "localhost";
/** /**
* The regex to use to split username and password. * The regex to use to split username and password.
*/ */
@@ -89,6 +78,8 @@ public class QCParser {
URI qcUri; URI qcUri;
try { try {
qcUri = new URI(uri); qcUri = new URI(uri);
if (!qcUri.isAbsolute())
throw new GuacamoleClientException("URI must be absolute.");
} }
catch (URISyntaxException e) { catch (URISyntaxException e) {
throw new GuacamoleClientException("Invalid URI Syntax", e); throw new GuacamoleClientException("Invalid URI Syntax", e);
@@ -108,7 +99,7 @@ public class QCParser {
if (protocol != null && !protocol.isEmpty()) if (protocol != null && !protocol.isEmpty())
qcConfig.setProtocol(protocol); qcConfig.setProtocol(protocol);
else else
qcConfig.setProtocol(DEFAULT_URI_PROTOCOL); throw new GuacamoleClientException("No protocol specified.");
// Check for provided port number // Check for provided port number
if (port > 0) if (port > 0)
@@ -118,7 +109,7 @@ public class QCParser {
if (host != null && !host.isEmpty()) if (host != null && !host.isEmpty())
qcConfig.setParameter("hostname", host); qcConfig.setParameter("hostname", host);
else else
qcConfig.setParameter("hostname", DEFAULT_URI_HOST); throw new GuacamoleClientException("No host specified.");
// Look for extra query parameters and parse them out. // Look for extra query parameters and parse them out.
if (query != null && !query.isEmpty()) { if (query != null && !query.isEmpty()) {