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

Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/7789fe89
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/7789fe89
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/7789fe89

Branch: refs/heads/master
Commit: 7789fe89d70f37d3800a552c8f57cb7158c1d69d
Parents: 22f650b
Author: Michael Jumper <[email protected]>
Authored: Fri Jan 22 11:47:37 2016 -0800
Committer: Michael Jumper <[email protected]>
Committed: Fri Jan 22 11:47:37 2016 -0800

----------------------------------------------------------------------
 .../guacamole/token/StandardTokens.java         | 28 +++++++++++++++-----
 1 file changed, 22 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/7789fe89/guacamole-ext/src/main/java/org/glyptodon/guacamole/token/StandardTokens.java
----------------------------------------------------------------------
diff --git 
a/guacamole-ext/src/main/java/org/glyptodon/guacamole/token/StandardTokens.java 
b/guacamole-ext/src/main/java/org/glyptodon/guacamole/token/StandardTokens.java
index 6029209..e899e80 100644
--- 
a/guacamole-ext/src/main/java/org/glyptodon/guacamole/token/StandardTokens.java
+++ 
b/guacamole-ext/src/main/java/org/glyptodon/guacamole/token/StandardTokens.java
@@ -75,6 +75,23 @@ public class 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
      * TokenFilter using the values from the given Credentials object. These
      * standardized tokens include the current username (GUAC_USERNAME),
      * password (GUAC_PASSWORD), and the server date and time (GUAC_DATE and
@@ -83,10 +100,11 @@ public class StandardTokens {
      * unset.
      *
      * @param filter
-     *     The TokenFilter to add standard username/password tokens to.
+     *     The TokenFilter to add standard tokens to.
      *
      * @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) {
 
@@ -100,10 +118,8 @@ public class StandardTokens {
         if (password != null)
             filter.setToken(PASSWORD_TOKEN, password);
 
-        // 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));
+        // Add any tokens which do not require credentials
+        addStandardTokens(filter);
 
     }
 

Reply via email to