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 052849520..b3852e717 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; @@ -64,6 +65,17 @@ public class ModeledUser extends ModeledDirectoryObject 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. @@ -106,6 +118,15 @@ public class ModeledUser extends ModeledDirectoryObject 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.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 implements Us * logical forms. */ public static final Collection
ATTRIBUTES = Collections.unmodifiableCollection(Arrays.asList( + PROFILE, ACCOUNT_RESTRICTIONS )); @@ -371,6 +393,25 @@ public class ModeledUser extends ModeledDirectoryObject 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 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 @@ -477,11 +518,31 @@ public class ModeledUser extends ModeledDirectoryObject 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 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 getAttributes() { Map attributes = new HashMap(); + // 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 implements Us @Override public void setAttributes(Map attributes) { + // Always assign unrestricted attributes + setUnrestrictedAttributes(attributes); + // Assign restricted attributes only if they are exposed if (exposeRestrictedAttributes) setRestrictedAttributes(attributes); 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 f182aacb7..c6ce14b04 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" }