GUACAMOLE-292: Define and use standard attributes for user full name and email.


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/9634731f
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/9634731f
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/9634731f

Branch: refs/heads/master
Commit: 9634731fe69c9ce1501880cd6bf38fd755eb9e72
Parents: e9549fb
Author: Michael Jumper <[email protected]>
Authored: Fri Feb 24 01:50:26 2017 -0800
Committer: Michael Jumper <[email protected]>
Committed: Sat May 27 11:28:13 2017 -0700

----------------------------------------------------------------------
 .../guacamole/auth/jdbc/user/ModeledUser.java   | 23 +++++-------------
 .../src/main/resources/translations/en.json     |  2 --
 .../org/apache/guacamole/net/auth/User.java     | 21 ++++++++++++++++
 .../src/main/webapp/app/rest/types/User.js      | 25 ++++++++++++++++++++
 guacamole/src/main/webapp/translations/en.json  |  7 ++++++
 5 files changed, 59 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/9634731f/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/ModeledUser.java
----------------------------------------------------------------------
diff --git 
a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/ModeledUser.java
 
b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/ModeledUser.java
index 1c65827..c2c7f72 100644
--- 
a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/ModeledUser.java
+++ 
b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/user/ModeledUser.java
@@ -67,17 +67,6 @@ public class ModeledUser extends 
ModeledDirectoryObject<UserModel> implements Us
     private static final Logger logger = 
LoggerFactory.getLogger(ModeledUser.class);
 
     /**
-     * The name of the attribute which holds the user's full name, if known.
-     */
-    public static final String FULL_NAME_ATTRIBUTE_NAME = "full-name";
-
-    /**
-     * The name of the attribute which holds the user's email address, if
-     * known.
-     */
-    public static final String EMAIL_ADDRESS_ATTRIBUTE_NAME = "email-address";
-
-    /**
      * The name of the attribute which controls whether a user account is
      * disabled.
      */
