GUACAMOLE-292: Store user profile information within PostgreSQL/MySQL database.

This commit is contained in:
Michael Jumper
2017-03-07 13:23:13 -08:00
parent 06fb054ae2
commit a34d3facc4
8 changed files with 242 additions and 43 deletions

View File

@@ -397,16 +397,16 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
private void putUnrestrictedAttributes(Map<String, String> attributes) {
// Set full name attribute
attributes.put(User.Attribute.FULL_NAME, "Testy McTesterson"); // TODO
attributes.put(User.Attribute.FULL_NAME, getModel().getFullName());
// Set email address attribute
attributes.put(User.Attribute.EMAIL_ADDRESS, "test@test.test"); // TODO
attributes.put(User.Attribute.EMAIL_ADDRESS, getModel().getEmailAddress());
// Set organization attribute
attributes.put(User.Attribute.ORGANIZATION, "Example, Inc."); // TODO
attributes.put(User.Attribute.ORGANIZATION, getModel().getOrganization());
// Set role attribute
attributes.put(User.Attribute.ORGANIZATIONAL_ROLE, "Senior Lead Architect"); // TODO
attributes.put(User.Attribute.ORGANIZATIONAL_ROLE, getModel().getOrganizationalRole());
}
@@ -526,16 +526,16 @@ 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(User.Attribute.FULL_NAME)); // TODO
getModel().setFullName(attributes.get(User.Attribute.FULL_NAME));
// Translate email address attribute
logger.info("EMAIL ADDRESS: \"{}\"", attributes.get(User.Attribute.EMAIL_ADDRESS)); // TODO
getModel().setEmailAddress(attributes.get(User.Attribute.EMAIL_ADDRESS));
// Translate organization attribute
logger.info("ORGANIZATION: \"{}\"", attributes.get(User.Attribute.ORGANIZATION)); // TODO
getModel().setOrganization(attributes.get(User.Attribute.ORGANIZATION));
// Translate role attribute
logger.info("ORGANIZATIONAL ROLE: \"{}\"", attributes.get(User.Attribute.ORGANIZATIONAL_ROLE)); // TODO
getModel().setOrganizationalRole(attributes.get(User.Attribute.ORGANIZATIONAL_ROLE));
}

View File

@@ -92,6 +92,28 @@ public class UserModel extends ObjectModel {
*/
private String timeZone;
/**
* The user's full name, or null if this is not known.
*/
private String fullName;
/**
* The email address of the user, or null if this is not known.
*/
private String emailAddress;
/**
* The organization, company, group, etc. that the user belongs to, or null
* if this is not known.
*/
private String organization;
/**
* The role that the user has at the organization, company, group, etc.
* they belong to, or null if this is not known.
*/
private String organizationalRole;
/**
* Creates a new, empty user.
*/
@@ -351,4 +373,93 @@ public class UserModel extends ObjectModel {
this.timeZone = timeZone;
}
/**
* Returns the user's full name, if known. If not available, null is
* returned.
*
* @return
* The user's full name, or null if this is not known.
*/
public String getFullName() {
return fullName;
}
/**
* Sets the user's full name.
*
* @param fullName
* The user's full name, or null if this is not known.
*/
public void setFullName(String fullName) {
this.fullName = fullName;
}
/**
* Returns the email address of the user, if known. If not available, null
* is returned.
*
* @return
* The email address of the user, or null if this is not known.
*/
public String getEmailAddress() {
return emailAddress;
}
/**
* Sets the email address of the user.
*
* @param emailAddress
* The email address of the user, or null if this is not known.
*/
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
/**
* Returns the organization, company, group, etc. that the user belongs to,
* if known. If not available, null is returned.
*
* @return
* The organization, company, group, etc. that the user belongs to, or
* null if this is not known.
*/
public String getOrganization() {
return organization;
}
/**
* Sets the organization, company, group, etc. that the user belongs to.
*
* @param organization
* The organization, company, group, etc. that the user belongs to, or
* null if this is not known.
*/
public void setOrganization(String organization) {
this.organization = organization;
}
/**
* Returns the role that the user has at the organization, company, group,
* etc. they belong to. If not available, null is returned.
*
* @return
* The role that the user has at the organization, company, group, etc.
* they belong to, or null if this is not known.
*/
public String getOrganizationalRole() {
return organizationalRole;
}
/**
* Sets the role that the user has at the organization, company, group,
* etc. they belong to.
*
* @param organizationalRole
* The role that the user has at the organization, company, group, etc.
* they belong to, or null if this is not known.
*/
public void setOrganizationalRole(String organizationalRole) {
this.organizationalRole = organizationalRole;
}
}

