You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/02/01 18:32:50 UTC
[07/10] guacamole-client git commit: GUACAMOLE-96: Map base JDBC
support for arbitrary attributes to MySQL tables.
GUACAMOLE-96: Map base JDBC support for arbitrary attributes to MySQL tables.
Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/6a834a10
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/6a834a10
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/6a834a10
Branch: refs/heads/master
Commit: 6a834a1066ad65c63d64a4aa13c64ffba6acb9b0
Parents: 4947335
Author: Michael Jumper <mj...@apache.org>
Authored: Sat Nov 25 11:41:54 2017 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Wed Jan 31 15:26:16 2018 -0800
----------------------------------------------------------------------
.../schema/001-create-schema.sql | 88 +++++++++++++++
.../schema/upgrade/upgrade-pre-0.9.15.sql | 106 +++++++++++++++++++
.../auth/jdbc/connection/ConnectionMapper.xml | 58 +++++++++-
.../connectiongroup/ConnectionGroupMapper.xml | 58 +++++++++-
.../sharingprofile/SharingProfileMapper.xml | 67 +++++++++++-
.../guacamole/auth/jdbc/user/UserMapper.xml | 84 +++++++++++++--
6 files changed, 446 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/6a834a10/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/001-create-schema.sql
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/001-create-schema.sql b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/001-create-schema.sql
index f26d2cc..76711f1 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/001-create-schema.sql
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/001-create-schema.sql
@@ -186,6 +186,94 @@ CREATE TABLE guacamole_sharing_profile_parameter (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
+-- Table of arbitrary user attributes. Each attribute is simply a name/value
+-- pair associated with a user. Arbitrary attributes are defined by other
+-- extensions. Attributes defined by this extension will be mapped to
+-- properly-typed columns of a specific table.
+--
+
+CREATE TABLE guacamole_user_attribute (
+
+ `user_id` int(11) NOT NULL,
+ `attribute_name` varchar(128) NOT NULL,
+ `attribute_value` varchar(4096) NOT NULL,
+
+ PRIMARY KEY (user_id, attribute_name),
+ KEY `user_id` (`user_id`),
+
+ CONSTRAINT guacamole_user_attribute_ibfk_1
+ FOREIGN KEY (user_id)
+ REFERENCES guacamole_user (user_id) ON DELETE CASCADE
+
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table of arbitrary connection attributes. Each attribute is simply a
+-- name/value pair associated with a connection. Arbitrary attributes are
+-- defined by other extensions. Attributes defined by this extension will be
+-- mapped to properly-typed columns of a specific table.
+--
+
+CREATE TABLE guacamole_connection_attribute (
+
+ `connection_id` int(11) NOT NULL,
+ `attribute_name` varchar(128) NOT NULL,
+ `attribute_value` varchar(4096) NOT NULL,
+
+ PRIMARY KEY (connection_id, attribute_name),
+ KEY `connection_id` (`connection_id`),
+
+ CONSTRAINT guacamole_connection_attribute_ibfk_1
+ FOREIGN KEY (connection_id)
+ REFERENCES guacamole_connection (connection_id) ON DELETE CASCADE
+
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table of arbitrary connection group attributes. Each attribute is simply a
+-- name/value pair associated with a connection group. Arbitrary attributes are
+-- defined by other extensions. Attributes defined by this extension will be
+-- mapped to properly-typed columns of a specific table.
+--
+
+CREATE TABLE guacamole_connection_group_attribute (
+
+ `connection_group_id` int(11) NOT NULL,
+ `attribute_name` varchar(128) NOT NULL,
+ `attribute_value` varchar(4096) NOT NULL,
+
+ PRIMARY KEY (connection_group_id, attribute_name),
+ KEY `connection_group_id` (`connection_group_id`),
+
+ CONSTRAINT guacamole_connection_group_attribute_ibfk_1
+ FOREIGN KEY (connection_group_id)
+ REFERENCES guacamole_connection_group (connection_group_id) ON DELETE CASCADE
+
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table of arbitrary sharing profile attributes. Each attribute is simply a
+-- name/value pair associated with a sharing profile. Arbitrary attributes are
+-- defined by other extensions. Attributes defined by this extension will be
+-- mapped to properly-typed columns of a specific table.
+--
+
+CREATE TABLE guacamole_sharing_profile_attribute (
+
+ `sharing_profile_id` int(11) NOT NULL,
+ `attribute_name` varchar(128) NOT NULL,
+ `attribute_value` varchar(4096) NOT NULL,
+
+ PRIMARY KEY (sharing_profile_id, attribute_name),
+ KEY `sharing_profile_id` (`sharing_profile_id`),
+
+ CONSTRAINT guacamole_sharing_profile_attribute_ibfk_1
+ FOREIGN KEY (sharing_profile_id)
+ REFERENCES guacamole_sharing_profile (sharing_profile_id) ON DELETE CASCADE
+
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
-- Table of connection permissions. Each connection permission grants a user
-- specific access to a connection.
--
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/6a834a10/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.15.sql
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.15.sql b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.15.sql
new file mode 100644
index 0000000..2979f53
--- /dev/null
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/upgrade/upgrade-pre-0.9.15.sql
@@ -0,0 +1,106 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied. See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+--
+
+--
+-- Table of arbitrary user attributes. Each attribute is simply a name/value
+-- pair associated with a user. Arbitrary attributes are defined by other
+-- extensions. Attributes defined by this extension will be mapped to
+-- properly-typed columns of a specific table.
+--
+
+CREATE TABLE guacamole_user_attribute (
+
+ `user_id` int(11) NOT NULL,
+ `attribute_name` varchar(128) NOT NULL,
+ `attribute_value` varchar(4096) NOT NULL,
+
+ PRIMARY KEY (user_id, attribute_name),
+ KEY `user_id` (`user_id`),
+
+ CONSTRAINT guacamole_user_attribute_ibfk_1
+ FOREIGN KEY (user_id)
+ REFERENCES guacamole_user (user_id) ON DELETE CASCADE
+
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table of arbitrary connection attributes. Each attribute is simply a
+-- name/value pair associated with a connection. Arbitrary attributes are
+-- defined by other extensions. Attributes defined by this extension will be
+-- mapped to properly-typed columns of a specific table.
+--
+
+CREATE TABLE guacamole_connection_attribute (
+
+ `connection_id` int(11) NOT NULL,
+ `attribute_name` varchar(128) NOT NULL,
+ `attribute_value` varchar(4096) NOT NULL,
+
+ PRIMARY KEY (connection_id, attribute_name),
+ KEY `connection_id` (`connection_id`),
+
+ CONSTRAINT guacamole_connection_attribute_ibfk_1
+ FOREIGN KEY (connection_id)
+ REFERENCES guacamole_connection (connection_id) ON DELETE CASCADE
+
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table of arbitrary connection group attributes. Each attribute is simply a
+-- name/value pair associated with a connection group. Arbitrary attributes are
+-- defined by other extensions. Attributes defined by this extension will be
+-- mapped to properly-typed columns of a specific table.
+--
+
+CREATE TABLE guacamole_connection_group_attribute (
+
+ `connection_group_id` int(11) NOT NULL,
+ `attribute_name` varchar(128) NOT NULL,
+ `attribute_value` varchar(4096) NOT NULL,
+
+ PRIMARY KEY (connection_group_id, attribute_name),
+ KEY `connection_group_id` (`connection_group_id`),
+
+ CONSTRAINT guacamole_connection_group_attribute_ibfk_1
+ FOREIGN KEY (connection_group_id)
+ REFERENCES guacamole_connection_group (connection_group_id) ON DELETE CASCADE
+
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Table of arbitrary sharing profile attributes. Each attribute is simply a
+-- name/value pair associated with a sharing profile. Arbitrary attributes are
+-- defined by other extensions. Attributes defined by this extension will be
+-- mapped to properly-typed columns of a specific table.
+--
+
+CREATE TABLE guacamole_sharing_profile_attribute (
+
+ `sharing_profile_id` int(11) NOT NULL,
+ `attribute_name` varchar(128) NOT NULL,
+ `attribute_value` varchar(4096) NOT NULL,
+
+ PRIMARY KEY (sharing_profile_id, attribute_name),
+ KEY `sharing_profile_id` (`sharing_profile_id`),
+
+ CONSTRAINT guacamole_sharing_profile_attribute_ibfk_1
+ FOREIGN KEY (sharing_profile_id)
+ REFERENCES guacamole_sharing_profile (sharing_profile_id) ON DELETE CASCADE
+
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/6a834a10/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml
index cbffdd4..e5fd2f0 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionMapper.xml
@@ -47,6 +47,14 @@
<result column="sharing_profile_id"/>
</collection>
+ <!-- Arbitrary attributes -->
+ <collection property="arbitraryAttributes" resultSet="arbitraryAttributes"
+ ofType="org.apache.guacamole.auth.jdbc.base.ArbitraryAttributeModel"
+ column="connection_id" foreignColumn="connection_id">
+ <result property="name" column="attribute_name" jdbcType="VARCHAR"/>
+ <result property="value" column="attribute_value" jdbcType="VARCHAR"/>
+ </collection>
+
</resultMap>
<!-- Select all connection identifiers -->
@@ -87,7 +95,7 @@
<!-- Select multiple connections by identifier -->
<select id="select" resultMap="ConnectionResultMap"
- resultSets="connections,sharingProfiles">
+ resultSets="connections,sharingProfiles,arbitraryAttributes">
SELECT
guacamole_connection.connection_id,
@@ -119,11 +127,22 @@
#{identifier,jdbcType=VARCHAR}
</foreach>;
+ SELECT
+ connection_id,
+ attribute_name,
+ attribute_value
+ FROM guacamole_connection_attribute
+ WHERE connection_id IN
+ <foreach collection="identifiers" item="identifier"
+ open="(" separator="," close=")">
+ #{identifier,jdbcType=VARCHAR}
+ </foreach>;
+
</select>
<!-- Select multiple connections by identifier only if readable -->
<select id="selectReadable" resultMap="ConnectionResultMap"
- resultSets="connections,sharingProfiles">
+ resultSets="connections,sharingProfiles,arbitraryAttributes">
SELECT
guacamole_connection.connection_id,
@@ -161,6 +180,20 @@
AND user_id = #{user.objectID,jdbcType=INTEGER}
AND permission = 'READ';
+ SELECT
+ guacamole_connection_attribute.connection_id,
+ attribute_name,
+ attribute_value
+ FROM guacamole_connection_attribute
+ JOIN guacamole_connection_permission ON guacamole_connection_permission.connection_id = guacamole_connection_attribute.connection_id
+ WHERE guacamole_connection_attribute.connection_id IN
+ <foreach collection="identifiers" item="identifier"
+ open="(" separator="," close=")">
+ #{identifier,jdbcType=VARCHAR}
+ </foreach>
+ AND user_id = #{user.objectID,jdbcType=INTEGER}
+ AND permission = 'READ';
+
</select>
<!-- Select single connection by name -->
@@ -242,4 +275,25 @@
WHERE connection_id = #{object.objectID,jdbcType=INTEGER}
</update>
+ <!-- Delete attributes associated with connection -->
+ <delete id="deleteAttributes">
+ DELETE FROM guacamole_connection_attribute
+ WHERE connection_id = #{object.objectID,jdbcType=INTEGER}
+ </delete>
+
+ <!-- Insert attributes for connection -->
+ <insert id="insertAttributes" parameterType="org.apache.guacamole.auth.jdbc.base.ArbitraryAttributeModel">
+ INSERT INTO guacamole_connection_attribute (
+ connection_id,
+ attribute_name,
+ attribute_value
+ )
+ VALUES
+ <foreach collection="object.arbitraryAttributes" item="attribute" separator=",">
+ (#{object.objectID,jdbcType=INTEGER},
+ #{attribute.name,jdbcType=VARCHAR},
+ #{attribute.value,jdbcType=VARCHAR})
+ </foreach>
+ </insert>
+
</mapper>
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/6a834a10/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connectiongroup/ConnectionGroupMapper.xml
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connectiongroup/ConnectionGroupMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connectiongroup/ConnectionGroupMapper.xml
index f2ef3c2..e02a046 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connectiongroup/ConnectionGroupMapper.xml
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connectiongroup/ConnectionGroupMapper.xml
@@ -48,6 +48,14 @@
<result column="connection_id"/>
</collection>
+ <!-- Arbitrary attributes -->
+ <collection property="arbitraryAttributes" resultSet="arbitraryAttributes"
+ ofType="org.apache.guacamole.auth.jdbc.base.ArbitraryAttributeModel"
+ column="connection_group_id" foreignColumn="connection_group_id">
+ <result property="name" column="attribute_name" jdbcType="VARCHAR"/>
+ <result property="value" column="attribute_value" jdbcType="VARCHAR"/>
+ </collection>
+
</resultMap>
<!-- Select all connection group identifiers -->
@@ -88,7 +96,7 @@
<!-- Select multiple connection groups by identifier -->
<select id="select" resultMap="ConnectionGroupResultMap"
- resultSets="connectionGroups,childConnectionGroups,childConnections">
+ resultSets="connectionGroups,childConnectionGroups,childConnections,arbitraryAttributes">
SELECT
connection_group_id,
@@ -121,11 +129,22 @@
#{identifier,jdbcType=VARCHAR}
</foreach>;
+ SELECT
+ connection_group_id,
+ attribute_name,
+ attribute_value
+ FROM guacamole_connection_group_attribute
+ WHERE connection_group_id IN
+ <foreach collection="identifiers" item="identifier"
+ open="(" separator="," close=")">
+ #{identifier,jdbcType=VARCHAR}
+ </foreach>;
+
</select>
<!-- Select multiple connection groups by identifier only if readable -->
<select id="selectReadable" resultMap="ConnectionGroupResultMap"
- resultSets="connectionGroups,childConnectionGroups,childConnections">
+ resultSets="connectionGroups,childConnectionGroups,childConnections,arbitraryAttributes">
SELECT
guacamole_connection_group.connection_group_id,
@@ -167,6 +186,20 @@
AND user_id = #{user.objectID,jdbcType=INTEGER}
AND permission = 'READ';
+ SELECT
+ guacamole_connection_group_attribute.connection_group_id,
+ attribute_name,
+ attribute_value
+ FROM guacamole_connection_group_attribute
+ JOIN guacamole_connection_group_permission ON guacamole_connection_group_permission.connection_group_id = guacamole_connection_group_attribute.connection_group_id
+ WHERE guacamole_connection_group_attribute.connection_group_id IN
+ <foreach collection="identifiers" item="identifier"
+ open="(" separator="," close=")">
+ #{identifier,jdbcType=VARCHAR}
+ </foreach>
+ AND user_id = #{user.objectID,jdbcType=INTEGER}
+ AND permission = 'READ';
+
</select>
<!-- Select single connection group by name -->
@@ -229,4 +262,25 @@
WHERE connection_group_id = #{object.objectID,jdbcType=INTEGER}
</update>
+ <!-- Delete attributes associated with connection group -->
+ <delete id="deleteAttributes">
+ DELETE FROM guacamole_connection_group_attribute
+ WHERE connection_group_id = #{object.objectID,jdbcType=INTEGER}
+ </delete>
+
+ <!-- Insert attributes for connection group -->
+ <insert id="insertAttributes" parameterType="org.apache.guacamole.auth.jdbc.base.ArbitraryAttributeModel">
+ INSERT INTO guacamole_connection_group_attribute (
+ connection_group_id,
+ attribute_name,
+ attribute_value
+ )
+ VALUES
+ <foreach collection="object.arbitraryAttributes" item="attribute" separator=",">
+ (#{object.objectID,jdbcType=INTEGER},
+ #{attribute.name,jdbcType=VARCHAR},
+ #{attribute.value,jdbcType=VARCHAR})
+ </foreach>
+ </insert>
+
</mapper>
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/6a834a10/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml
index 49bb337..ef89913 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml
@@ -25,9 +25,20 @@
<!-- Result mapper for sharing profile objects -->
<resultMap id="SharingProfileResultMap" type="org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileModel">
+
+ <!-- Sharing profile properties -->
<id column="sharing_profile_id" property="objectID" jdbcType="INTEGER"/>
<result column="sharing_profile_name" property="name" jdbcType="VARCHAR"/>
<result column="primary_connection_id" property="parentIdentifier" jdbcType="INTEGER"/>
+
+ <!-- Arbitrary attributes -->
+ <collection property="arbitraryAttributes" resultSet="arbitraryAttributes"
+ ofType="org.apache.guacamole.auth.jdbc.base.ArbitraryAttributeModel"
+ column="sharing_profile_id" foreignColumn="sharing_profile_id">
+ <result property="name" column="attribute_name" jdbcType="VARCHAR"/>
+ <result property="value" column="attribute_value" jdbcType="VARCHAR"/>
+ </collection>
+
</resultMap>
<!-- Select all sharing profile identifiers -->
@@ -46,7 +57,8 @@
</select>
<!-- Select multiple sharing profiles by identifier -->
- <select id="select" resultMap="SharingProfileResultMap">
+ <select id="select" resultMap="SharingProfileResultMap"
+ resultSets="sharingProfiles,arbitraryAttributes">
SELECT
sharing_profile_id,
@@ -57,12 +69,24 @@
<foreach collection="identifiers" item="identifier"
open="(" separator="," close=")">
#{identifier,jdbcType=VARCHAR}
- </foreach>
+ </foreach>;
+
+ SELECT
+ sharing_profile_id,
+ attribute_name,
+ attribute_value
+ FROM guacamole_sharing_profile_attribute
+ WHERE sharing_profile_id IN
+ <foreach collection="identifiers" item="identifier"
+ open="(" separator="," close=")">
+ #{identifier,jdbcType=VARCHAR}
+ </foreach>;
</select>
<!-- Select multiple sharing profiles by identifier only if readable -->
- <select id="selectReadable" resultMap="SharingProfileResultMap">
+ <select id="selectReadable" resultMap="SharingProfileResultMap"
+ resultSets="sharingProfiles,arbitraryAttributes">
SELECT
guacamole_sharing_profile.sharing_profile_id,
@@ -76,7 +100,21 @@
#{identifier,jdbcType=VARCHAR}
</foreach>
AND user_id = #{user.objectID,jdbcType=INTEGER}
- AND permission = 'READ'
+ AND permission = 'READ';
+
+ SELECT
+ guacamole_sharing_profile_attribute.sharing_profile_id,
+ attribute_name,
+ attribute_value
+ FROM guacamole_sharing_profile_attribute
+ JOIN guacamole_sharing_profile_permission ON guacamole_sharing_profile_permission.sharing_profile_id = guacamole_sharing_profile_attribute.sharing_profile_id
+ WHERE guacamole_sharing_profile_attribute.sharing_profile_id IN
+ <foreach collection="identifiers" item="identifier"
+ open="(" separator="," close=")">
+ #{identifier,jdbcType=VARCHAR}
+ </foreach>
+ AND user_id = #{user.objectID,jdbcType=INTEGER}
+ AND permission = 'READ';
</select>
@@ -123,4 +161,25 @@
WHERE sharing_profile_id = #{object.objectID,jdbcType=INTEGER}
</update>
+ <!-- Delete attributes associated with sharing profile -->
+ <delete id="deleteAttributes">
+ DELETE FROM guacamole_sharing_profile_attribute
+ WHERE sharing_profile_id = #{object.objectID,jdbcType=INTEGER}
+ </delete>
+
+ <!-- Insert attributes for sharing profile -->
+ <insert id="insertAttributes" parameterType="org.apache.guacamole.auth.jdbc.base.ArbitraryAttributeModel">
+ INSERT INTO guacamole_sharing_profile_attribute (
+ sharing_profile_id,
+ attribute_name,
+ attribute_value
+ )
+ VALUES
+ <foreach collection="object.arbitraryAttributes" item="attribute" separator=",">
+ (#{object.objectID,jdbcType=INTEGER},
+ #{attribute.name,jdbcType=VARCHAR},
+ #{attribute.value,jdbcType=VARCHAR})
+ </foreach>
+ </insert>
+
</mapper>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/6a834a10/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserMapper.xml
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserMapper.xml
index c9e4f70..e183fe2 100644
--- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserMapper.xml
+++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/user/UserMapper.xml
@@ -25,6 +25,8 @@
<!-- Result mapper for user objects -->
<resultMap id="UserResultMap" type="org.apache.guacamole.auth.jdbc.user.UserModel" >
+
+ <!-- User properties -->
<id column="user_id" property="objectID" jdbcType="INTEGER"/>
<result column="username" property="identifier" jdbcType="VARCHAR"/>
<result column="password_hash" property="passwordHash" jdbcType="BINARY"/>
@@ -42,6 +44,15 @@
<result column="organization" property="organization" jdbcType="VARCHAR"/>
<result column="organizational_role" property="organizationalRole" jdbcType="VARCHAR"/>
<result column="last_active" property="lastActive" jdbcType="TIMESTAMP"/>
+
+ <!-- Arbitrary attributes -->
+ <collection property="arbitraryAttributes" resultSet="arbitraryAttributes"
+ ofType="org.apache.guacamole.auth.jdbc.base.ArbitraryAttributeModel"
+ column="user_id" foreignColumn="user_id">
+ <result property="name" column="attribute_name" jdbcType="VARCHAR"/>
+ <result property="value" column="attribute_value" jdbcType="VARCHAR"/>
+ </collection>
+
</resultMap>
<!-- Select all usernames -->
@@ -61,7 +72,8 @@
</select>
<!-- Select multiple users by username -->
- <select id="select" resultMap="UserResultMap">
+ <select id="select" resultMap="UserResultMap"
+ resultSets="users,arbitraryAttributes">
SELECT
guacamole_user.user_id,
@@ -88,12 +100,25 @@
open="(" separator="," close=")">
#{identifier,jdbcType=VARCHAR}
</foreach>
- GROUP BY guacamole_user.user_id
+ GROUP BY guacamole_user.user_id;
+
+ SELECT
+ guacamole_user_attribute.user_id,
+ guacamole_user_attribute.attribute_name,
+ guacamole_user_attribute.attribute_value
+ FROM guacamole_user_attribute
+ JOIN guacamole_user ON guacamole_user.user_id = guacamole_user_attribute.user_id
+ WHERE username IN
+ <foreach collection="identifiers" item="identifier"
+ open="(" separator="," close=")">
+ #{identifier,jdbcType=VARCHAR}
+ </foreach>;
</select>
<!-- Select multiple users by username only if readable -->
- <select id="selectReadable" resultMap="UserResultMap">
+ <select id="selectReadable" resultMap="UserResultMap"
+ resultSets="users,arbitraryAttributes">
SELECT
guacamole_user.user_id,
@@ -123,12 +148,28 @@
</foreach>
AND guacamole_user_permission.user_id = #{user.objectID,jdbcType=INTEGER}
AND permission = 'READ'
- GROUP BY guacamole_user.user_id
+ GROUP BY guacamole_user.user_id;
+
+ SELECT
+ guacamole_user_attribute.user_id,
+ guacamole_user_attribute.attribute_name,
+ guacamole_user_attribute.attribute_value
+ FROM guacamole_user_attribute
+ JOIN guacamole_user ON guacamole_user.user_id = guacamole_user_attribute.user_id
+ JOIN guacamole_user_permission ON affected_user_id = guacamole_user.user_id
+ WHERE username IN
+ <foreach collection="identifiers" item="identifier"
+ open="(" separator="," close=")">
+ #{identifier,jdbcType=VARCHAR}
+ </foreach>
+ AND guacamole_user_permission.user_id = #{user.objectID,jdbcType=INTEGER}
+ AND permission = 'READ';
</select>
<!-- Select single user by username -->
- <select id="selectOne" resultMap="UserResultMap">
+ <select id="selectOne" resultMap="UserResultMap"
+ resultSets="users,arbitraryAttributes">
SELECT
guacamole_user.user_id,
@@ -152,7 +193,15 @@
LEFT JOIN guacamole_user_history ON guacamole_user_history.user_id = guacamole_user.user_id
WHERE
guacamole_user.username = #{username,jdbcType=VARCHAR}
- GROUP BY guacamole_user.user_id
+ GROUP BY guacamole_user.user_id;
+
+ SELECT
+ guacamole_user_attribute.user_id,
+ guacamole_user_attribute.attribute_name,
+ guacamole_user_attribute.attribute_value
+ FROM guacamole_user_attribute
+ JOIN guacamole_user ON guacamole_user.user_id = guacamole_user_attribute.user_id
+ WHERE username = #{username,jdbcType=VARCHAR};
</select>
@@ -223,4 +272,25 @@
WHERE user_id = #{object.objectID,jdbcType=VARCHAR}
</update>
-</mapper>
\ No newline at end of file
+ <!-- Delete attributes associated with user -->
+ <delete id="deleteAttributes">
+ DELETE FROM guacamole_user_attribute
+ WHERE user_id = #{object.objectID,jdbcType=INTEGER}
+ </delete>
+
+ <!-- Insert attributes for user -->
+ <insert id="insertAttributes" parameterType="org.apache.guacamole.auth.jdbc.base.ArbitraryAttributeModel">
+ INSERT INTO guacamole_user_attribute (
+ user_id,
+ attribute_name,
+ attribute_value
+ )
+ VALUES
+ <foreach collection="object.arbitraryAttributes" item="attribute" separator=",">
+ (#{object.objectID,jdbcType=INTEGER},
+ #{attribute.name,jdbcType=VARCHAR},
+ #{attribute.value,jdbcType=VARCHAR})
+ </foreach>
+ </insert>
+
+</mapper>