mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-394: Pull connection last active time from history records.
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package org.apache.guacamole.auth.jdbc.connection;
|
package org.apache.guacamole.auth.jdbc.connection;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.guacamole.auth.jdbc.base.ChildObjectModel;
|
import org.apache.guacamole.auth.jdbc.base.ChildObjectModel;
|
||||||
@@ -92,6 +93,12 @@ public class ConnectionModel extends ChildObjectModel {
|
|||||||
*/
|
*/
|
||||||
private EncryptionMethod proxyEncryptionMethod;
|
private EncryptionMethod proxyEncryptionMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The date and time that this connection was last used, or null if this
|
||||||
|
* connection has never been used.
|
||||||
|
*/
|
||||||
|
private Date lastActive;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new, empty connection.
|
* Creates a new, empty connection.
|
||||||
*/
|
*/
|
||||||
@@ -341,6 +348,32 @@ public class ConnectionModel extends ChildObjectModel {
|
|||||||
this.sharingProfileIdentifiers = sharingProfileIdentifiers;
|
this.sharingProfileIdentifiers = sharingProfileIdentifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the date and time that this connection was last used, or null if
|
||||||
|
* this connection has never been used.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* The date and time that this connection was last used, or null if this
|
||||||
|
* connection has never been used.
|
||||||
|
*/
|
||||||
|
public Date getLastActive() {
|
||||||
|
return lastActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the date and time that this connection was last used. This value is
|
||||||
|
* expected to be set automatically via queries, derived from connection
|
||||||
|
* history records. It does NOT correspond to an actual column, and values
|
||||||
|
* set manually through invoking this function will not persist.
|
||||||
|
*
|
||||||
|
* @param lastActive
|
||||||
|
* The date and time that this connection was last used, or null if this
|
||||||
|
* connection has never been used.
|
||||||
|
*/
|
||||||
|
public void setLastActive(Date lastActive) {
|
||||||
|
this.lastActive = lastActive;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifier() {
|
public String getIdentifier() {
|
||||||
|
|
||||||
|
@@ -235,7 +235,7 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date getLastActive() {
|
public Date getLastActive() {
|
||||||
return null;
|
return getModel().getLastActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
javaType="org.apache.guacamole.net.auth.GuacamoleProxyConfiguration$EncryptionMethod"/>
|
javaType="org.apache.guacamole.net.auth.GuacamoleProxyConfiguration$EncryptionMethod"/>
|
||||||
<result column="connection_weight" property="connectionWeight" jdbcType="INTEGER"/>
|
<result column="connection_weight" property="connectionWeight" jdbcType="INTEGER"/>
|
||||||
<result column="failover_only" property="failoverOnly" jdbcType="BOOLEAN"/>
|
<result column="failover_only" property="failoverOnly" jdbcType="BOOLEAN"/>
|
||||||
|
<result column="last_active" property="lastActive" jdbcType="TIMESTAMP"/>
|
||||||
|
|
||||||
<!-- Associated sharing profiles -->
|
<!-- Associated sharing profiles -->
|
||||||
<collection property="sharingProfileIdentifiers" resultSet="sharingProfiles" ofType="java.lang.String"
|
<collection property="sharingProfileIdentifiers" resultSet="sharingProfiles" ofType="java.lang.String"
|
||||||
@@ -89,8 +90,8 @@
|
|||||||
resultSets="connections,sharingProfiles">
|
resultSets="connections,sharingProfiles">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
connection_id,
|
guacamole_connection.connection_id,
|
||||||
connection_name,
|
guacamole_connection.connection_name,
|
||||||
parent_id,
|
parent_id,
|
||||||
protocol,
|
protocol,
|
||||||
max_connections,
|
max_connections,
|
||||||
@@ -99,13 +100,16 @@
|
|||||||
proxy_port,
|
proxy_port,
|
||||||
proxy_encryption_method,
|
proxy_encryption_method,
|
||||||
connection_weight,
|
connection_weight,
|
||||||
failover_only
|
failover_only,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM guacamole_connection
|
FROM guacamole_connection
|
||||||
WHERE connection_id IN
|
JOIN guacamole_connection_history ON guacamole_connection_history.connection_id = guacamole_connection.connection_id
|
||||||
|
WHERE guacamole_connection.connection_id IN
|
||||||
<foreach collection="identifiers" item="identifier"
|
<foreach collection="identifiers" item="identifier"
|
||||||
open="(" separator="," close=")">
|
open="(" separator="," close=")">
|
||||||
#{identifier,jdbcType=VARCHAR}
|
#{identifier,jdbcType=VARCHAR}
|
||||||
</foreach>;
|
</foreach>
|
||||||
|
GROUP BY guacamole_connection.connection_id;
|
||||||
|
|
||||||
SELECT primary_connection_id, sharing_profile_id
|
SELECT primary_connection_id, sharing_profile_id
|
||||||
FROM guacamole_sharing_profile
|
FROM guacamole_sharing_profile
|
||||||
@@ -123,7 +127,7 @@
|
|||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
guacamole_connection.connection_id,
|
guacamole_connection.connection_id,
|
||||||
connection_name,
|
guacamole_connection.connection_name,
|
||||||
parent_id,
|
parent_id,
|
||||||
protocol,
|
protocol,
|
||||||
max_connections,
|
max_connections,
|
||||||
@@ -132,16 +136,19 @@
|
|||||||
proxy_port,
|
proxy_port,
|
||||||
proxy_encryption_method,
|
proxy_encryption_method,
|
||||||
connection_weight,
|
connection_weight,
|
||||||
failover_only
|
failover_only,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM guacamole_connection
|
FROM guacamole_connection
|
||||||
JOIN guacamole_connection_permission ON guacamole_connection_permission.connection_id = guacamole_connection.connection_id
|
JOIN guacamole_connection_permission ON guacamole_connection_permission.connection_id = guacamole_connection.connection_id
|
||||||
|
JOIN guacamole_connection_history ON guacamole_connection_history.connection_id = guacamole_connection.connection_id
|
||||||
WHERE guacamole_connection.connection_id IN
|
WHERE guacamole_connection.connection_id IN
|
||||||
<foreach collection="identifiers" item="identifier"
|
<foreach collection="identifiers" item="identifier"
|
||||||
open="(" separator="," close=")">
|
open="(" separator="," close=")">
|
||||||
#{identifier,jdbcType=VARCHAR}
|
#{identifier,jdbcType=VARCHAR}
|
||||||
</foreach>
|
</foreach>
|
||||||
AND user_id = #{user.objectID,jdbcType=INTEGER}
|
AND user_id = #{user.objectID,jdbcType=INTEGER}
|
||||||
AND permission = 'READ';
|
AND permission = 'READ'
|
||||||
|
GROUP BY guacamole_connection.connection_id;
|
||||||
|
|
||||||
SELECT primary_connection_id, guacamole_sharing_profile.sharing_profile_id
|
SELECT primary_connection_id, guacamole_sharing_profile.sharing_profile_id
|
||||||
FROM guacamole_sharing_profile
|
FROM guacamole_sharing_profile
|
||||||
@@ -160,8 +167,8 @@
|
|||||||
<select id="selectOneByName" resultMap="ConnectionResultMap">
|
<select id="selectOneByName" resultMap="ConnectionResultMap">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
connection_id,
|
guacamole_connection.connection_id,
|
||||||
connection_name,
|
guacamole_connection.connection_name,
|
||||||
parent_id,
|
parent_id,
|
||||||
protocol,
|
protocol,
|
||||||
max_connections,
|
max_connections,
|
||||||
@@ -170,12 +177,15 @@
|
|||||||
proxy_port,
|
proxy_port,
|
||||||
proxy_encryption_method,
|
proxy_encryption_method,
|
||||||
connection_weight,
|
connection_weight,
|
||||||
failover_only
|
failover_only,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM guacamole_connection
|
FROM guacamole_connection
|
||||||
|
JOIN guacamole_connection_history ON guacamole_connection_history.connection_id = guacamole_connection.connection_id
|
||||||
WHERE
|
WHERE
|
||||||
<if test="parentIdentifier != null">parent_id = #{parentIdentifier,jdbcType=VARCHAR}</if>
|
<if test="parentIdentifier != null">parent_id = #{parentIdentifier,jdbcType=VARCHAR}</if>
|
||||||
<if test="parentIdentifier == null">parent_id IS NULL</if>
|
<if test="parentIdentifier == null">parent_id IS NULL</if>
|
||||||
AND connection_name = #{name,jdbcType=VARCHAR}
|
AND guacamole_connection.connection_name = #{name,jdbcType=VARCHAR}
|
||||||
|
GROUP BY guacamole_connection.connection_id
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
javaType="org.apache.guacamole.net.auth.GuacamoleProxyConfiguration$EncryptionMethod"/>
|
javaType="org.apache.guacamole.net.auth.GuacamoleProxyConfiguration$EncryptionMethod"/>
|
||||||
<result column="connection_weight" property="connectionWeight" jdbcType="INTEGER"/>
|
<result column="connection_weight" property="connectionWeight" jdbcType="INTEGER"/>
|
||||||
<result column="failover_only" property="failoverOnly" jdbcType="BOOLEAN"/>
|
<result column="failover_only" property="failoverOnly" jdbcType="BOOLEAN"/>
|
||||||
|
<result column="last_active" property="lastActive" jdbcType="TIMESTAMP"/>
|
||||||
|
|
||||||
<!-- Associated sharing profiles -->
|
<!-- Associated sharing profiles -->
|
||||||
<collection property="sharingProfileIdentifiers" resultSet="sharingProfiles" ofType="java.lang.String"
|
<collection property="sharingProfileIdentifiers" resultSet="sharingProfiles" ofType="java.lang.String"
|
||||||
@@ -89,8 +90,8 @@
|
|||||||
resultSets="connections,sharingProfiles">
|
resultSets="connections,sharingProfiles">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
connection_id,
|
guacamole_connection.connection_id,
|
||||||
connection_name,
|
guacamole_connection.connection_name,
|
||||||
parent_id,
|
parent_id,
|
||||||
protocol,
|
protocol,
|
||||||
max_connections,
|
max_connections,
|
||||||
@@ -99,13 +100,16 @@
|
|||||||
proxy_port,
|
proxy_port,
|
||||||
proxy_encryption_method,
|
proxy_encryption_method,
|
||||||
connection_weight,
|
connection_weight,
|
||||||
failover_only
|
failover_only,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM guacamole_connection
|
FROM guacamole_connection
|
||||||
WHERE connection_id IN
|
JOIN guacamole_connection_history ON guacamole_connection_history.connection_id = guacamole_connection.connection_id
|
||||||
|
WHERE guacamole_connection.connection_id IN
|
||||||
<foreach collection="identifiers" item="identifier"
|
<foreach collection="identifiers" item="identifier"
|
||||||
open="(" separator="," close=")">
|
open="(" separator="," close=")">
|
||||||
#{identifier,jdbcType=INTEGER}::integer
|
#{identifier,jdbcType=INTEGER}::integer
|
||||||
</foreach>;
|
</foreach>
|
||||||
|
GROUP BY guacamole_connection.connection_id;
|
||||||
|
|
||||||
SELECT primary_connection_id, sharing_profile_id
|
SELECT primary_connection_id, sharing_profile_id
|
||||||
FROM guacamole_sharing_profile
|
FROM guacamole_sharing_profile
|
||||||
@@ -123,7 +127,7 @@
|
|||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
guacamole_connection.connection_id,
|
guacamole_connection.connection_id,
|
||||||
connection_name,
|
guacamole_connection.connection_name,
|
||||||
parent_id,
|
parent_id,
|
||||||
protocol,
|
protocol,
|
||||||
max_connections,
|
max_connections,
|
||||||
@@ -132,16 +136,19 @@
|
|||||||
proxy_port,
|
proxy_port,
|
||||||
proxy_encryption_method,
|
proxy_encryption_method,
|
||||||
connection_weight,
|
connection_weight,
|
||||||
failover_only
|
failover_only,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM guacamole_connection
|
FROM guacamole_connection
|
||||||
JOIN guacamole_connection_permission ON guacamole_connection_permission.connection_id = guacamole_connection.connection_id
|
JOIN guacamole_connection_permission ON guacamole_connection_permission.connection_id = guacamole_connection.connection_id
|
||||||
|
JOIN guacamole_connection_history ON guacamole_connection_history.connection_id = guacamole_connection.connection_id
|
||||||
WHERE guacamole_connection.connection_id IN
|
WHERE guacamole_connection.connection_id IN
|
||||||
<foreach collection="identifiers" item="identifier"
|
<foreach collection="identifiers" item="identifier"
|
||||||
open="(" separator="," close=")">
|
open="(" separator="," close=")">
|
||||||
#{identifier,jdbcType=INTEGER}::integer
|
#{identifier,jdbcType=INTEGER}::integer
|
||||||
</foreach>
|
</foreach>
|
||||||
AND user_id = #{user.objectID,jdbcType=INTEGER}
|
AND user_id = #{user.objectID,jdbcType=INTEGER}
|
||||||
AND permission = 'READ';
|
AND permission = 'READ'
|
||||||
|
GROUP BY guacamole_connection.connection_id;
|
||||||
|
|
||||||
SELECT primary_connection_id, guacamole_sharing_profile.sharing_profile_id
|
SELECT primary_connection_id, guacamole_sharing_profile.sharing_profile_id
|
||||||
FROM guacamole_sharing_profile
|
FROM guacamole_sharing_profile
|
||||||
@@ -160,8 +167,8 @@
|
|||||||
<select id="selectOneByName" resultMap="ConnectionResultMap">
|
<select id="selectOneByName" resultMap="ConnectionResultMap">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
connection_id,
|
guacamole_connection.connection_id,
|
||||||
connection_name,
|
guacamole_connection.connection_name,
|
||||||
parent_id,
|
parent_id,
|
||||||
protocol,
|
protocol,
|
||||||
max_connections,
|
max_connections,
|
||||||
@@ -170,12 +177,15 @@
|
|||||||
proxy_port,
|
proxy_port,
|
||||||
proxy_encryption_method,
|
proxy_encryption_method,
|
||||||
connection_weight,
|
connection_weight,
|
||||||
failover_only
|
failover_only,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM guacamole_connection
|
FROM guacamole_connection
|
||||||
|
JOIN guacamole_connection_history ON guacamole_connection_history.connection_id = guacamole_connection.connection_id
|
||||||
WHERE
|
WHERE
|
||||||
<if test="parentIdentifier != null">parent_id = #{parentIdentifier,jdbcType=INTEGER}::integer</if>
|
<if test="parentIdentifier != null">parent_id = #{parentIdentifier,jdbcType=INTEGER}::integer</if>
|
||||||
<if test="parentIdentifier == null">parent_id IS NULL</if>
|
<if test="parentIdentifier == null">parent_id IS NULL</if>
|
||||||
AND connection_name = #{name,jdbcType=VARCHAR}
|
AND guacamole_connection.connection_name = #{name,jdbcType=VARCHAR}
|
||||||
|
GROUP BY guacamole_connection.connection_id
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
javaType="org.apache.guacamole.net.auth.GuacamoleProxyConfiguration$EncryptionMethod"/>
|
javaType="org.apache.guacamole.net.auth.GuacamoleProxyConfiguration$EncryptionMethod"/>
|
||||||
<result column="connection_weight" property="connectionWeight" jdbcType="INTEGER"/>
|
<result column="connection_weight" property="connectionWeight" jdbcType="INTEGER"/>
|
||||||
<result column="failover_only" property="failoverOnly" jdbcType="BOOLEAN"/>
|
<result column="failover_only" property="failoverOnly" jdbcType="BOOLEAN"/>
|
||||||
|
<result column="last_active" property="lastActive" jdbcType="TIMESTAMP"/>
|
||||||
|
|
||||||
<!-- Associated sharing profiles -->
|
<!-- Associated sharing profiles -->
|
||||||
<collection property="sharingProfileIdentifiers" resultSet="sharingProfiles" ofType="java.lang.String"
|
<collection property="sharingProfileIdentifiers" resultSet="sharingProfiles" ofType="java.lang.String"
|
||||||
@@ -89,8 +90,8 @@
|
|||||||
resultSets="connections,sharingProfiles">
|
resultSets="connections,sharingProfiles">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
connection_id,
|
[guacamole_connection].connection_id,
|
||||||
connection_name,
|
[guacamole_connection].connection_name,
|
||||||
parent_id,
|
parent_id,
|
||||||
protocol,
|
protocol,
|
||||||
max_connections,
|
max_connections,
|
||||||
@@ -99,13 +100,16 @@
|
|||||||
proxy_port,
|
proxy_port,
|
||||||
proxy_encryption_method,
|
proxy_encryption_method,
|
||||||
connection_weight,
|
connection_weight,
|
||||||
failover_only
|
failover_only,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM [guacamole_connection]
|
FROM [guacamole_connection]
|
||||||
WHERE connection_id IN
|
JOIN [guacamole_connection_history] ON [guacamole_connection_history].connection_id = [guacamole_connection].connection_id
|
||||||
|
WHERE [guacamole_connection].connection_id IN
|
||||||
<foreach collection="identifiers" item="identifier"
|
<foreach collection="identifiers" item="identifier"
|
||||||
open="(" separator="," close=")">
|
open="(" separator="," close=")">
|
||||||
#{identifier,jdbcType=INTEGER}
|
#{identifier,jdbcType=INTEGER}
|
||||||
</foreach>;
|
</foreach>
|
||||||
|
GROUP BY [guacamole_connection].connection_id;
|
||||||
|
|
||||||
SELECT primary_connection_id, sharing_profile_id
|
SELECT primary_connection_id, sharing_profile_id
|
||||||
FROM [guacamole_sharing_profile]
|
FROM [guacamole_sharing_profile]
|
||||||
@@ -123,7 +127,7 @@
|
|||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
[guacamole_connection].connection_id,
|
[guacamole_connection].connection_id,
|
||||||
connection_name,
|
[guacamole_connection].connection_name,
|
||||||
parent_id,
|
parent_id,
|
||||||
protocol,
|
protocol,
|
||||||
max_connections,
|
max_connections,
|
||||||
@@ -132,16 +136,19 @@
|
|||||||
proxy_port,
|
proxy_port,
|
||||||
proxy_encryption_method,
|
proxy_encryption_method,
|
||||||
connection_weight,
|
connection_weight,
|
||||||
failover_only
|
failover_only,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM [guacamole_connection]
|
FROM [guacamole_connection]
|
||||||
JOIN [guacamole_connection_permission] ON [guacamole_connection_permission].connection_id = [guacamole_connection].connection_id
|
JOIN [guacamole_connection_permission] ON [guacamole_connection_permission].connection_id = [guacamole_connection].connection_id
|
||||||
|
JOIN [guacamole_connection_history] ON [guacamole_connection_history].connection_id = [guacamole_connection].connection_id
|
||||||
WHERE [guacamole_connection].connection_id IN
|
WHERE [guacamole_connection].connection_id IN
|
||||||
<foreach collection="identifiers" item="identifier"
|
<foreach collection="identifiers" item="identifier"
|
||||||
open="(" separator="," close=")">
|
open="(" separator="," close=")">
|
||||||
#{identifier,jdbcType=INTEGER}
|
#{identifier,jdbcType=INTEGER}
|
||||||
</foreach>
|
</foreach>
|
||||||
AND user_id = #{user.objectID,jdbcType=INTEGER}
|
AND user_id = #{user.objectID,jdbcType=INTEGER}
|
||||||
AND permission = 'READ';
|
AND permission = 'READ'
|
||||||
|
GROUP BY [guacamole_connection].connection_id;
|
||||||
|
|
||||||
SELECT primary_connection_id, [guacamole_sharing_profile].sharing_profile_id
|
SELECT primary_connection_id, [guacamole_sharing_profile].sharing_profile_id
|
||||||
FROM [guacamole_sharing_profile]
|
FROM [guacamole_sharing_profile]
|
||||||
@@ -160,8 +167,8 @@
|
|||||||
<select id="selectOneByName" resultMap="ConnectionResultMap">
|
<select id="selectOneByName" resultMap="ConnectionResultMap">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
connection_id,
|
[guacamole_connection].connection_id,
|
||||||
connection_name,
|
[guacamole_connection].connection_name,
|
||||||
parent_id,
|
parent_id,
|
||||||
protocol,
|
protocol,
|
||||||
max_connections,
|
max_connections,
|
||||||
@@ -170,12 +177,15 @@
|
|||||||
proxy_port,
|
proxy_port,
|
||||||
proxy_encryption_method,
|
proxy_encryption_method,
|
||||||
connection_weight,
|
connection_weight,
|
||||||
failover_only
|
failover_only,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM [guacamole_connection]
|
FROM [guacamole_connection]
|
||||||
|
JOIN [guacamole_connection_history] ON [guacamole_connection_history].connection_id = [guacamole_connection].connection_id
|
||||||
WHERE
|
WHERE
|
||||||
<if test="parentIdentifier != null">parent_id = #{parentIdentifier,jdbcType=INTEGER}</if>
|
<if test="parentIdentifier != null">parent_id = #{parentIdentifier,jdbcType=INTEGER}</if>
|
||||||
<if test="parentIdentifier == null">parent_id IS NULL</if>
|
<if test="parentIdentifier == null">parent_id IS NULL</if>
|
||||||
AND connection_name = #{name,jdbcType=VARCHAR}
|
AND [guacamole_connection].connection_name = #{name,jdbcType=VARCHAR}
|
||||||
|
GROUP BY [guacamole_connection].connection_id
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user