GUACAMOLE-422: Add timezone to tunnel connections.

This commit is contained in:
Nick Couchman
2018-06-03 14:59:47 -04:00
committed by Virtually Nick
parent 8ad65d6e6c
commit 047ed7ac9c
4 changed files with 56 additions and 1 deletions

View File

@@ -476,6 +476,15 @@ public abstract class AbstractGuacamoleTunnelService implements GuacamoleTunnelS
activeConnections.put(connection.getIdentifier(), activeConnection); activeConnections.put(connection.getIdentifier(), activeConnection);
activeConnectionGroups.put(connection.getParentIdentifier(), activeConnection); activeConnectionGroups.put(connection.getParentIdentifier(), activeConnection);
config = getGuacamoleConfiguration(activeConnection.getUser(), connection); config = getGuacamoleConfiguration(activeConnection.getUser(), connection);
// If timezone is provided by tunnel parameter, and not
// overriden by connection parameter, set it.
String tzTunnel = info.getTimezone();
String tzParam = config.getParameter("timezone");
if ((tzParam == null || tzParam.isEmpty())
&& tzTunnel != null && !tzTunnel.isEmpty())
config.setParameter("timezone", tzTunnel);
} }
// If we ARE joining an active connection, generate a configuration // If we ARE joining an active connection, generate a configuration

View File

@@ -59,6 +59,11 @@ public class GuacamoleClientInformation {
*/ */
private final List<String> imageMimetypes = new ArrayList<String>(); private final List<String> imageMimetypes = new ArrayList<String>();
/**
* The timezone report by the client.
*/
private String timezone = "";
/** /**
* Returns the optimal screen width requested by the client, in pixels. * Returns the optimal screen width requested by the client, in pixels.
* @return The optimal screen width requested by the client, in pixels. * @return The optimal screen width requested by the client, in pixels.
@@ -145,4 +150,24 @@ public class GuacamoleClientInformation {
return imageMimetypes; return imageMimetypes;
} }
/**
* Return the timezone as reported by the client.
*
* @returns
* A string value of the timezone reported by the client.
*/
public String getTimezone() {
return timezone;
}
/**
* Set the string value of the timezone.
*
* @param timezone
* The string value of the timezone reported by the client.
*/
public void setTimezone(String timezone) {
this.timezone = timezone;
}
} }

View File

@@ -96,6 +96,11 @@ public abstract class TunnelRequest {
*/ */
public static final String IMAGE_PARAMETER = "GUAC_IMAGE"; public static final String IMAGE_PARAMETER = "GUAC_IMAGE";
/**
* The name of the parameter specifying the timezone of the client.
*/
public static final String TIMEZONE_PARAMETER = "GUAC_TIMEZONE";
/** /**
* All supported object types that can be used as the destination of a * All supported object types that can be used as the destination of a
* tunnel. * tunnel.
@@ -366,4 +371,15 @@ public abstract class TunnelRequest {
return getParameterValues(IMAGE_PARAMETER); return getParameterValues(IMAGE_PARAMETER);
} }
/**
* Returns the value of the timezone parameter declared within the
* tunnel request.
*
* @return
* The string value of the timezone parameter as reported by
* the client.
*/
public String getTimezone() {
return getParameter(TIMEZONE_PARAMETER);
}
} }

View File

@@ -167,6 +167,11 @@ public class TunnelRequestService {
if (imageMimetypes != null) if (imageMimetypes != null)
info.getImageMimetypes().addAll(imageMimetypes); info.getImageMimetypes().addAll(imageMimetypes);
// Get the timezone value
String timezone = request.getTimezone();
if (timezone != null & !timezone.isEmpty())
info.setTimezone(timezone);
return info; return info;
} }