You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/10/17 17:21:34 UTC

[2/3] guacamole-client git commit: GUACAMOLE-524: Provide convenience constructor for TokenFilter which initializes the filter with provided tokens.

GUACAMOLE-524: Provide convenience constructor for TokenFilter which initializes the filter with provided tokens.


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

Branch: refs/heads/master
Commit: 333a8c411f90f847f50111939089f3d10610ed89
Parents: f3cbdf5
Author: Michael Jumper <mj...@apache.org>
Authored: Tue Oct 16 13:21:57 2018 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Tue Oct 16 14:53:10 2018 -0700

----------------------------------------------------------------------
 .../org/apache/guacamole/token/TokenFilter.java | 23 +++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/333a8c41/guacamole-ext/src/main/java/org/apache/guacamole/token/TokenFilter.java
----------------------------------------------------------------------
diff --git a/guacamole-ext/src/main/java/org/apache/guacamole/token/TokenFilter.java b/guacamole-ext/src/main/java/org/apache/guacamole/token/TokenFilter.java
index ab43622..c412d18 100644
--- a/guacamole-ext/src/main/java/org/apache/guacamole/token/TokenFilter.java
+++ b/guacamole-ext/src/main/java/org/apache/guacamole/token/TokenFilter.java
@@ -19,6 +19,7 @@
 
 package org.apache.guacamole.token;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.regex.Matcher;
@@ -68,7 +69,27 @@ public class TokenFilter {
     /**
      * The values of all known tokens.
      */
-    private final Map<String, String> tokenValues = new HashMap<String, String>();
+    private final Map<String, String> tokenValues;
+
+    /**
+     * Creates a new TokenFilter which has no associated tokens. Tokens must
+     * later be given using {@link #setToken(java.lang.String, java.lang.String)}
+     * or {@link #setTokens(java.util.Map)}.
+     */
+    public TokenFilter() {
+         this(Collections.<String, String>emptyMap());
+    }
+
+    /**
+     * Creates a new TokenFilter which is initialized with the given token
+     * name/value pairs.
+     *
+     * @param tokenValues
+     *     A map containing token names and their corresponding values.
+     */
+    public TokenFilter(Map<String, String> tokenValues) {
+        this.tokenValues = new HashMap<>(tokenValues);
+    }
 
     /**
      * Sets the token having the given name to the given value. Any existing