GUACAMOLE-394: Expose "last active" time for connections and users via REST API.
Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/67fc77a1 Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/67fc77a1 Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/67fc77a1 Branch: refs/heads/staging/0.9.14 Commit: 67fc77a1c7a2efb64e74d400fec8d2013c41ab56 Parents: b8ce9c9 Author: Michael Jumper <[email protected]> Authored: Mon Sep 11 19:03:27 2017 -0700 Committer: Michael Jumper <[email protected]> Committed: Mon Dec 11 20:44:28 2017 -0800 ---------------------------------------------------------------------- .../rest/connection/APIConnection.java | 33 +++++++++++++++++++- .../org/apache/guacamole/rest/user/APIUser.java | 31 ++++++++++++++++++ .../main/webapp/app/rest/types/Connection.js | 9 ++++++ .../src/main/webapp/app/rest/types/User.js | 9 ++++++ 4 files changed, 81 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/67fc77a1/guacamole/src/main/java/org/apache/guacamole/rest/connection/APIConnection.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/connection/APIConnection.java b/guacamole/src/main/java/org/apache/guacamole/rest/connection/APIConnection.java index 8e6a385..e402e67 100644 --- a/guacamole/src/main/java/org/apache/guacamole/rest/connection/APIConnection.java +++ b/guacamole/src/main/java/org/apache/guacamole/rest/connection/APIConnection.java @@ -20,6 +20,7 @@ package org.apache.guacamole.rest.connection; import java.util.Collection; +import java.util.Date; import java.util.Map; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.map.annotate.JsonSerialize; @@ -75,7 +76,13 @@ public class APIConnection { * The count of currently active connections using this connection. */ private int activeConnections; - + + /** + * The date and time that this connection was last used, or null if this + * connection has never been used or this information is unavailable. + */ + private Date lastActive; + /** * Create an empty APIConnection. */ @@ -97,6 +104,7 @@ public class APIConnection { this.identifier = connection.getIdentifier(); this.parentIdentifier = connection.getParentIdentifier(); this.activeConnections = connection.getActiveConnections(); + this.lastActive = connection.getLastActive(); // Set protocol from configuration GuacamoleConfiguration configuration = connection.getConfiguration(); @@ -257,4 +265,27 @@ public class APIConnection { this.sharingProfiles = sharingProfiles; } + /** + * Returns the date and time that this connection was last used, or null if + * this connection has never been used or this information is unavailable. + * + * @return + * The date and time that this connection was last used, or null if this + * connection has never been used or this information is unavailable. + */ + public Date getLastActive() { + return lastActive; + } + + /** + * Sets the date and time that this connection was last used. + * + * @param lastActive + * The date and time that this connection was last used, or null if this + * connection has never been used or this information is unavailable. + */ + public void setLastActive(Date lastActive) { + this.lastActive = lastActive; + } + } http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/67fc77a1/guacamole/src/main/java/org/apache/guacamole/rest/user/APIUser.java ---------------------------------------------------------------------- diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/user/APIUser.java b/guacamole/src/main/java/org/apache/guacamole/rest/user/APIUser.java index 96e2230..e71b5d2 100644 --- a/guacamole/src/main/java/org/apache/guacamole/rest/user/APIUser.java +++ b/guacamole/src/main/java/org/apache/guacamole/rest/user/APIUser.java @@ -19,6 +19,7 @@ package org.apache.guacamole.rest.user; +import java.util.Date; import java.util.Map; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.map.annotate.JsonSerialize; @@ -47,6 +48,12 @@ public class APIUser { private Map<String, String> attributes; /** + * The date and time that this user was last logged in, or null if this user + * has never logged in or this information is unavailable. + */ + private Date lastActive; + + /** * Construct a new empty APIUser. */ public APIUser() {} @@ -60,6 +67,7 @@ public class APIUser { // Set user information this.username = user.getIdentifier(); this.password = user.getPassword(); + this.lastActive = user.getLastActive(); // Associate any attributes this.attributes = user.getAttributes(); @@ -122,4 +130,27 @@ public class APIUser { this.attributes = attributes; } + /** + * Returns the date and time that this user was last logged in, or null if + * this user has never logged in or this information is unavailable. + * + * @return + * The date and time that this user was last logged in, or null if this + * user has never logged in or this information is unavailable. + */ + public Date getLastActive() { + return lastActive; + } + + /** + * Sets the date and time that this user was last logged in. + * + * @param lastActive + * The date and time that this user was last logged in, or null if this + * user has never logged in or this information is unavailable. + */ + public void setLastActive(Date lastActive) { + this.lastActive = lastActive; + } + } http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/67fc77a1/guacamole/src/main/webapp/app/rest/types/Connection.js ---------------------------------------------------------------------- diff --git a/guacamole/src/main/webapp/app/rest/types/Connection.js b/guacamole/src/main/webapp/app/rest/types/Connection.js index b4639b2..52da6b7 100644 --- a/guacamole/src/main/webapp/app/rest/types/Connection.js +++ b/guacamole/src/main/webapp/app/rest/types/Connection.js @@ -104,6 +104,15 @@ angular.module('rest').factory('Connection', [function defineConnection() { */ this.sharingProfiles = template.sharingProfiles; + /** + * The time that this connection was last used, in seconds since + * 1970-01-01 00:00:00 UTC. If this information is unknown or + * unavailable, this will be null. + * + * @type Number + */ + this.lastActive = template.lastActive; + }; return Connection; http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/67fc77a1/guacamole/src/main/webapp/app/rest/types/User.js ---------------------------------------------------------------------- diff --git a/guacamole/src/main/webapp/app/rest/types/User.js b/guacamole/src/main/webapp/app/rest/types/User.js index 9edd1f2..d0a96cc 100644 --- a/guacamole/src/main/webapp/app/rest/types/User.js +++ b/guacamole/src/main/webapp/app/rest/types/User.js @@ -54,6 +54,15 @@ angular.module('rest').factory('User', [function defineUser() { this.password = template.password; /** + * The time that this user was last logged in, in seconds since + * 1970-01-01 00:00:00 UTC. If this information is unknown or + * unavailable, this will be null. + * + * @type Number + */ + this.lastActive = template.lastActive; + + /** * Arbitrary name/value pairs which further describe this user. The * semantics and validity of these attributes are dictated by the * extension which defines them.
