guacamole-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mjum...@apache.org
Subject [01/50] incubator-guacamole-client git commit: GUAC-1451: Add standard GUAC_DATE and GUAC_TIME parameter tokens.
Date Sun, 20 Mar 2016 02:21:41 GMT
Repository: incubator-guacamole-client
Updated Branches:
  refs/heads/master [created] 2358d8868


GUAC-1451: Add standard GUAC_DATE and GUAC_TIME parameter 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/22f650b4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/22f650b4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/22f650b4

Branch: refs/heads/master
Commit: 22f650b4f7d9dcebe34a4a2293e18099b0db8bf4
Parents: 4fc5da5
Author: Michael Jumper <mike.jumper@guac-dev.org>
Authored: Fri Jan 22 11:39:51 2016 -0800
Committer: Michael Jumper <mike.jumper@guac-dev.org>
Committed: Fri Jan 22 11:39:51 2016 -0800

----------------------------------------------------------------------
 .../guacamole/token/StandardTokens.java         | 53 ++++++++++++++++----
 1 file changed, 42 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/22f650b4/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 31b2c4e..6029209 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
@@ -1,16 +1,16 @@
 /*
- * Copyright (C) 2015 Glyptodon LLC
- * 
+ * Copyright (C) 2016 Glyptodon LLC
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
  * in the Software without restriction, including without limitation the rights
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  * copies of the Software, and to permit persons to whom the Software is
  * furnished to do so, subject to the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,6 +22,8 @@
 
 package org.glyptodon.guacamole.token;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import org.glyptodon.guacamole.net.auth.Credentials;
 
 /**
@@ -43,14 +45,40 @@ public class StandardTokens {
     private static final String PASSWORD_TOKEN = "GUAC_PASSWORD";
 
     /**
+     * The name of the date token (server-local time) added via
+     * addStandardTokens().
+     */
+    private static final String DATE_TOKEN = "GUAC_DATE";
+
+    /**
+     * The name of the time token (server-local time) added via
+     * addStandardTokens().
+     */
+    private static final String TIME_TOKEN = "GUAC_TIME";
+
+    /**
+     * The date format that should be used for the date token. This format must
+     * be compatible with Java's SimpleDateFormat.
+     */
+    private static final String DATE_FORMAT = "yyyyMMdd";
+
+    /**
+     * The date format that should be used for the time token. This format must
+     * be compatible with Java's SimpleDateFormat.
+     */
+    private static final String TIME_FORMAT = "HHmmss";
+
+    /**
      * This utility class should not be instantiated.
      */
     private StandardTokens() {}
 
     /**
-     * Adds the standard username (GUAC_USERNAME) and password (GUAC_PASSWORD)
-     * tokens to the given TokenFilter using the values from the given
-     * Credentials object. If either the username or password are not set
+     * 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
+     * GUAC_TIME respectively). If either the username or password are not set
      * within the given credentials, the corresponding token(s) will remain
      * unset.
      *
@@ -59,7 +87,6 @@ public class StandardTokens {
      *
      * @param credentials
      *     The Credentials containing the username/password to add.
-     *
      */
     public static void addStandardTokens(TokenFilter filter, Credentials credentials) {
 
@@ -67,13 +94,17 @@ public class StandardTokens {
         String username = credentials.getUsername();
         if (username != null)
             filter.setToken(USERNAME_TOKEN, username);
-        
+
         // Add password token
         String password = credentials.getPassword();
         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));
+
     }
-    
 
 }


Mime
View raw message