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

This commit is contained in:
Michael Jumper
2017-02-24 01:50:26 -08:00
parent e9549fbb3b
commit 9634731fe6
5 changed files with 59 additions and 19 deletions

View File

@@ -66,17 +66,6 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
*/ */
private static final Logger logger = LoggerFactory.getLogger(ModeledUser.class); 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 * The name of the attribute which controls whether a user account is
* disabled. * disabled.
@@ -124,8 +113,8 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
* form. * form.
*/ */
public static final Form PROFILE = new Form("profile", Arrays.<Field>asList( public static final Form PROFILE = new Form("profile", Arrays.<Field>asList(
new TextField(FULL_NAME_ATTRIBUTE_NAME), new TextField(User.Attribute.FULL_NAME),
new EmailField(EMAIL_ADDRESS_ATTRIBUTE_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) { private void putUnrestrictedAttributes(Map<String, String> attributes) {
// Set full name attribute // 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 // Set email address attribute
attributes.put(EMAIL_ADDRESS_ATTRIBUTE_NAME, "test@test.test"); // TODO attributes.put(User.Attribute.EMAIL_ADDRESS, "test@test.test"); // TODO
} }
@@ -529,10 +518,10 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
private void setUnrestrictedAttributes(Map<String, String> attributes) { private void setUnrestrictedAttributes(Map<String, String> attributes) {
// Translate full name attribute // 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 // 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
} }

View File

@@ -79,8 +79,6 @@
"FIELD_HEADER_DISABLED" : "Login disabled:", "FIELD_HEADER_DISABLED" : "Login disabled:",
"FIELD_HEADER_EXPIRED" : "Password expired:", "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_END" : "Do not allow access after:",
"FIELD_HEADER_ACCESS_WINDOW_START" : "Allow access after:", "FIELD_HEADER_ACCESS_WINDOW_START" : "Allow access after:",
"FIELD_HEADER_TIMEZONE" : "User time zone:", "FIELD_HEADER_TIMEZONE" : "User time zone:",

View File

@@ -30,6 +30,27 @@ import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
*/ */
public interface User extends Identifiable { 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 * Returns this user's password. Note that the password returned may be
* hashed or completely arbitrary. * hashed or completely arbitrary.

View File

@@ -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; return User;
}]); }]);

View File

@@ -697,6 +697,13 @@
}, },
"USER_ATTRIBUTES" : {
"FIELD_HEADER_GUAC_EMAIL_ADDRESS" : "Email address:",
"FIELD_HEADER_GUAC_FULL_NAME" : "Full name:"
},
"USER_MENU" : { "USER_MENU" : {
"ACTION_LOGOUT" : "@:APP.ACTION_LOGOUT", "ACTION_LOGOUT" : "@:APP.ACTION_LOGOUT",