mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	GUAC-1101: Rename guacamole-auth-mysql hierarchically.
This commit is contained in:
		| @@ -0,0 +1,142 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" ?> | ||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|     "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||||
|  | ||||
| <!-- | ||||
|    Copyright (C) 2015 Glyptodon LLC | ||||
|  | ||||
|    Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|    of this software and associated documentation files (the "Software"), to deal | ||||
|    in the Software without restriction, including without limitation the rights | ||||
|    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|    copies of the Software, and to permit persons to whom the Software is | ||||
|    furnished to do so, subject to the following conditions: | ||||
|  | ||||
|    The above copyright notice and this permission notice shall be included in | ||||
|    all copies or substantial portions of the Software. | ||||
|  | ||||
|    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
|    THE SOFTWARE. | ||||
| --> | ||||
|  | ||||
| <mapper namespace="org.glyptodon.guacamole.auth.jdbc.connection.ConnectionMapper" > | ||||
|  | ||||
|     <!-- Result mapper for connection objects --> | ||||
|     <resultMap id="ConnectionResultMap" type="org.glyptodon.guacamole.auth.jdbc.connection.ConnectionModel" > | ||||
|         <id     column="connection_id"   property="objectID"         jdbcType="INTEGER"/> | ||||
|         <result column="connection_name" property="name"             jdbcType="VARCHAR"/> | ||||
|         <result column="parent_id"       property="parentIdentifier" jdbcType="INTEGER"/> | ||||
|         <result column="protocol"        property="protocol"         jdbcType="VARCHAR"/> | ||||
|     </resultMap> | ||||
|  | ||||
|     <!-- Select all connection identifiers --> | ||||
|     <select id="selectIdentifiers" resultType="string"> | ||||
|         SELECT connection_id  | ||||
|         FROM guacamole_connection | ||||
|     </select> | ||||
|  | ||||
|     <!-- Select identifiers of all readable connections --> | ||||
|     <select id="selectReadableIdentifiers" resultType="string"> | ||||
|         SELECT connection_id | ||||
|         FROM guacamole_connection_permission | ||||
|         WHERE | ||||
|             user_id = #{user.objectID,jdbcType=INTEGER} | ||||
|             AND permission = 'READ' | ||||
|     </select> | ||||
|  | ||||
|     <!-- Select all connection identifiers within a particular connection group --> | ||||
|     <select id="selectIdentifiersWithin" resultType="string"> | ||||
|         SELECT connection_id  | ||||
|         FROM guacamole_connection | ||||
|         WHERE | ||||
|             <if test="parentIdentifier != null">parent_id = #{parentIdentifier,jdbcType=VARCHAR}</if> | ||||
|             <if test="parentIdentifier == null">parent_id IS NULL</if> | ||||
|     </select> | ||||
|  | ||||
|     <!-- Select identifiers of all readable connections within a particular connection group --> | ||||
|     <select id="selectReadableIdentifiersWithin" resultType="string"> | ||||
|         SELECT guacamole_connection.connection_id | ||||
|         FROM guacamole_connection | ||||
|         JOIN guacamole_connection_permission ON guacamole_connection_permission.connection_id = guacamole_connection.connection_id | ||||
|         WHERE | ||||
|             <if test="parentIdentifier != null">parent_id = #{parentIdentifier,jdbcType=VARCHAR}</if> | ||||
|             <if test="parentIdentifier == null">parent_id IS NULL</if> | ||||
|             AND user_id = #{user.objectID,jdbcType=INTEGER} | ||||
|             AND permission = 'READ' | ||||
|     </select> | ||||
|  | ||||
|     <!-- Select multiple connections by identifier --> | ||||
|     <select id="select" resultMap="ConnectionResultMap"> | ||||
|  | ||||
|         SELECT | ||||
|             connection_id, | ||||
|             connection_name, | ||||
|             parent_id, | ||||
|             protocol  | ||||
|         FROM guacamole_connection | ||||
|         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"> | ||||
|  | ||||
|         SELECT | ||||
|             guacamole_connection.connection_id, | ||||
|             connection_name, | ||||
|             parent_id, | ||||
|             protocol  | ||||
|         FROM guacamole_connection | ||||
|         JOIN guacamole_connection_permission ON guacamole_connection_permission.connection_id = guacamole_connection.connection_id | ||||
|         WHERE guacamole_connection.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> | ||||
|  | ||||
|     <!-- Delete single connection by identifier --> | ||||
|     <delete id="delete"> | ||||
|         DELETE FROM guacamole_connection | ||||
|         WHERE connection_id = #{identifier,jdbcType=VARCHAR} | ||||
|     </delete> | ||||
|  | ||||
|     <!-- Insert single connection --> | ||||
|     <insert id="insert" useGeneratedKeys="true" keyProperty="object.objectID" | ||||
|             parameterType="org.glyptodon.guacamole.auth.jdbc.connection.ConnectionModel"> | ||||
|  | ||||
|         INSERT INTO guacamole_connection ( | ||||
|             connection_name, | ||||
|             parent_id, | ||||
|             protocol  | ||||
|         ) | ||||
|         VALUES ( | ||||
|             #{object.name,jdbcType=VARCHAR}, | ||||
|             #{object.parentIdentifier,jdbcType=VARCHAR}, | ||||
|             #{object.protocol,jdbcType=VARCHAR} | ||||
|         ) | ||||
|  | ||||
|     </insert> | ||||
|  | ||||
|     <!-- Update single connection --> | ||||
|     <update id="update" parameterType="org.glyptodon.guacamole.auth.jdbc.connection.ConnectionModel"> | ||||
|         UPDATE guacamole_connection | ||||
|         SET connection_name = #{object.name,jdbcType=VARCHAR}, | ||||
|             parent_id       = #{object.parentIdentifier,jdbcType=VARCHAR}, | ||||
|             protocol        = #{object.protocol,jdbcType=VARCHAR} | ||||
|         WHERE connection_id = #{object.objectID,jdbcType=INTEGER} | ||||
|     </update> | ||||
|  | ||||
| </mapper> | ||||
| @@ -0,0 +1,75 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" ?> | ||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|     "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||||
|  | ||||
| <!-- | ||||
|    Copyright (C) 2015 Glyptodon LLC | ||||
|  | ||||
|    Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|    of this software and associated documentation files (the "Software"), to deal | ||||
|    in the Software without restriction, including without limitation the rights | ||||
|    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|    copies of the Software, and to permit persons to whom the Software is | ||||
|    furnished to do so, subject to the following conditions: | ||||
|  | ||||
|    The above copyright notice and this permission notice shall be included in | ||||
|    all copies or substantial portions of the Software. | ||||
|  | ||||
|    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
|    THE SOFTWARE. | ||||
| --> | ||||
|  | ||||
| <mapper namespace="org.glyptodon.guacamole.auth.jdbc.connection.ConnectionRecordMapper" > | ||||
|  | ||||
|     <!-- Result mapper for system permissions --> | ||||
|     <resultMap id="ConnectionRecordResultMap" type="org.glyptodon.guacamole.auth.jdbc.connection.ConnectionRecordModel"> | ||||
|         <result column="connection_id" property="connectionIdentifier" jdbcType="INTEGER"/> | ||||
|         <result column="user_id"       property="userID"               jdbcType="INTEGER"/> | ||||
|         <result column="username"      property="username"             jdbcType="VARCHAR"/> | ||||
|         <result column="start_date"    property="startDate"            jdbcType="TIMESTAMP"/> | ||||
|         <result column="end_date"      property="endDate"              jdbcType="TIMESTAMP"/> | ||||
|     </resultMap> | ||||
|  | ||||
|     <!-- Select all connection records from a given connection --> | ||||
|     <select id="select" resultMap="ConnectionRecordResultMap"> | ||||
|  | ||||
|         SELECT | ||||
|             connection_id, | ||||
|             guacamole_connection_history.user_id, | ||||
|             username, | ||||
|             start_date, | ||||
|             end_date | ||||
|         FROM guacamole_connection_history | ||||
|         JOIN guacamole_user ON guacamole_connection_history.user_id = guacamole_user.user_id | ||||
|         WHERE | ||||
|             connection_id = #{identifier,jdbcType=VARCHAR} | ||||
|         ORDER BY | ||||
|             start_date DESC, | ||||
|             end_date DESC | ||||
|  | ||||
|     </select> | ||||
|  | ||||
|     <!-- Insert the given connection record --> | ||||
|     <insert id="insert" parameterType="org.glyptodon.guacamole.auth.jdbc.connection.ConnectionRecordModel"> | ||||
|  | ||||
|         INSERT INTO guacamole_connection_history ( | ||||
|             connection_id, | ||||
|             user_id, | ||||
|             start_date, | ||||
|             end_date | ||||
|         ) | ||||
|         VALUES ( | ||||
|             #{record.connectionIdentifier,jdbcType=VARCHAR}, | ||||
|             #{record.userID,jdbcType=INTEGER}, | ||||
|             #{record.startDate,jdbcType=TIMESTAMP}, | ||||
|             #{record.endDate,jdbcType=TIMESTAMP} | ||||
|         ) | ||||
|  | ||||
|     </insert> | ||||
|  | ||||
| </mapper> | ||||
| @@ -0,0 +1,71 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" ?> | ||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|     "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||||
|  | ||||
| <!-- | ||||
|    Copyright (C) 2015 Glyptodon LLC | ||||
|  | ||||
|    Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|    of this software and associated documentation files (the "Software"), to deal | ||||
|    in the Software without restriction, including without limitation the rights | ||||
|    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|    copies of the Software, and to permit persons to whom the Software is | ||||
|    furnished to do so, subject to the following conditions: | ||||
|  | ||||
|    The above copyright notice and this permission notice shall be included in | ||||
|    all copies or substantial portions of the Software. | ||||
|  | ||||
|    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
|    THE SOFTWARE. | ||||
| --> | ||||
|  | ||||
| <mapper namespace="org.glyptodon.guacamole.auth.jdbc.connection.ParameterMapper"> | ||||
|  | ||||
|     <!-- Result mapper for connection parameters --> | ||||
|     <resultMap id="ParameterResultMap" type="org.glyptodon.guacamole.auth.jdbc.connection.ParameterModel"> | ||||
|         <result column="connection_id"   property="connectionIdentifier" jdbcType="INTEGER"/> | ||||
|         <result column="parameter_name"  property="name"                 jdbcType="VARCHAR"/> | ||||
|         <result column="parameter_value" property="value"                jdbcType="VARCHAR"/> | ||||
|     </resultMap> | ||||
|  | ||||
|     <!-- Select all parameters of a given connection --> | ||||
|     <select id="select" resultMap="ParameterResultMap"> | ||||
|         SELECT | ||||
|             connection_id, | ||||
|             parameter_name, | ||||
|             parameter_value | ||||
|         FROM guacamole_connection_parameter | ||||
|         WHERE | ||||
|             connection_id = #{identifier,jdbcType=VARCHAR} | ||||
|     </select> | ||||
|  | ||||
|     <!-- Delete all parameters of a given connection --> | ||||
|     <delete id="delete"> | ||||
|         DELETE FROM guacamole_connection_parameter | ||||
|         WHERE connection_id = #{identifier,jdbcType=VARCHAR} | ||||
|     </delete> | ||||
|  | ||||
|     <!-- Insert all given parameters --> | ||||
|     <insert id="insert" parameterType="org.glyptodon.guacamole.auth.jdbc.connection.ParameterModel"> | ||||
|  | ||||
|         INSERT INTO guacamole_connection_parameter ( | ||||
|             connection_id, | ||||
|             parameter_name, | ||||
|             parameter_value | ||||
|         ) | ||||
|         VALUES  | ||||
|             <foreach collection="parameters" item="parameter" separator=","> | ||||
|                 (#{parameter.connectionIdentifier,jdbcType=VARCHAR}, | ||||
|                  #{parameter.name,jdbcType=VARCHAR}, | ||||
|                  #{parameter.value,jdbcType=VARCHAR}) | ||||
|             </foreach> | ||||
|  | ||||
|     </insert> | ||||
|  | ||||
|  | ||||
| </mapper> | ||||
| @@ -0,0 +1,143 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" ?> | ||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|     "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||||
|  | ||||
| <!-- | ||||
|    Copyright (C) 2015 Glyptodon LLC | ||||
|  | ||||
|    Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|    of this software and associated documentation files (the "Software"), to deal | ||||
|    in the Software without restriction, including without limitation the rights | ||||
|    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|    copies of the Software, and to permit persons to whom the Software is | ||||
|    furnished to do so, subject to the following conditions: | ||||
|  | ||||
|    The above copyright notice and this permission notice shall be included in | ||||
|    all copies or substantial portions of the Software. | ||||
|  | ||||
|    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
|    THE SOFTWARE. | ||||
| --> | ||||
|  | ||||
| <mapper namespace="org.glyptodon.guacamole.auth.jdbc.connectiongroup.ConnectionGroupMapper" > | ||||
|  | ||||
|     <!-- Result mapper for connection objects --> | ||||
|     <resultMap id="ConnectionGroupResultMap" type="org.glyptodon.guacamole.auth.jdbc.connectiongroup.ConnectionGroupModel" > | ||||
|         <id     column="connection_group_id"   property="objectID"         jdbcType="INTEGER"/> | ||||
|         <result column="connection_group_name" property="name"             jdbcType="VARCHAR"/> | ||||
|         <result column="parent_id"             property="parentIdentifier" jdbcType="INTEGER"/> | ||||
|         <result column="type"                  property="type"             jdbcType="VARCHAR" | ||||
|                 javaType="org.glyptodon.guacamole.net.auth.ConnectionGroup$Type"/> | ||||
|     </resultMap> | ||||
|  | ||||
|     <!-- Select all connection group identifiers --> | ||||
|     <select id="selectIdentifiers" resultType="string"> | ||||
|         SELECT connection_group_id  | ||||
|         FROM guacamole_connection_group | ||||
|     </select> | ||||
|  | ||||
|     <!-- Select identifiers of all readable connection groups --> | ||||
|     <select id="selectReadableIdentifiers" resultType="string"> | ||||
|         SELECT connection_group_id | ||||
|         FROM guacamole_connection_group_permission | ||||
|         WHERE | ||||
|             user_id = #{user.objectID,jdbcType=INTEGER} | ||||
|             AND permission = 'READ' | ||||
|     </select> | ||||
|  | ||||
|     <!-- Select all connection identifiers within a particular connection group --> | ||||
|     <select id="selectIdentifiersWithin" resultType="string"> | ||||
|         SELECT connection_group_id  | ||||
|         FROM guacamole_connection_group | ||||
|         WHERE | ||||
|             <if test="parentIdentifier != null">parent_id = #{parentIdentifier,jdbcType=VARCHAR}</if> | ||||
|             <if test="parentIdentifier == null">parent_id IS NULL</if> | ||||
|     </select> | ||||
|  | ||||
|     <!-- Select identifiers of all readable connection groups within a particular connection group --> | ||||
|     <select id="selectReadableIdentifiersWithin" resultType="string"> | ||||
|         SELECT guacamole_connection_group.connection_group_id | ||||
|         FROM guacamole_connection_group | ||||
|         JOIN guacamole_connection_group_permission ON guacamole_connection_group_permission.connection_group_id = guacamole_connection.group_connection_group_id | ||||
|         WHERE | ||||
|             <if test="parentIdentifier != null">parent_id = #{parentIdentifier,jdbcType=VARCHAR}</if> | ||||
|             <if test="parentIdentifier == null">parent_id IS NULL</if> | ||||
|             AND user_id = #{user.objectID,jdbcType=INTEGER} | ||||
|             AND permission = 'READ' | ||||
|     </select> | ||||
|  | ||||
|     <!-- Select multiple connection groups by identifier --> | ||||
|     <select id="select" resultMap="ConnectionGroupResultMap"> | ||||
|  | ||||
|         SELECT | ||||
|             connection_group_id, | ||||
|             connection_group_name, | ||||
|             parent_id, | ||||
|             type | ||||
|         FROM guacamole_connection_group | ||||
|         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"> | ||||
|  | ||||
|         SELECT | ||||
|             guacamole_connection_group.connection_group_id, | ||||
|             connection_group_name, | ||||
|             parent_id, | ||||
|             protocol  | ||||
|         FROM guacamole_connection_group | ||||
|         JOIN guacamole_connection_group_permission ON guacamole_connection_group_permission.connection_group_id = guacamole_connection_group.connection_group_id | ||||
|         WHERE guacamole_connection_group.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> | ||||
|  | ||||
|     <!-- Delete single connection group by identifier --> | ||||
|     <delete id="delete"> | ||||
|         DELETE FROM guacamole_connection_group | ||||
|         WHERE connection_group_id = #{identifier,jdbcType=VARCHAR} | ||||
|     </delete> | ||||
|  | ||||
|     <!-- Insert single connection --> | ||||
|     <insert id="insert" useGeneratedKeys="true" keyProperty="object.objectID" | ||||
|             parameterType="org.glyptodon.guacamole.auth.jdbc.connectiongroup.ConnectionGroupModel"> | ||||
|  | ||||
|         INSERT INTO guacamole_connection_group ( | ||||
|             connection_group_name, | ||||
|             parent_id, | ||||
|             type | ||||
|         ) | ||||
|         VALUES ( | ||||
|             #{object.name,jdbcType=VARCHAR}, | ||||
|             #{object.parentIdentifier,jdbcType=VARCHAR}, | ||||
|             #{object.type,jdbcType=VARCHAR} | ||||
|         ) | ||||
|  | ||||
|     </insert> | ||||
|  | ||||
|     <!-- Update single connection group --> | ||||
|     <update id="update" parameterType="org.glyptodon.guacamole.auth.jdbc.connectiongroup.ConnectionGroupModel"> | ||||
|         UPDATE guacamole_connection_group | ||||
|         SET connection_group_name = #{object.name,jdbcType=VARCHAR}, | ||||
|             parent_id             = #{object.parentIdentifier,jdbcType=VARCHAR}, | ||||
|             type                  = #{object.type,jdbcType=VARCHAR} | ||||
|         WHERE connection_group_id = #{object.objectID,jdbcType=INTEGER} | ||||
|     </update> | ||||
|  | ||||
| </mapper> | ||||
| @@ -0,0 +1,93 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" ?> | ||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|     "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||||
|  | ||||
| <!-- | ||||
|    Copyright (C) 2015 Glyptodon LLC | ||||
|  | ||||
|    Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|    of this software and associated documentation files (the "Software"), to deal | ||||
|    in the Software without restriction, including without limitation the rights | ||||
|    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|    copies of the Software, and to permit persons to whom the Software is | ||||
|    furnished to do so, subject to the following conditions: | ||||
|  | ||||
|    The above copyright notice and this permission notice shall be included in | ||||
|    all copies or substantial portions of the Software. | ||||
|  | ||||
|    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
|    THE SOFTWARE. | ||||
| --> | ||||
|  | ||||
| <mapper namespace="org.glyptodon.guacamole.auth.jdbc.permission.SystemPermissionMapper" > | ||||
|  | ||||
|     <!-- Result mapper for system permissions --> | ||||
|     <resultMap id="SystemPermissionResultMap" type="org.glyptodon.guacamole.auth.jdbc.permission.SystemPermissionModel"> | ||||
|         <result column="user_id"    property="userID"   jdbcType="INTEGER"/> | ||||
|         <result column="username"   property="username" jdbcType="VARCHAR"/> | ||||
|         <result column="permission" property="type"     jdbcType="VARCHAR" | ||||
|                 javaType="org.glyptodon.guacamole.net.auth.permission.SystemPermission$Type"/> | ||||
|     </resultMap> | ||||
|  | ||||
|     <!-- Select all permissions for a given user --> | ||||
|     <select id="select" resultMap="SystemPermissionResultMap"> | ||||
|  | ||||
|         SELECT | ||||
|             guacamole_system_permission.user_id, | ||||
|             username, | ||||
|             permission | ||||
|         FROM guacamole_system_permission | ||||
|         JOIN guacamole_user ON guacamole_system_permission.user_id = guacamole_user.user_id | ||||
|         WHERE guacamole_system_permission.user_id = #{user.objectID,jdbcType=INTEGER} | ||||
|  | ||||
|     </select> | ||||
|  | ||||
|     <!-- Select the single permission matching the given criteria --> | ||||
|     <select id="selectOne" resultMap="SystemPermissionResultMap"> | ||||
|  | ||||
|         SELECT | ||||
|             guacamole_system_permission.user_id, | ||||
|             username, | ||||
|             permission | ||||
|         FROM guacamole_system_permission | ||||
|         JOIN guacamole_user ON guacamole_system_permission.user_id = guacamole_user.user_id | ||||
|         WHERE | ||||
|             guacamole_system_permission.user_id = #{user.objectID,jdbcType=INTEGER} | ||||
|             AND permission = #{type,jdbcType=VARCHAR} | ||||
|  | ||||
|     </select> | ||||
|  | ||||
|     <!-- Delete all given permissions --> | ||||
|     <delete id="delete" parameterType="org.glyptodon.guacamole.auth.jdbc.permission.SystemPermissionModel"> | ||||
|  | ||||
|         DELETE FROM guacamole_system_permission | ||||
|         WHERE (user_id, permission) IN | ||||
|             <foreach collection="permissions" item="permission" | ||||
|                      open="(" separator="," close=")"> | ||||
|                 (#{permission.userID,jdbcType=INTEGER}, | ||||
|                  #{permission.type,jdbcType=VARCHAR}) | ||||
|             </foreach> | ||||
|  | ||||
|     </delete> | ||||
|  | ||||
|     <!-- Insert all given permissions --> | ||||
|     <insert id="insert" parameterType="org.glyptodon.guacamole.auth.jdbc.permission.SystemPermissionModel"> | ||||
|  | ||||
|         INSERT IGNORE INTO guacamole_system_permission ( | ||||
|             user_id, | ||||
|             permission | ||||
|         ) | ||||
|         VALUES | ||||
|             <foreach collection="permissions" item="permission" separator=","> | ||||
|                 (#{permission.userID,jdbcType=INTEGER}, | ||||
|                  #{permission.type,jdbcType=VARCHAR}) | ||||
|             </foreach> | ||||
|  | ||||
|     </insert> | ||||
|  | ||||
| </mapper> | ||||
| @@ -0,0 +1,134 @@ | ||||
| <?xml version="1.0" encoding="UTF-8" ?> | ||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|     "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||||
|  | ||||
| <!-- | ||||
|    Copyright (C) 2015 Glyptodon LLC | ||||
|  | ||||
|    Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|    of this software and associated documentation files (the "Software"), to deal | ||||
|    in the Software without restriction, including without limitation the rights | ||||
|    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|    copies of the Software, and to permit persons to whom the Software is | ||||
|    furnished to do so, subject to the following conditions: | ||||
|  | ||||
|    The above copyright notice and this permission notice shall be included in | ||||
|    all copies or substantial portions of the Software. | ||||
|  | ||||
|    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
|    THE SOFTWARE. | ||||
| --> | ||||
|  | ||||
| <mapper namespace="org.glyptodon.guacamole.auth.jdbc.user.UserMapper" > | ||||
|  | ||||
|     <!-- Result mapper for user objects --> | ||||
|     <resultMap id="UserResultMap" type="org.glyptodon.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"/> | ||||
|     </resultMap> | ||||
|  | ||||
|     <!-- Select all usernames --> | ||||
|     <select id="selectIdentifiers" resultType="string"> | ||||
|         SELECT username | ||||
|         FROM guacamole_user | ||||
|     </select> | ||||
|  | ||||
|     <!-- Select usernames of all readable users --> | ||||
|     <select id="selectReadableIdentifiers" resultType="string"> | ||||
|         SELECT username | ||||
|         FROM guacamole_user | ||||
|         JOIN guacamole_user_permission ON affected_user_id = guacamole_user.user_id | ||||
|         WHERE | ||||
|             guacamole_user_permission.user_id = #{user.objectID,jdbcType=INTEGER} | ||||
|             AND permission = 'read' | ||||
|     </select> | ||||
|  | ||||
|     <!-- Select multiple users by username --> | ||||
|     <select id="select" resultMap="UserResultMap"> | ||||
|  | ||||
|         SELECT | ||||
|             user_id, | ||||
|             username, | ||||
|             password_hash, | ||||
|             password_salt | ||||
|         FROM guacamole_user | ||||
|         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 | ||||
|             guacamole_user.user_id, | ||||
|             username, | ||||
|             password_hash, | ||||
|             password_salt | ||||
|         FROM guacamole_user | ||||
|         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 id="selectByCredentials" resultMap="UserResultMap"> | ||||
|         SELECT | ||||
|             user_id, | ||||
|             username, | ||||
|             password_hash, | ||||
|             password_salt | ||||
|         FROM guacamole_user | ||||
|         WHERE | ||||
|                 username      = #{username,jdbcType=VARCHAR} | ||||
|             AND password_hash = UNHEX(SHA2(CONCAT(#{password,jdbcType=VARCHAR}, HEX(password_salt)), 256)) | ||||
|     </select> | ||||
|  | ||||
|     <!-- Delete single user by username --> | ||||
|     <delete id="delete"> | ||||
|         DELETE FROM guacamole_user | ||||
|         WHERE username = #{identifier,jdbcType=VARCHAR} | ||||
|     </delete> | ||||
|  | ||||
|     <!-- Insert single user --> | ||||
|     <insert id="insert" useGeneratedKeys="true" keyProperty="object.objectID" | ||||
|             parameterType="org.glyptodon.guacamole.auth.jdbc.user.UserModel"> | ||||
|  | ||||
|         INSERT INTO guacamole_user ( | ||||
|             username, | ||||
|             password_hash, | ||||
|             password_salt | ||||
|         ) | ||||
|         VALUES ( | ||||
|             #{object.identifier,jdbcType=VARCHAR}, | ||||
|             #{object.passwordHash,jdbcType=BINARY}, | ||||
|             #{object.passwordSalt,jdbcType=BINARY} | ||||
|         ) | ||||
|  | ||||
|     </insert> | ||||
|  | ||||
|     <!-- Update single user --> | ||||
|     <update id="update" parameterType="org.glyptodon.guacamole.auth.jdbc.user.UserModel"> | ||||
|         UPDATE guacamole_user | ||||
|         SET password_hash = #{object.passwordHash,jdbcType=BINARY}, | ||||
|             password_salt = #{object.passwordSalt,jdbcType=BINARY} | ||||
|         WHERE user_id = #{object.objectID,jdbcType=VARCHAR} | ||||
|     </update> | ||||
|  | ||||
| </mapper> | ||||
		Reference in New Issue
	
	Block a user