View File

@@ -102,6 +102,12 @@ CREATE TABLE `guacamole_user` (
-- Timezone used for all date/time comparisons and interpretation
`timezone` VARCHAR(64),
-- Profile information
`full_name` VARCHAR(256),
`email_address` VARCHAR(256),
`organization` VARCHAR(256),
`organizational_role` VARCHAR(256),
PRIMARY KEY (`user_id`),
UNIQUE KEY `username` (`username`)

View File

@@ -28,3 +28,13 @@ ALTER TABLE guacamole_connection ADD COLUMN proxy_encryption_method ENUM(
'NONE',
'SSL'
);
--
-- Add new user profile columns
--
ALTER TABLE guacamole_user ADD COLUMN full_name VARCHAR(256);
ALTER TABLE guacamole_user ADD COLUMN email_address VARCHAR(256);
ALTER TABLE guacamole_user ADD COLUMN organization VARCHAR(256);
ALTER TABLE guacamole_user ADD COLUMN organizational_role VARCHAR(256);

View File

@@ -25,17 +25,21 @@
<!-- Result mapper for user objects -->
<resultMap id="UserResultMap" type="org.apache.guacamole.auth.jdbc.user.UserModel" >
<id column="user_id" property="objectID" jdbcType="INTEGER"/>
<result column="username" property="identifier" jdbcType="VARCHAR"/>
<result column="password_hash" property="passwordHash" jdbcType="BINARY"/>
<result column="password_salt" property="passwordSalt" jdbcType="BINARY"/>
<result column="password_date" property="passwordDate" jdbcType="TIMESTAMP"/>
<result column="disabled" property="disabled" jdbcType="BOOLEAN"/>
<result column="access_window_start" property="accessWindowStart" jdbcType="TIME"/>
<result column="access_window_end" property="accessWindowEnd" jdbcType="TIME"/>
<result column="valid_from" property="validFrom" jdbcType="DATE"/>
<result column="valid_until" property="validUntil" jdbcType="DATE"/>
<result column="timezone" property="timeZone" jdbcType="VARCHAR"/>
<id column="user_id" property="objectID" jdbcType="INTEGER"/>
<result column="username" property="identifier" jdbcType="VARCHAR"/>
<result column="password_hash" property="passwordHash" jdbcType="BINARY"/>
<result column="password_salt" property="passwordSalt" jdbcType="BINARY"/>
<result column="password_date" property="passwordDate" jdbcType="TIMESTAMP"/>
<result column="disabled" property="disabled" jdbcType="BOOLEAN"/>
<result column="access_window_start" property="accessWindowStart" jdbcType="TIME"/>
<result column="access_window_end" property="accessWindowEnd" jdbcType="TIME"/>
<result column="valid_from" property="validFrom" jdbcType="DATE"/>
<result column="valid_until" property="validUntil" jdbcType="DATE"/>
<result column="timezone" property="timeZone" jdbcType="VARCHAR"/>
<result column="full_name" property="fullName" jdbcType="VARCHAR"/>
<result column="email_address" property="emailAddress" jdbcType="VARCHAR"/>
<result column="organization" property="organization" jdbcType="VARCHAR"/>
<result column="organizational_role" property="organizationalRole" jdbcType="VARCHAR"/>
</resultMap>
<!-- Select all usernames -->
@@ -69,7 +73,11 @@
access_window_end,
valid_from,
valid_until,
timezone
timezone,
full_name,
email_address,
organization,
organizational_role
FROM guacamole_user
WHERE username IN
<foreach collection="identifiers" item="identifier"
@@ -94,7 +102,11 @@
access_window_end,
valid_from,
valid_until,
timezone
timezone,
full_name,
email_address,
organization,
organizational_role
FROM guacamole_user
JOIN guacamole_user_permission ON affected_user_id = guacamole_user.user_id
WHERE username IN
@@ -122,7 +134,11 @@
access_window_end,
valid_from,
valid_until,
timezone
timezone,
full_name,
email_address,
organization,
organizational_role
FROM guacamole_user
WHERE
username = #{username,jdbcType=VARCHAR}
@@ -150,7 +166,11 @@
access_window_end,
valid_from,
valid_until,
timezone
timezone,
full_name,
email_address,
organization,
organizational_role
)
VALUES (
#{object.identifier,jdbcType=VARCHAR},
@@ -163,7 +183,11 @@
#{object.accessWindowEnd,jdbcType=TIME},
#{object.validFrom,jdbcType=DATE},
#{object.validUntil,jdbcType=DATE},
#{object.timeZone,jdbcType=VARCHAR}
#{object.timeZone,jdbcType=VARCHAR},
#{object.fullName,jdbcType=VARCHAR},
#{object.emailAddress,jdbcType=VARCHAR},
#{object.organization,jdbcType=VARCHAR},
#{object.organizationalRole,jdbcType=VARCHAR}
)
</insert>
@@ -180,7 +204,11 @@
access_window_end = #{object.accessWindowEnd,jdbcType=TIME},
valid_from = #{object.validFrom,jdbcType=DATE},
valid_until = #{object.validUntil,jdbcType=DATE},
timezone = #{object.timeZone,jdbcType=VARCHAR}
timezone = #{object.timeZone,jdbcType=VARCHAR},
full_name = #{object.fullName,jdbcType=VARCHAR},
email_address = #{object.emailAddress,jdbcType=VARCHAR},
organization = #{object.organization,jdbcType=VARCHAR},
organizational_role = #{object.organizationalRole,jdbcType=VARCHAR}
WHERE user_id = #{object.objectID,jdbcType=VARCHAR}
</update>

