You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by jm...@apache.org on 2017/05/28 18:03:11 UTC
[05/11] incubator-guacamole-client git commit: GUACAMOLE-292: Add
stub attributes for full name and email.
GUACAMOLE-292: Add stub attributes for 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/afd051e5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/afd051e5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/afd051e5
Branch: refs/heads/master
Commit: afd051e59f947c2d14e29940ddb12ab9e42ee278
Parents: b2871e7
Author: Michael Jumper <mj...@apache.org>
Authored: Wed Feb 22 00:16:14 2017 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Sat May 27 11:28:13 2017 -0700
----------------------------------------------------------------------
.../guacamole/auth/jdbc/user/ModeledUser.java | 64 ++++++++++++++++++++
.../src/main/resources/translations/en.json | 5 +-
2 files changed, 68 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/afd051e5/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 0528495..b3852e7 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
@@ -45,6 +45,7 @@ import org.apache.guacamole.form.BooleanField;
import org.apache.guacamole.form.DateField;
import org.apache.guacamole.form.Field;
import org.apache.guacamole.form.Form;
+import org.apache.guacamole.form.TextField;
import org.apache.guacamole.form.TimeField;
import org.apache.guacamole.form.TimeZoneField;
import org.apache.guacamole.net.auth.User;
@@ -65,6 +66,17 @@ 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.
*/
@@ -107,6 +119,15 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
public static final String TIMEZONE_ATTRIBUTE_NAME = "timezone";
/**
+ * All attributes related to user profile information, within a logical
+ * form.
+ */
+ public static final Form PROFILE = new Form("profile", Arrays.<Field>asList(
+ new TextField(FULL_NAME_ATTRIBUTE_NAME),
+ new TextField(EMAIL_ADDRESS_ATTRIBUTE_NAME)
+ ));
+
+ /**
* All attributes related to restricting user accounts, within a logical
* form.
*/
@@ -125,6 +146,7 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
* logical forms.
*/
public static final Collection<Form> ATTRIBUTES = Collections.unmodifiableCollection(Arrays.asList(
+ PROFILE,
ACCOUNT_RESTRICTIONS
));
@@ -372,6 +394,25 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
}
/**
+ * Stores all unrestricted (unprivileged) attributes within the given Map,
+ * pulling the values of those attributes from the underlying user model.
+ * If no value is yet defined for an attribute, that attribute will be set
+ * to null.
+ *
+ * @param attributes
+ * The Map to store all unrestricted attributes within.
+ */
+ private void putUnrestrictedAttributes(Map<String, String> attributes) {
+
+ // Set full name attribute
+ attributes.put(FULL_NAME_ATTRIBUTE_NAME, "Testy McTesterson"); // TODO
+
+ // Set email address attribute
+ attributes.put(EMAIL_ADDRESS_ATTRIBUTE_NAME, "test@test.test"); // TODO
+
+ }
+
+ /**
* Parses the given string into a corresponding date. The string must
* follow the standard format used by date attributes, as defined by
* DateField.FORMAT and as would be produced by DateField.format().
@@ -477,11 +518,31 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
}
+ /**
+ * Stores all unrestricted (unprivileged) attributes within the underlying
+ * user model, pulling the values of those attributes from the given Map.
+ *
+ * @param attributes
+ * The Map to pull all unrestricted attributes from.
+ */
+ private void setUnrestrictedAttributes(Map<String, String> attributes) {
+
+ // Translate full name attribute
+ logger.info("FULL NAME: \"{}\"", attributes.get(FULL_NAME_ATTRIBUTE_NAME)); // TODO
+
+ // Translate email address attribute
+ logger.info("EMAIL ADDRESS: \"{}\"", attributes.get(EMAIL_ADDRESS_ATTRIBUTE_NAME)); // TODO
+
+ }
+
@Override
public Map<String, String> getAttributes() {
Map<String, String> attributes = new HashMap<String, String>();
+ // Always include unrestricted attributes
+ putUnrestrictedAttributes(attributes);
+
// Include restricted attributes only if they should be exposed
if (exposeRestrictedAttributes)
putRestrictedAttributes(attributes);
@@ -492,6 +553,9 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
@Override
public void setAttributes(Map<String, String> attributes) {
+ // Always assign unrestricted attributes
+ setUnrestrictedAttributes(attributes);
+
// Assign restricted attributes only if they are exposed
if (exposeRestrictedAttributes)
setRestrictedAttributes(attributes);
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/afd051e5/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 f182aac..c6ce14b 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,13 +79,16 @@
"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:",
"FIELD_HEADER_VALID_FROM" : "Enable account after:",
"FIELD_HEADER_VALID_UNTIL" : "Disable account after:",
- "SECTION_HEADER_RESTRICTIONS" : "Account Restrictions"
+ "SECTION_HEADER_RESTRICTIONS" : "Account Restrictions",
+ "SECTION_HEADER_PROFILE" : "Profile"
}