mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
#268: Implement connection/user deletion. Implement connection update.
This commit is contained in:
@@ -22,6 +22,9 @@ import java.io.IOException;
|
|||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import net.sourceforge.guacamole.GuacamoleException;
|
||||||
|
import net.sourceforge.guacamole.net.auth.Connection;
|
||||||
|
import net.sourceforge.guacamole.net.auth.Directory;
|
||||||
import net.sourceforge.guacamole.net.auth.UserContext;
|
import net.sourceforge.guacamole.net.auth.UserContext;
|
||||||
import net.sourceforge.guacamole.net.basic.AuthenticatingHttpServlet;
|
import net.sourceforge.guacamole.net.basic.AuthenticatingHttpServlet;
|
||||||
|
|
||||||
@@ -38,7 +41,22 @@ public class Delete extends AuthenticatingHttpServlet {
|
|||||||
HttpServletRequest request, HttpServletResponse response)
|
HttpServletRequest request, HttpServletResponse response)
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
|
|
||||||
/* FIXME: STUB */
|
// Get ID
|
||||||
|
String identifier = request.getParameter("id");
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
// Attempt to get connection directory
|
||||||
|
Directory<String, Connection> directory =
|
||||||
|
context.getConnectionDirectory();
|
||||||
|
|
||||||
|
// Remove connection
|
||||||
|
directory.remove(identifier);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (GuacamoleException e) {
|
||||||
|
throw new ServletException("Unable to remove connection.", e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,11 +19,16 @@ package net.sourceforge.guacamole.net.basic.crud.connections;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Enumeration;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import net.sourceforge.guacamole.GuacamoleException;
|
||||||
|
import net.sourceforge.guacamole.net.auth.Connection;
|
||||||
|
import net.sourceforge.guacamole.net.auth.Directory;
|
||||||
import net.sourceforge.guacamole.net.auth.UserContext;
|
import net.sourceforge.guacamole.net.auth.UserContext;
|
||||||
import net.sourceforge.guacamole.net.basic.AuthenticatingHttpServlet;
|
import net.sourceforge.guacamole.net.basic.AuthenticatingHttpServlet;
|
||||||
|
import net.sourceforge.guacamole.protocol.GuacamoleConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple HttpServlet which handles connection update.
|
* Simple HttpServlet which handles connection update.
|
||||||
@@ -32,13 +37,58 @@ import net.sourceforge.guacamole.net.basic.AuthenticatingHttpServlet;
|
|||||||
*/
|
*/
|
||||||
public class Update extends AuthenticatingHttpServlet {
|
public class Update extends AuthenticatingHttpServlet {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefix given to a parameter name when that parameter is a protocol-
|
||||||
|
* specific parameter meant for the configuration.
|
||||||
|
*/
|
||||||
|
public static final String PARAMETER_PREFIX = "_";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void authenticatedService(
|
protected void authenticatedService(
|
||||||
UserContext context,
|
UserContext context,
|
||||||
HttpServletRequest request, HttpServletResponse response)
|
HttpServletRequest request, HttpServletResponse response)
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
|
|
||||||
/* FIXME: STUB */
|
// Get ID and protocol
|
||||||
|
String identifier = request.getParameter("id");
|
||||||
|
String protocol = request.getParameter("protocol");
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
// Attempt to get connection directory
|
||||||
|
Directory<String, Connection> directory =
|
||||||
|
context.getConnectionDirectory();
|
||||||
|
|
||||||
|
// Create config
|
||||||
|
GuacamoleConfiguration config = new GuacamoleConfiguration();
|
||||||
|
config.setProtocol(protocol);
|
||||||
|
|
||||||
|
// Load parameters into config
|
||||||
|
Enumeration<String> params = request.getParameterNames();
|
||||||
|
while (params.hasMoreElements()) {
|
||||||
|
|
||||||
|
// If parameter starts with prefix, load corresponding parameter
|
||||||
|
// value into config
|
||||||
|
String param = params.nextElement();
|
||||||
|
if (param.startsWith(PARAMETER_PREFIX))
|
||||||
|
config.setParameter(
|
||||||
|
param.substring(PARAMETER_PREFIX.length()),
|
||||||
|
request.getParameter(param));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create connection skeleton
|
||||||
|
Connection connection = new DummyConnection();
|
||||||
|
connection.setIdentifier(identifier);
|
||||||
|
connection.setConfiguration(config);
|
||||||
|
|
||||||
|
// Update connection
|
||||||
|
directory.update(connection);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (GuacamoleException e) {
|
||||||
|
throw new ServletException("Unable to update connection.", e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,6 +22,9 @@ import java.io.IOException;
|
|||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import net.sourceforge.guacamole.GuacamoleException;
|
||||||
|
import net.sourceforge.guacamole.net.auth.Directory;
|
||||||
|
import net.sourceforge.guacamole.net.auth.User;
|
||||||
import net.sourceforge.guacamole.net.auth.UserContext;
|
import net.sourceforge.guacamole.net.auth.UserContext;
|
||||||
import net.sourceforge.guacamole.net.basic.AuthenticatingHttpServlet;
|
import net.sourceforge.guacamole.net.basic.AuthenticatingHttpServlet;
|
||||||
|
|
||||||
@@ -38,7 +41,21 @@ public class Delete extends AuthenticatingHttpServlet {
|
|||||||
HttpServletRequest request, HttpServletResponse response)
|
HttpServletRequest request, HttpServletResponse response)
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
|
|
||||||
/* FIXME: STUB */
|
// Get username
|
||||||
|
String username = request.getParameter("name");
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
// Attempt to get user directory
|
||||||
|
Directory<String, User> directory = context.getUserDirectory();
|
||||||
|
|
||||||
|
// Remove user
|
||||||
|
directory.remove(username);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (GuacamoleException e) {
|
||||||
|
throw new ServletException("Unable to remove user.", e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user