diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/auth/package-info.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/auth/package-info.java
new file mode 100644
index 000000000..f40e4544e
--- /dev/null
+++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/auth/package-info.java
@@ -0,0 +1,6 @@
+
+/**
+ * Classes related to the authentication aspect of the Guacamole REST API.
+ */
+package org.glyptodon.guacamole.net.basic.rest;
+
diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnection.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnection.java
index 0e78f3fcc..14a610aeb 100644
--- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnection.java
+++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnection.java
@@ -18,20 +18,19 @@ package org.glyptodon.guacamole.net.basic.rest.connection;
* along with this program. If not, see .
*/
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.glyptodon.guacamole.GuacamoleException;
-import org.glyptodon.guacamole.net.GuacamoleSocket;
import org.glyptodon.guacamole.net.auth.Connection;
import org.glyptodon.guacamole.net.auth.ConnectionRecord;
-import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;
-import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
/**
* A simple connection to expose through the REST endpoints.
*
* @author James Muehlner
*/
-public class APIConnection implements Connection {
+public class APIConnection {
/**
* The name of this connection.
@@ -43,15 +42,15 @@ public class APIConnection implements Connection {
*/
private String identifier;
- /**
- * The configuration associated with this connection.
- */
- private GuacamoleConfiguration configuration;
-
/**
* The history records associated with this connection.
*/
private List extends ConnectionRecord> history;
+
+ /**
+ * Map of all associated parameter values, indexed by parameter name.
+ */
+ private Map parameters = new HashMap();
/**
* Create an empty APIConnection.
@@ -68,55 +67,61 @@ public class APIConnection implements Connection {
throws GuacamoleException {
this.name = connection.getName();
this.identifier = connection.getIdentifier();
- this.configuration = connection.getConfiguration();
this.history = connection.getHistory();
}
- @Override
+ /**
+ * Returns the name of this connection.
+ * @return The name of this connection.
+ */
public String getName() {
return name;
}
- @Override
+ /**
+ * Set the name of this connection.
+ * @param name The name of this connection.
+ */
public void setName(String name) {
this.name = name;
}
- @Override
+
+ /**
+ * Returns the unique identifier for this connection.
+ * @return The unique identifier for this connection.
+ */
public String getIdentifier() {
return identifier;
}
-
- @Override
+ /**
+ * Sets the unique identifier for this connection.
+ */
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
- @Override
- public GuacamoleConfiguration getConfiguration() {
- return configuration;
- }
-
- @Override
- public void setConfiguration(GuacamoleConfiguration configuration) {
- this.configuration = configuration;
- }
-
- @Override
+ /**
+ * Returns the history records associated with this connection.
+ * @return The history records associated with this connection.
+ */
public List extends ConnectionRecord> getHistory() {
return history;
}
/**
- * Set the history records for this connection.
- * @param history The history records for this connection.
+ * Returns the parameter map for this connection.
+ * @return The parameter map for this connection.
*/
- public void setHistory(List extends ConnectionRecord> history) {
- this.history = history;
+ public Map getParameters() {
+ return parameters;
}
- @Override
- public GuacamoleSocket connect(GuacamoleClientInformation info) throws GuacamoleException {
- throw new UnsupportedOperationException("Not supported.");
+ /**
+ * Sets the parameter map for this connection.
+ * @param parameters The parameter map for this connection.
+ */
+ public void setParameters(Map parameters) {
+ this.parameters = parameters;
}
}
diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnectionWrapper.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnectionWrapper.java
new file mode 100644
index 000000000..0b9404ac6
--- /dev/null
+++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnectionWrapper.java
@@ -0,0 +1,100 @@
+package org.glyptodon.guacamole.net.basic.rest.connection;
+
+/*
+ * Guacamole - Clientless Remote Desktop
+ * Copyright (C) 2010 Michael Jumper
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.glyptodon.guacamole.GuacamoleException;
+import org.glyptodon.guacamole.net.GuacamoleSocket;
+import org.glyptodon.guacamole.net.auth.Connection;
+import org.glyptodon.guacamole.net.auth.ConnectionRecord;
+import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;
+import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
+
+/**
+ * A wrapper to make an APIConnection look like a Connection. Useful where a
+ * org.glyptodon.guacamole.net.auth.Connection is required.
+ *
+ * @author James Muehlner
+ */
+public class APIConnectionWrapper implements Connection {
+
+ private final APIConnection apiConnection;
+
+ public APIConnectionWrapper(APIConnection apiConnection) {
+ this.apiConnection = apiConnection;
+ }
+
+ @Override
+ public String getName() {
+ return apiConnection.getName();
+ }
+
+ @Override
+ public void setName(String name) {
+ apiConnection.setName(name);
+ }
+
+ @Override
+ public String getIdentifier() {
+ return apiConnection.getIdentifier();
+ }
+
+ @Override
+ public void setIdentifier(String identifier) {
+ apiConnection.setIdentifier(identifier);
+ }
+
+ @Override
+ public GuacamoleConfiguration getConfiguration() {
+
+ // Create the GuacamoleConfiguration from the parameter map
+ GuacamoleConfiguration configuration = new GuacamoleConfiguration();
+
+ Map parameters = apiConnection.getParameters();
+
+ for(String key : parameters.keySet())
+ configuration.setParameter(key, parameters.get(key));
+
+ return configuration;
+ }
+
+ @Override
+ public void setConfiguration(GuacamoleConfiguration config) {
+
+ // Create a parameter map from the GuacamoleConfiguration
+ Map newParameters = new HashMap();
+ for(String key : config.getParameterNames())
+ newParameters.put(key, config.getParameter(key));
+
+ apiConnection.setParameters(newParameters);
+ }
+
+ @Override
+ public GuacamoleSocket connect(GuacamoleClientInformation info) throws GuacamoleException {
+ throw new UnsupportedOperationException("Operation not supported.");
+ }
+
+ @Override
+ public List extends ConnectionRecord> getHistory() throws GuacamoleException {
+ return apiConnection.getHistory();
+ }
+
+}
diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/ConnectionRESTService.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/ConnectionRESTService.java
index 9a081650f..c1ddc1e1c 100644
--- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/ConnectionRESTService.java
+++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/ConnectionRESTService.java
@@ -231,7 +231,7 @@ public class ConnectionRESTService {
parentConnectionGroup.getConnectionDirectory();
// Create the connection
- connectionDirectory.add(connection);
+ connectionDirectory.add(new APIConnectionWrapper(connection));
// Return the new connection identifier
return connection.getIdentifier();
@@ -273,7 +273,7 @@ public class ConnectionRESTService {
throw new GuacamoleClientException("No Connection with the provided ID.");
// Update the connection
- connectionDirectory.update(connection);
+ connectionDirectory.update(new APIConnectionWrapper(connection));
} catch(GuacamoleSecurityException e) {
throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied.");
} catch(GuacamoleClientException e) {
diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/package-info.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/package-info.java
new file mode 100644
index 000000000..8e4dcfde6
--- /dev/null
+++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/package-info.java
@@ -0,0 +1,6 @@
+
+/**
+ * Classes related to the connection manipulation aspect of the Guacamole REST API.
+ */
+package org.glyptodon.guacamole.net.basic.rest.connection;
+
diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/package-info.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/package-info.java
new file mode 100644
index 000000000..3abc5554b
--- /dev/null
+++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/package-info.java
@@ -0,0 +1,6 @@
+
+/**
+ * Classes related to the basic Guacamole REST API.
+ */
+package org.glyptodon.guacamole.net.basic.rest;
+