GUAC-1451: Do not require Credentials for adding standard tokens.

This commit is contained in:
Michael Jumper
2016-01-22 11:47:37 -08:00
parent 22f650b4f7
commit 7789fe89d7

View File

@@ -73,6 +73,23 @@ public class StandardTokens {
*/ */
private StandardTokens() {} private StandardTokens() {}
/**
* Adds tokens which are standardized by guacamole-ext to the given
* TokenFilter and which do not require a corresponding Credentials object.
* These the server date and time (GUAC_DATE and GUAC_TIME respectively).
*
* @param filter
* The TokenFilter to add standard tokens to.
*/
public static void addStandardTokens(TokenFilter filter) {
// Add date/time tokens (server-local time)
Date currentTime = new Date();
filter.setToken(DATE_TOKEN, new SimpleDateFormat(DATE_FORMAT).format(currentTime));
filter.setToken(TIME_TOKEN, new SimpleDateFormat(TIME_FORMAT).format(currentTime));
}
/** /**
* Adds tokens which are standardized by guacamole-ext to the given * Adds tokens which are standardized by guacamole-ext to the given
* TokenFilter using the values from the given Credentials object. These * TokenFilter using the values from the given Credentials object. These
@@ -83,10 +100,11 @@ public class StandardTokens {
* unset. * unset.
* *
* @param filter * @param filter
* The TokenFilter to add standard username/password tokens to. * The TokenFilter to add standard tokens to.
* *
* @param credentials * @param credentials
* The Credentials containing the username/password to add. * The Credentials to use when populating the GUAC_USERNAME and
* GUAC_PASSWORD tokens.
*/ */
public static void addStandardTokens(TokenFilter filter, Credentials credentials) { public static void addStandardTokens(TokenFilter filter, Credentials credentials) {
@@ -100,10 +118,8 @@ public class StandardTokens {
if (password != null) if (password != null)
filter.setToken(PASSWORD_TOKEN, password); filter.setToken(PASSWORD_TOKEN, password);
// Add date/time tokens (server-local time) // Add any tokens which do not require credentials
Date currentTime = new Date(); addStandardTokens(filter);
filter.setToken(DATE_TOKEN, new SimpleDateFormat(DATE_FORMAT).format(currentTime));
filter.setToken(TIME_TOKEN, new SimpleDateFormat(TIME_FORMAT).format(currentTime));
} }