@@ -124,8 +113,8 @@ public class ModeledUser extends 
ModeledDirectoryObject<UserModel> implements Us
      * form.
      */
     public static final Form PROFILE = new Form("profile", 
Arrays.<Field>asList(
-        new TextField(FULL_NAME_ATTRIBUTE_NAME),
-        new EmailField(EMAIL_ADDRESS_ATTRIBUTE_NAME)
+        new TextField(User.Attribute.FULL_NAME),
+        new EmailField(User.Attribute.EMAIL_ADDRESS)
     ));
 
     /**
@@ -406,10 +395,10 @@ public class ModeledUser extends 
ModeledDirectoryObject<UserModel> implements Us
     private void putUnrestrictedAttributes(Map<String, String> attributes) {
 
         // Set full name attribute
-        attributes.put(FULL_NAME_ATTRIBUTE_NAME, "Testy McTesterson"); // TODO
+        attributes.put(User.Attribute.FULL_NAME, "Testy McTesterson"); // TODO
 
         // Set email address attribute
-        attributes.put(EMAIL_ADDRESS_ATTRIBUTE_NAME, "[email protected]"); // TODO
+        attributes.put(User.Attribute.EMAIL_ADDRESS, "[email protected]"); // TODO
 
     }
 
@@ -529,10 +518,10 @@ public class ModeledUser extends 
ModeledDirectoryObject<UserModel> implements Us
     private void setUnrestrictedAttributes(Map<String, String> attributes) {
 
         // Translate full name attribute
-        logger.info("FULL NAME: \"{}\"", 
attributes.get(FULL_NAME_ATTRIBUTE_NAME)); // TODO
+        logger.info("FULL NAME: \"{}\"", 
attributes.get(User.Attribute.FULL_NAME)); // TODO
 
         // Translate email address attribute
-        logger.info("EMAIL ADDRESS: \"{}\"", 
attributes.get(EMAIL_ADDRESS_ATTRIBUTE_NAME)); // TODO
+        logger.info("EMAIL ADDRESS: \"{}\"", 
attributes.get(User.Attribute.EMAIL_ADDRESS)); // TODO
 
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/9634731f/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
----------------------------------------------------------------------
diff --git 
a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
 
b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
index c6ce14b..bf73c35 100644
--- 
a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
+++ 
b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en.json
@@ -79,8 +79,6 @@
 
         "FIELD_HEADER_DISABLED"            : "Login disabled:",
         "FIELD_HEADER_EXPIRED"             : "Password expired:",
-        "FIELD_HEADER_EMAIL_ADDRESS"       : "Email address:",
-        "FIELD_HEADER_FULL_NAME"           : "Full name:",
         "FIELD_HEADER_ACCESS_WINDOW_END"   : "Do not allow access after:",
         "FIELD_HEADER_ACCESS_WINDOW_START" : "Allow access after:",
         "FIELD_HEADER_TIMEZONE"            : "User time zone:",

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/9634731f/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/User.java
----------------------------------------------------------------------
diff --git 
a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/User.java 
b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/User.java
index 90167e4..1d36583 100644
--- a/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/User.java
+++ b/guacamole-ext/src/main/java/org/apache/guacamole/net/auth/User.java
@@ -31,6 +31,27 @@ import 
org.apache.guacamole.net.auth.permission.SystemPermissionSet;
 public interface User extends Identifiable {
 
     /**
+     * All standard attribute names with semantics defined by the Guacamole web
+     * application. Extensions may additionally define their own attributes
+     * with completely arbitrary names and semantics, so long as those names do
+     * not conflict with the names listed here. All standard attribute names
+     * have a "guac-" prefix to avoid such conflicts.
+     */
+    public static class Attribute {
+
+        /**
+         * The user's full name.
+         */
+        public static String FULL_NAME = "guac-full-name";
+
+        /**
+         * The email address of the user.
+         */
+        public static String EMAIL_ADDRESS = "guac-email-address";
+
+    }
+
+    /**
      * Returns this user's password. Note that the password returned may be
      * hashed or completely arbitrary.
      *

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/9634731f/guacamole/src/main/webapp/app/rest/types/User.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/rest/types/User.js 
b/guacamole/src/main/webapp/app/rest/types/User.js
index 4a808b1..b6df12b 100644
--- a/guacamole/src/main/webapp/app/rest/types/User.js
+++ b/guacamole/src/main/webapp/app/rest/types/User.js
@@ -64,6 +64,31 @@ angular.module('rest').factory('User', [function 
defineUser() {
 
     };
 
+    /**
+     * All standard attribute names with semantics defined by the Guacamole web
+     * application. Extensions may additionally define their own attributes
+     * with completely arbitrary names and semantics, so long as those names do
+     * not conflict with the names listed here. All standard attribute names
+     * have a "guac-" prefix to avoid such conflicts.
+     */
+    User.Attributes = {
+
+        /**
+         * The user's full name.
+         *
+         * @type String
+         */
+        FULL_NAME : 'guac-full-name',
+
+        /**
+         * The email address of the user.
+         *
+         * @type String
+         */
+        EMAIL_ADDRESS : 'guac-email-address'
+
+    };
+
     return User;
 
 }]);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/9634731f/guacamole/src/main/webapp/translations/en.json
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/translations/en.json 
b/guacamole/src/main/webapp/translations/en.json
index 512524a..79a7ea7 100644
--- a/guacamole/src/main/webapp/translations/en.json
+++ b/guacamole/src/main/webapp/translations/en.json
@@ -697,6 +697,13 @@
 
     },
 
+    "USER_ATTRIBUTES" : {
+
+        "FIELD_HEADER_GUAC_EMAIL_ADDRESS" : "Email address:",
+        "FIELD_HEADER_GUAC_FULL_NAME"     : "Full name:"
+
+    },
+
     "USER_MENU" : {
 
         "ACTION_LOGOUT"             : "@:APP.ACTION_LOGOUT",

Reply via email to