View File

@@ -143,6 +143,12 @@ CREATE TABLE guacamole_user (
-- Timezone used for all date/time comparisons and interpretation
timezone varchar(64),
-- Profile information
full_name varchar(256),
email_address varchar(256),
organization varchar(256),
organizational_role varchar(256),
PRIMARY KEY (user_id),
CONSTRAINT username

View File

@@ -33,3 +33,13 @@ CREATE TYPE guacamole_proxy_encryption_method AS ENUM(
ALTER TABLE guacamole_connection ADD COLUMN proxy_port integer;
ALTER TABLE guacamole_connection ADD COLUMN proxy_hostname varchar(512);
ALTER TABLE guacamole_connection ADD COLUMN proxy_encryption_method guacamole_proxy_encryption_method;
--
-- Add new user profile columns
--
ALTER TABLE guacamole_user ADD COLUMN full_name VARCHAR(256);
ALTER TABLE guacamole_user ADD COLUMN email_address VARCHAR(256);
ALTER TABLE guacamole_user ADD COLUMN organization VARCHAR(256);
ALTER TABLE guacamole_user ADD COLUMN organizational_role VARCHAR(256);

View File

@@ -25,18 +25,22 @@
<!-- Result mapper for user objects -->
<resultMap id="UserResultMap" type="org.apache.guacamole.auth.jdbc.user.UserModel" >
<id column="user_id" property="objectID" jdbcType="INTEGER"/>
<result column="username" property="identifier" jdbcType="VARCHAR"/>
<result column="password_hash" property="passwordHash" jdbcType="BINARY"/>
<result column="password_salt" property="passwordSalt" jdbcType="BINARY"/>
<result column="password_date" property="passwordDate" jdbcType="TIMESTAMP"/>
<result column="disabled" property="disabled" jdbcType="BOOLEAN"/>
<result column="expired" property="expired" jdbcType="BOOLEAN"/>
<result column="access_window_start" property="accessWindowStart" jdbcType="TIME"/>
<result column="access_window_end" property="accessWindowEnd" jdbcType="TIME"/>
<result column="valid_from" property="validFrom" jdbcType="DATE"/>
<result column="valid_until" property="validUntil" jdbcType="DATE"/>
<result column="timezone" property="timeZone" jdbcType="VARCHAR"/>
<id column="user_id" property="objectID" jdbcType="INTEGER"/>
<result column="username" property="identifier" jdbcType="VARCHAR"/>
<result column="password_hash" property="passwordHash" jdbcType="BINARY"/>
<result column="password_salt" property="passwordSalt" jdbcType="BINARY"/>
<result column="password_date" property="passwordDate" jdbcType="TIMESTAMP"/>
<result column="disabled" property="disabled" jdbcType="BOOLEAN"/>
<result column="expired" property="expired" jdbcType="BOOLEAN"/>
<result column="access_window_start" property="accessWindowStart" jdbcType="TIME"/>
<result column="access_window_end" property="accessWindowEnd" jdbcType="TIME"/>
<result column="valid_from" property="validFrom" jdbcType="DATE"/>
<result column="valid_until" property="validUntil" jdbcType="DATE"/>
<result column="timezone" property="timeZone" jdbcType="VARCHAR"/>
<result column="full_name" property="fullName" jdbcType="VARCHAR"/>
<result column="email_address" property="emailAddress" jdbcType="VARCHAR"/>
<result column="organization" property="organization" jdbcType="VARCHAR"/>
<result column="organizational_role" property="organizationalRole" jdbcType="VARCHAR"/>
</resultMap>
<!-- Select all usernames -->
@@ -70,7 +74,11 @@
access_window_end,
valid_from,
valid_until,
timezone
timezone,
full_name,
email_address,
organization,
organizational_role
FROM guacamole_user
WHERE username IN
<foreach collection="identifiers" item="identifier"
@@ -95,7 +103,11 @@
access_window_end,
valid_from,
valid_until,
timezone
timezone,
full_name,
email_address,
organization,
organizational_role
FROM guacamole_user
JOIN guacamole_user_permission ON affected_user_id = guacamole_user.user_id
WHERE username IN
@@ -123,7 +135,11 @@
access_window_end,
valid_from,
valid_until,
timezone
timezone,
full_name,
email_address,
organization,
organizational_role
FROM guacamole_user
WHERE
username = #{username,jdbcType=VARCHAR}
@@ -151,7 +167,11 @@
access_window_end,
valid_from,
valid_until,
timezone
timezone,
full_name,
email_address,
organization,
organizational_role
)
VALUES (
#{object.identifier,jdbcType=VARCHAR},
@@ -164,7 +184,11 @@
#{object.accessWindowEnd,jdbcType=TIME},
#{object.validFrom,jdbcType=DATE},
#{object.validUntil,jdbcType=DATE},
#{object.timeZone,jdbcType=VARCHAR}
#{object.timeZone,jdbcType=VARCHAR},
#{object.fullName,jdbcType=VARCHAR},
#{object.emailAddress,jdbcType=VARCHAR},
#{object.organization,jdbcType=VARCHAR},
#{object.organizationalRole,jdbcType=VARCHAR}
)
</insert>
@@ -181,7 +205,11 @@
access_window_end = #{object.accessWindowEnd,jdbcType=TIME},
valid_from = #{object.validFrom,jdbcType=DATE},
valid_until = #{object.validUntil,jdbcType=DATE},
timezone = #{object.timeZone,jdbcType=VARCHAR}
timezone = #{object.timeZone,jdbcType=VARCHAR},
full_name = #{object.fullName,jdbcType=VARCHAR},
email_address = #{object.emailAddress,jdbcType=VARCHAR},
organization = #{object.organization,jdbcType=VARCHAR},
organizational_role = #{object.organizationalRole,jdbcType=VARCHAR}
WHERE user_id = #{object.objectID,jdbcType=VARCHAR}
</update>