I tried to build a demo guacamole app for ssh from the below tutorial.
http://guac-dev.org/doc/gug/writing-you-own-guacamole-app.html
The app worked just fine as long as the values were hardcoded. But I need to get the hostname/IP from the user. To achieve that I tried using request.getParameter() in the below code :
package org.glyptodon.guacamole.net.example;
import javax.servlet.http.HttpServletRequest;
import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.net.GuacamoleSocket;
import org.glyptodon.guacamole.net.GuacamoleTunnel;
import org.glyptodon.guacamole.net.InetGuacamoleSocket;
import org.glyptodon.guacamole.net.SimpleGuacamoleTunnel;
import org.glyptodon.guacamole.protocol.ConfiguredGuacamoleSocket;
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
import org.glyptodon.guacamole.servlet.GuacamoleHTTPTunnelServlet;
public class TutorialGuacamoleTunnelServlet
extends GuacamoleHTTPTunnelServlet {
@Override
protected GuacamoleTunnel doConnect(HttpServletRequest request)
throws GuacamoleException {
// Create our configuration
String hostname = request.getParameter("hostname");
GuacamoleConfiguration config = new GuacamoleConfiguration();
config.setProtocol("ssh");
config.setParameter("hostname", hostname);
config.setParameter("port", "22");
// Connect to guacd - everything is hard-coded here.
GuacamoleSocket socket = new ConfiguredGuacamoleSocket(
new InetGuacamoleSocket("localhost", 4822),
config
);
// Return a new tunnel which uses the connected socket
return new SimpleGuacamoleTunnel(socket);
}
}
But when I try to use it like localhost:8080/guacamole-tutorial-0.9.9?hostname=localhost, it doesn't work. Whereas it works just fine if I hardcode the same values. Please help me out.