diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connection/ModeledConnectionRecord.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connection/ModeledConnectionRecord.java index c86e46588..41615c794 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connection/ModeledConnectionRecord.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connection/ModeledConnectionRecord.java @@ -24,6 +24,7 @@ package org.glyptodon.guacamole.auth.jdbc.connection; import java.util.Date; +import org.glyptodon.guacamole.net.GuacamoleSocket; import org.glyptodon.guacamole.net.auth.ConnectionRecord; /** @@ -61,6 +62,12 @@ public class ModeledConnectionRecord implements ConnectionRecord { return model.getEndDate(); } + @Override + public String getRemoteHost() { + // STUB + return "STUB"; + } + @Override public String getUsername() { return model.getUsername(); @@ -71,4 +78,9 @@ public class ModeledConnectionRecord implements ConnectionRecord { return false; } + @Override + public GuacamoleSocket getActiveSocket() { + return null; + } + } diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/socket/ActiveConnectionRecord.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/socket/ActiveConnectionRecord.java index 5d23a7443..500b274f8 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/socket/ActiveConnectionRecord.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/socket/ActiveConnectionRecord.java @@ -26,6 +26,7 @@ import java.util.Date; import org.glyptodon.guacamole.auth.jdbc.connection.ModeledConnection; import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ModeledConnectionGroup; import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser; +import org.glyptodon.guacamole.net.GuacamoleSocket; import org.glyptodon.guacamole.net.auth.ConnectionRecord; @@ -162,6 +163,12 @@ public class ActiveConnectionRecord implements ConnectionRecord { } + @Override + public String getRemoteHost() { + // STUB + return "STUB"; + } + @Override public String getUsername() { return user.getUser().getIdentifier(); @@ -175,4 +182,10 @@ public class ActiveConnectionRecord implements ConnectionRecord { } + @Override + public GuacamoleSocket getActiveSocket() { + // STUB + return null; + } + } diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/UserContext.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/UserContext.java index fac5b9af9..b4d3de31f 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/UserContext.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/UserContext.java @@ -28,10 +28,13 @@ import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ConnectionGroupDirector import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionDirectory; import com.google.inject.Inject; import com.google.inject.Provider; +import java.util.Collection; +import java.util.Collections; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.auth.jdbc.base.RestrictedObject; import org.glyptodon.guacamole.net.auth.Connection; import org.glyptodon.guacamole.net.auth.ConnectionGroup; +import org.glyptodon.guacamole.net.auth.ConnectionRecord; import org.glyptodon.guacamole.net.auth.Directory; import org.glyptodon.guacamole.net.auth.User; @@ -114,4 +117,10 @@ public class UserContext extends RestrictedObject } + @Override + public Collection getActiveConnections() throws GuacamoleException { + // STUB + return Collections.EMPTY_LIST; + } + } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/ConnectionRecord.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/ConnectionRecord.java index 208b3c397..7a4b4d219 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/ConnectionRecord.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/ConnectionRecord.java @@ -23,6 +23,7 @@ package org.glyptodon.guacamole.net.auth; import java.util.Date; +import org.glyptodon.guacamole.net.GuacamoleSocket; /** * A logging record describing when a user started and ended usage of a @@ -47,6 +48,17 @@ public interface ConnectionRecord { */ public Date getEndDate(); + /** + * Returns the hostname or IP address of the remote host that used the + * connection associated with this record, if known. If the hostname or IP + * address is not known, null is returned. + * + * @return + * The hostname or IP address of the remote host, or null if this + * information is not available. + */ + public String getRemoteHost(); + /** * Returns the name of the user who used or is using the connection at the * times given by this connection record. @@ -65,4 +77,15 @@ public interface ConnectionRecord { */ public boolean isActive(); + /** + * Returns the connected GuacamoleSocket of the connection associated with + * this record, if any. If the connection is not active, or access to + * the socket is denied, null is returned. + * + * @return + * The connected GuacamoleSocket, if any, or null if the connection is + * not active or permission is denied. + */ + public GuacamoleSocket getActiveSocket(); + } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/UserContext.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/UserContext.java index c38d9a90f..010e3e3a6 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/UserContext.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/UserContext.java @@ -22,6 +22,7 @@ package org.glyptodon.guacamole.net.auth; +import java.util.Collection; import org.glyptodon.guacamole.GuacamoleException; /** @@ -95,4 +96,20 @@ public interface UserContext { */ ConnectionGroup getRootConnectionGroup() throws GuacamoleException; + /** + * Returns a collection of connection records associated with all active + * connections to which the current user has access. For an administrative + * user, this may include connections associated with other users. + * + * @return + * A collection of all connection records associated with active + * connections to which the current user has access. + * + * @throws GuacamoleException + * If an error occurs while reading active connection records, or if + * permission is denied. + */ + Collection getActiveConnections() + throws GuacamoleException; + } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUserContext.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUserContext.java index 8ee7e84c1..3f19ec7fc 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUserContext.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUserContext.java @@ -30,6 +30,7 @@ import java.util.UUID; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.net.auth.Connection; import org.glyptodon.guacamole.net.auth.ConnectionGroup; +import org.glyptodon.guacamole.net.auth.ConnectionRecord; import org.glyptodon.guacamole.net.auth.Directory; import org.glyptodon.guacamole.net.auth.User; import org.glyptodon.guacamole.net.auth.UserContext; @@ -167,4 +168,10 @@ public class SimpleUserContext implements UserContext { return rootGroup; } + @Override + public Collection getActiveConnections() + throws GuacamoleException { + return Collections.EMPTY_LIST; + } + } diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnectionRecord.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnectionRecord.java index e1423ac8f..e3912ecbe 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnectionRecord.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnectionRecord.java @@ -43,6 +43,11 @@ public class APIConnectionRecord { */ private final Date endDate; + /** + * The host from which the connection originated, if known. + */ + private final String remoteHost; + /** * The name of the user who used or is using the connection. */ @@ -61,10 +66,11 @@ public class APIConnectionRecord { * The record to copy data from. */ public APIConnectionRecord(ConnectionRecord record) { - this.startDate = record.getStartDate(); - this.endDate = record.getEndDate(); - this.username = record.getUsername(); - this.active = record.isActive(); + this.startDate = record.getStartDate(); + this.endDate = record.getEndDate(); + this.remoteHost = record.getRemoteHost(); + this.username = record.getUsername(); + this.active = record.isActive(); } /** @@ -88,6 +94,16 @@ public class APIConnectionRecord { return endDate; } + /** + * Returns the remote host from which this connection originated. + * + * @return + * The remote host from which this connection originated. + */ + public String getRemoteHost() { + return remoteHost; + } + /** * Returns the name of the user who used or is using the connection at the * times given by this connection record. diff --git a/guacamole/src/main/webapp/app/rest/types/ConnectionHistoryEntry.js b/guacamole/src/main/webapp/app/rest/types/ConnectionHistoryEntry.js index 9f0023323..299c65c13 100644 --- a/guacamole/src/main/webapp/app/rest/types/ConnectionHistoryEntry.js +++ b/guacamole/src/main/webapp/app/rest/types/ConnectionHistoryEntry.js @@ -60,6 +60,13 @@ angular.module('rest').factory('ConnectionHistoryEntry', [function defineConnect */ this.endDate = template.endDate; + /** + * The remote host that initiated this connection, if known. + * + * @type String + */ + this.remoteHost = template.remoteHost; + /** * The username of the user associated with this particular usage of * the connection.