On Tue, Aug 20, 2024 at 5:52 AM David Lomas <d...@pale-eds.co.uk.invalid>
wrote:

> Hi Nick & Mike,
>
> So, some progress, and I'm also a bit confused by what I had to do to get
> this to work. This is my custom connect() method, and the various calls to
> get configuration information:
>
> @Override
> public GuacamoleTunnel connect(GuacamoleClientInformation info,
> Map<String, String> tokens) throws GuacamoleException {
>
>     tokens = new HashMap<>(tokens);
>     GuacamoleTunnel tunnel = super.connect(info, tokens);
>     UUID tunnelUUID = tunnel.getUUID();
>     UserContext privilegedUserContext = userContext.getPrivileged();
>     Directory<ActiveConnection> activeConnectionDirectory =
> privilegedUserContext.getActiveConnectionDirectory();
>     ActiveConnection activeConnection =
> activeConnectionDirectory.get(tunnelUUID.toString());
>     String connectionIdentifier =
> activeConnection.getConnectionIdentifier();
>     Directory<Connection> connectionDirectory =
> privilegedUserContext.getConnectionDirectory();
>     Connection connection = connectionDirectory.get(connectionIdentifier);
>     GuacamoleConfiguration config = connection.getConfiguration();
>
>     logger.info("********** [CustomUserContext] tunnel: {}", tunnel);
>     logger.info("********** [CustomUserContext] tunnelUUID: {}",
> tunnelUUID);
>     logger.info("********** [CustomUserContext] privilegedUserContext:
> {}", privilegedUserContext);
>     logger.info("********** [CustomUserContext]
> activeConnectionDirectory: {}", activeConnectionDirectory);
>     logger.info("********** [CustomUserContext] activeConnection: {}",
> activeConnection);
>     logger.info("********** [CustomUserContext] connectionIdentifier:
> {}", connectionIdentifier);
>     logger.info("********** [CustomUserContext] connectionDirectory: {}",
> connectionDirectory);
>     logger.info("********** [CustomUserContext] connection: {}",
> connection);
>     logger.info("********** [CustomUserContext] config: {}", config);
>
>     logger.info("********** [CustomUserContext]   config.getProtocol:
> {}", config.getProtocol());
>     logger.info("********** [CustomUserContext]
> config.getParameterNames: {}", config.getParameterNames());
>     logger.info("********** [CustomUserContext]
> config.getParameter(\"hostname\"): {}", config.getParameter("hostname"));
>
>     return tunnel;
> }
>
> The logging output of all of that is:
>
> ********** [CustomUserContext] tunnel:
> org.apache.guacamole.auth.jdbc.tunnel.ActiveConnectionRecord$2@60d7a730
> ********** [CustomUserContext] tunnelUUID:
> 7380abce-a220-36f5-a67b-b3272d2854ec
> ********** [CustomUserContext] privilegedUserContext:
> org.apache.guacamole.auth.jdbc.user.ModeledUserContext@4ff5d3ff
> ********** [CustomUserContext] activeConnectionDirectory:
> org.apache.guacamole.auth.jdbc.activeconnection.ActiveConnectionDirectory@1148447a
> ********** [CustomUserContext] activeConnection:
> org.apache.guacamole.auth.jdbc.activeconnection.TrackedActiveConnection@754e2efa
> ********** [CustomUserContext] connectionIdentifier: 1
> ********** [CustomUserContext] connectionDirectory:
> org.apache.guacamole.auth.jdbc.connection.ConnectionDirectory$$EnhancerByGuice$$2150384@287df944
> ********** [CustomUserContext] connection:
> org.apache.guacamole.auth.jdbc.connection.ModeledConnection@49f6bd9f
> ********** [CustomUserContext] config:
> org.apache.guacamole.auth.jdbc.connection.ModeledGuacamoleConfiguration@1a4e5b4f
> ********** [CustomUserContext]   config.getProtocol: rdp
> ********** [CustomUserContext]   config.getParameterNames: []
> ********** [CustomUserContext]   config.getParameter("hostname"): null
>
> At this point I thought I was stuck—maybe the jdbc extension wasn't going
> to expose what I needed. As one last ditch attempt, I tried this:
>
> logger.info("********** [CustomUserContext]   config.getProtocol: {}",
> config.getProtocol());
> logger.info("********** [CustomUserContext]   config.getParameterNames:
> {}", config.getParameterNames());
> logger.info("********** [CustomUserContext]   config.getParameters: {}",
> config.getParameters());
> logger.info("********** [CustomUserContext]
> config.getParameter(\"hostname\"): {}", config.getParameter("hostname"));
>
> and now the output looks like this:
>
> ********** [CustomUserContext]   config.getProtocol: rdp
> ********** [CustomUserContext]   config.getParameterNames: []
> ********** [CustomUserContext]   config.getParameters:
> {hostname=10.0.0.130, password=[snip], security=nla, ignore-cert=true,
> port=3389, server-layout=en-gb-qwerty, enable-audio-input=true,
> username=[snip]}
> ********** [CustomUserContext]   config.getParameter("hostname"):
> 10.0.0.130
>
> so it seems I _can_ get the hostname, but only by calling getParameters()
> before getParameter(). Looking at the source code for
> ModeledGuacamoleConfiguration it seems like this is how it's supposed to
> work, but I just wanted to check before relying on it.
>
>
Yeah, I think that is by design. This is quite a roundabout way of you
getting the data you need, but, unfortunately, what is available at the
moment. Glad you got it going, and thank you for posting back, here, with
the solution, for any others that might be looking for things kind of
functionality!

-Nick

>

Reply via email to