GUAC-1132: Modify API to support listing of active connections and host information.

This commit is contained in:
Michael Jumper
2015-03-16 14:26:56 -07:00
parent 093a5a0dd9
commit 3603155f36
8 changed files with 108 additions and 4 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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<ConnectionRecord> getActiveConnections() throws GuacamoleException {
// STUB
return Collections.EMPTY_LIST;
}
}

View File

@@ -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();
}

View File

@@ -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<ConnectionRecord> getActiveConnections()
throws GuacamoleException;
}

View File

@@ -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<ConnectionRecord> getActiveConnections()
throws GuacamoleException {
return Collections.EMPTY_LIST;
}
}

View File

@@ -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.
*/
@@ -63,6 +68,7 @@ public class APIConnectionRecord {
public APIConnectionRecord(ConnectionRecord record) {
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.

View File

@@ -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.