mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-1123: Implement new methods for retrieving user and connection history.
This commit is contained in:
@@ -48,7 +48,7 @@ public abstract class ModeledActivityRecordSet<RecordType extends ActivityRecord
|
|||||||
* strings within the collection will be excluded from the results.
|
* strings within the collection will be excluded from the results.
|
||||||
*/
|
*/
|
||||||
private final Set<ActivityRecordSearchTerm> requiredContents =
|
private final Set<ActivityRecordSearchTerm> requiredContents =
|
||||||
new HashSet<ActivityRecordSearchTerm>();
|
new HashSet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum number of history records that should be returned by a call
|
* The maximum number of history records that should be returned by a call
|
||||||
@@ -62,7 +62,7 @@ public abstract class ModeledActivityRecordSet<RecordType extends ActivityRecord
|
|||||||
* properties.
|
* properties.
|
||||||
*/
|
*/
|
||||||
private final List<ActivityRecordSortPredicate> sortPredicates =
|
private final List<ActivityRecordSortPredicate> sortPredicates =
|
||||||
new ArrayList<ActivityRecordSortPredicate>();
|
new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the history records matching the given criteria. Retrieves up
|
* Retrieves the history records matching the given criteria. Retrieves up
|
||||||
|
@@ -27,6 +27,7 @@ import org.apache.guacamole.GuacamoleException;
|
|||||||
import org.apache.guacamole.auth.jdbc.base.ActivityRecordSearchTerm;
|
import org.apache.guacamole.auth.jdbc.base.ActivityRecordSearchTerm;
|
||||||
import org.apache.guacamole.auth.jdbc.base.ActivityRecordSortPredicate;
|
import org.apache.guacamole.auth.jdbc.base.ActivityRecordSortPredicate;
|
||||||
import org.apache.guacamole.auth.jdbc.base.ModeledActivityRecordSet;
|
import org.apache.guacamole.auth.jdbc.base.ModeledActivityRecordSet;
|
||||||
|
import org.apache.guacamole.auth.jdbc.user.ModeledAuthenticatedUser;
|
||||||
import org.apache.guacamole.net.auth.AuthenticatedUser;
|
import org.apache.guacamole.net.auth.AuthenticatedUser;
|
||||||
import org.apache.guacamole.net.auth.ConnectionRecord;
|
import org.apache.guacamole.net.auth.ConnectionRecord;
|
||||||
|
|
||||||
@@ -43,6 +44,27 @@ public class ConnectionRecordSet extends ModeledActivityRecordSet<ConnectionReco
|
|||||||
@Inject
|
@Inject
|
||||||
private ConnectionService connectionService;
|
private ConnectionService connectionService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The identifier of the connection to which this record set should be
|
||||||
|
* limited, if any.
|
||||||
|
*/
|
||||||
|
private String identifier = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes this object, associating it with the current authenticated
|
||||||
|
* user and connection identifier.
|
||||||
|
*
|
||||||
|
* @param currentUser
|
||||||
|
* The user that created or retrieved this object.
|
||||||
|
*
|
||||||
|
* @param identifier
|
||||||
|
* The connection identifier to which this record set should be limited.
|
||||||
|
*/
|
||||||
|
protected void init(ModeledAuthenticatedUser currentUser, String identifier) {
|
||||||
|
super.init(currentUser);
|
||||||
|
this.identifier = identifier;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<ConnectionRecord> retrieveHistory(
|
protected Collection<ConnectionRecord> retrieveHistory(
|
||||||
AuthenticatedUser user, Set<ActivityRecordSearchTerm> requiredContents,
|
AuthenticatedUser user, Set<ActivityRecordSearchTerm> requiredContents,
|
||||||
@@ -50,7 +72,7 @@ public class ConnectionRecordSet extends ModeledActivityRecordSet<ConnectionReco
|
|||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
// Retrieve history from database
|
// Retrieve history from database
|
||||||
return connectionService.retrieveHistory(getCurrentUser(),
|
return connectionService.retrieveHistory(identifier, getCurrentUser(),
|
||||||
requiredContents, sortPredicates, limit);
|
requiredContents, sortPredicates, limit);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -40,6 +40,7 @@ import org.apache.guacamole.form.Form;
|
|||||||
import org.apache.guacamole.form.NumericField;
|
import org.apache.guacamole.form.NumericField;
|
||||||
import org.apache.guacamole.form.TextField;
|
import org.apache.guacamole.form.TextField;
|
||||||
import org.apache.guacamole.net.GuacamoleTunnel;
|
import org.apache.guacamole.net.GuacamoleTunnel;
|
||||||
|
import org.apache.guacamole.net.auth.ActivityRecordSet;
|
||||||
import org.apache.guacamole.net.auth.Connection;
|
import org.apache.guacamole.net.auth.Connection;
|
||||||
import org.apache.guacamole.net.auth.ConnectionRecord;
|
import org.apache.guacamole.net.auth.ConnectionRecord;
|
||||||
import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration;
|
import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration;
|
||||||
@@ -196,6 +197,12 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
|
|||||||
@Inject
|
@Inject
|
||||||
private Provider<ModeledGuacamoleConfiguration> configProvider;
|
private Provider<ModeledGuacamoleConfiguration> configProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provider for creating connection record sets.
|
||||||
|
*/
|
||||||
|
@Inject
|
||||||
|
private Provider<ConnectionRecordSet> connectionRecordSetProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The manually-set GuacamoleConfiguration, if any.
|
* The manually-set GuacamoleConfiguration, if any.
|
||||||
*/
|
*/
|
||||||
@@ -257,6 +264,14 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
|
|||||||
public List<? extends ConnectionRecord> getHistory() throws GuacamoleException {
|
public List<? extends ConnectionRecord> getHistory() throws GuacamoleException {
|
||||||
return connectionService.retrieveHistory(getCurrentUser(), this);
|
return connectionService.retrieveHistory(getCurrentUser(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||||
|
throws GuacamoleException {
|
||||||
|
ConnectionRecordSet connectionRecordSet = connectionRecordSetProvider.get();
|
||||||
|
connectionRecordSet.init(getCurrentUser(), this.getIdentifier());
|
||||||
|
return connectionRecordSet;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GuacamoleTunnel connect(GuacamoleClientInformation info,
|
public GuacamoleTunnel connect(GuacamoleClientInformation info,
|
||||||
|
@@ -26,10 +26,12 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
|
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||||
import org.apache.guacamole.auth.jdbc.sharing.connectiongroup.SharedRootConnectionGroup;
|
import org.apache.guacamole.auth.jdbc.sharing.connectiongroup.SharedRootConnectionGroup;
|
||||||
import org.apache.guacamole.auth.jdbc.tunnel.GuacamoleTunnelService;
|
import org.apache.guacamole.auth.jdbc.tunnel.GuacamoleTunnelService;
|
||||||
import org.apache.guacamole.auth.jdbc.user.RemoteAuthenticatedUser;
|
import org.apache.guacamole.auth.jdbc.user.RemoteAuthenticatedUser;
|
||||||
import org.apache.guacamole.net.GuacamoleTunnel;
|
import org.apache.guacamole.net.GuacamoleTunnel;
|
||||||
|
import org.apache.guacamole.net.auth.ActivityRecordSet;
|
||||||
import org.apache.guacamole.net.auth.Connection;
|
import org.apache.guacamole.net.auth.Connection;
|
||||||
import org.apache.guacamole.net.auth.ConnectionRecord;
|
import org.apache.guacamole.net.auth.ConnectionRecord;
|
||||||
import org.apache.guacamole.protocol.GuacamoleClientInformation;
|
import org.apache.guacamole.protocol.GuacamoleClientInformation;
|
||||||
@@ -157,6 +159,12 @@ public class SharedConnection implements Connection {
|
|||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
return Collections.<ConnectionRecord>emptyList();
|
return Collections.<ConnectionRecord>emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||||
|
throws GuacamoleException {
|
||||||
|
throw new GuacamoleUnsupportedException("SharedConnection objects do not provide history.");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getSharingProfileIdentifiers()
|
public Set<String> getSharingProfileIdentifiers()
|
||||||
|
@@ -24,8 +24,10 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
|
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||||
import org.apache.guacamole.auth.jdbc.sharing.permission.SharedObjectPermissionSet;
|
import org.apache.guacamole.auth.jdbc.sharing.permission.SharedObjectPermissionSet;
|
||||||
import org.apache.guacamole.net.auth.ActivityRecord;
|
import org.apache.guacamole.net.auth.ActivityRecord;
|
||||||
|
import org.apache.guacamole.net.auth.ActivityRecordSet;
|
||||||
import org.apache.guacamole.net.auth.AuthenticatedUser;
|
import org.apache.guacamole.net.auth.AuthenticatedUser;
|
||||||
import org.apache.guacamole.net.auth.Connection;
|
import org.apache.guacamole.net.auth.Connection;
|
||||||
import org.apache.guacamole.net.auth.ConnectionGroup;
|
import org.apache.guacamole.net.auth.ConnectionGroup;
|
||||||
@@ -106,6 +108,12 @@ public class SharedUser implements User {
|
|||||||
return Collections.<ActivityRecord>emptyList();
|
return Collections.<ActivityRecord>emptyList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||||
|
throws GuacamoleException {
|
||||||
|
throw new GuacamoleUnsupportedException("SharedUser objects do not provide login history.");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
|
@@ -47,6 +47,7 @@ import org.apache.guacamole.form.TextField;
|
|||||||
import org.apache.guacamole.form.TimeField;
|
import org.apache.guacamole.form.TimeField;
|
||||||
import org.apache.guacamole.form.TimeZoneField;
|
import org.apache.guacamole.form.TimeZoneField;
|
||||||
import org.apache.guacamole.net.auth.ActivityRecord;
|
import org.apache.guacamole.net.auth.ActivityRecord;
|
||||||
|
import org.apache.guacamole.net.auth.ActivityRecordSet;
|
||||||
import org.apache.guacamole.net.auth.Permissions;
|
import org.apache.guacamole.net.auth.Permissions;
|
||||||
import org.apache.guacamole.net.auth.RelatedObjectSet;
|
import org.apache.guacamole.net.auth.RelatedObjectSet;
|
||||||
import org.apache.guacamole.net.auth.User;
|
import org.apache.guacamole.net.auth.User;
|
||||||
@@ -182,6 +183,12 @@ public class ModeledUser extends ModeledPermissions<UserModel> implements User {
|
|||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
private Provider<UserParentUserGroupSet> parentUserGroupSetProvider;
|
private Provider<UserParentUserGroupSet> parentUserGroupSetProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provider for creating user record sets.
|
||||||
|
*/
|
||||||
|
@Inject
|
||||||
|
private Provider<UserRecordSet> userRecordSetProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether attributes which control access restrictions should be exposed
|
* Whether attributes which control access restrictions should be exposed
|
||||||
@@ -751,6 +758,14 @@ public class ModeledUser extends ModeledPermissions<UserModel> implements User {
|
|||||||
public List<ActivityRecord> getHistory() throws GuacamoleException {
|
public List<ActivityRecord> getHistory() throws GuacamoleException {
|
||||||
return userService.retrieveHistory(getCurrentUser(), this);
|
return userService.retrieveHistory(getCurrentUser(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||||
|
throws GuacamoleException {
|
||||||
|
UserRecordSet userRecordSet = userRecordSetProvider.get();
|
||||||
|
userRecordSet.init(getCurrentUser(), this.getIdentifier());
|
||||||
|
return userRecordSet;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RelatedObjectSet getUserGroups() throws GuacamoleException {
|
public RelatedObjectSet getUserGroups() throws GuacamoleException {
|
||||||
|
@@ -44,6 +44,13 @@ public class UserRecordSet extends ModeledActivityRecordSet<ActivityRecord> {
|
|||||||
@Inject
|
@Inject
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
|
private String identifier = null;
|
||||||
|
|
||||||
|
protected void init(ModeledAuthenticatedUser currentUser, String identifier) {
|
||||||
|
super.init(currentUser);
|
||||||
|
this.identifier = identifier;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<ActivityRecord> retrieveHistory(
|
protected Collection<ActivityRecord> retrieveHistory(
|
||||||
AuthenticatedUser user, Set<ActivityRecordSearchTerm> requiredContents,
|
AuthenticatedUser user, Set<ActivityRecordSearchTerm> requiredContents,
|
||||||
@@ -51,7 +58,7 @@ public class UserRecordSet extends ModeledActivityRecordSet<ActivityRecord> {
|
|||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
// Retrieve history from database
|
// Retrieve history from database
|
||||||
return userService.retrieveHistory(getCurrentUser(),
|
return userService.retrieveHistory(identifier, getCurrentUser(),
|
||||||
requiredContents, sortPredicates, limit);
|
requiredContents, sortPredicates, limit);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,7 @@ import java.util.Map;
|
|||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
|
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||||
import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
|
import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
|
||||||
|
import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base implementation of User which provides default implementations of
|
* Base implementation of User which provides default implementations of
|
||||||
@@ -96,6 +97,12 @@ public abstract class AbstractUser extends AbstractIdentifiable
|
|||||||
public List<ActivityRecord> getHistory() throws GuacamoleException {
|
public List<ActivityRecord> getHistory() throws GuacamoleException {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||||
|
throws GuacamoleException {
|
||||||
|
return new SimpleActivityRecordSet<>();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
@@ -109,6 +109,24 @@ public interface Connection extends Identifiable, Connectable, Attributes {
|
|||||||
*/
|
*/
|
||||||
public List<? extends ConnectionRecord> getHistory() throws GuacamoleException;
|
public List<? extends ConnectionRecord> getHistory() throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an ActivityRecordSet containing ConnectionRecords that
|
||||||
|
* represent the usage history of this Connection, including any active
|
||||||
|
* users. ConnectionRecords in this list will be sorted in descending order
|
||||||
|
* of end time (active connections are first), and then in descending order
|
||||||
|
* of start time (newer connections are first).
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* An ActivityRecordSet containing ConnectionRecords representing the
|
||||||
|
* usage history of this Connection.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs retrieving history for this Connection, or if
|
||||||
|
* permission to retrieve the history is denied.
|
||||||
|
*/
|
||||||
|
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||||
|
throws GuacamoleException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns identifiers of all readable sharing profiles that can be used to
|
* Returns identifiers of all readable sharing profiles that can be used to
|
||||||
* join this connection when it is active. The level of access granted to a
|
* join this connection when it is active. The level of access granted to a
|
||||||
|
@@ -139,6 +139,12 @@ public class DelegatingConnection implements Connection {
|
|||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
return connection.getHistory();
|
return connection.getHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||||
|
throws GuacamoleException {
|
||||||
|
return connection.getConnectionHistory();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getSharingProfileIdentifiers()
|
public Set<String> getSharingProfileIdentifiers()
|
||||||
|
@@ -98,6 +98,12 @@ public class DelegatingUser implements User {
|
|||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
return user.getHistory();
|
return user.getHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||||
|
throws GuacamoleException {
|
||||||
|
return user.getUserHistory();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SystemPermissionSet getSystemPermissions()
|
public SystemPermissionSet getSystemPermissions()
|
||||||
|
@@ -104,6 +104,24 @@ public interface User extends Identifiable, Attributes, Permissions {
|
|||||||
* permission is denied.
|
* permission is denied.
|
||||||
*/
|
*/
|
||||||
List<? extends ActivityRecord> getHistory() throws GuacamoleException;
|
List<? extends ActivityRecord> getHistory() throws GuacamoleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an ActivityRecordSet containing ActivityRecords representing
|
||||||
|
* the login history for this user, including any active sessions.
|
||||||
|
* ActivityRecords in this list will be sorted in descending order of end
|
||||||
|
* time (active sessions are first), and then in descending order of start
|
||||||
|
* time (newer sessions are first).
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* An ActivityRecordSet containing ActivityRecords representing the
|
||||||
|
* login history for this user.
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs retrieving this user's login history, or if
|
||||||
|
* permission to retrieve login history is denied.
|
||||||
|
*/
|
||||||
|
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||||
|
throws GuacamoleException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a set of all readable user groups of which this user is a member.
|
* Returns a set of all readable user groups of which this user is a member.
|
||||||
|
@@ -33,6 +33,7 @@ import org.apache.guacamole.net.InetGuacamoleSocket;
|
|||||||
import org.apache.guacamole.net.SSLGuacamoleSocket;
|
import org.apache.guacamole.net.SSLGuacamoleSocket;
|
||||||
import org.apache.guacamole.net.SimpleGuacamoleTunnel;
|
import org.apache.guacamole.net.SimpleGuacamoleTunnel;
|
||||||
import org.apache.guacamole.net.auth.AbstractConnection;
|
import org.apache.guacamole.net.auth.AbstractConnection;
|
||||||
|
import org.apache.guacamole.net.auth.ActivityRecordSet;
|
||||||
import org.apache.guacamole.net.auth.ConnectionRecord;
|
import org.apache.guacamole.net.auth.ConnectionRecord;
|
||||||
import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration;
|
import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration;
|
||||||
import org.apache.guacamole.protocol.ConfiguredGuacamoleSocket;
|
import org.apache.guacamole.protocol.ConfiguredGuacamoleSocket;
|
||||||
@@ -288,5 +289,11 @@ public class SimpleConnection extends AbstractConnection {
|
|||||||
public List<ConnectionRecord> getHistory() throws GuacamoleException {
|
public List<ConnectionRecord> getHistory() throws GuacamoleException {
|
||||||
return Collections.<ConnectionRecord>emptyList();
|
return Collections.<ConnectionRecord>emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||||
|
throws GuacamoleException {
|
||||||
|
return new SimpleActivityRecordSet<>();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,9 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
|
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||||
import org.apache.guacamole.net.GuacamoleTunnel;
|
import org.apache.guacamole.net.GuacamoleTunnel;
|
||||||
|
import org.apache.guacamole.net.auth.ActivityRecordSet;
|
||||||
import org.apache.guacamole.net.auth.Connection;
|
import org.apache.guacamole.net.auth.Connection;
|
||||||
import org.apache.guacamole.net.auth.ConnectionRecord;
|
import org.apache.guacamole.net.auth.ConnectionRecord;
|
||||||
import org.apache.guacamole.protocol.GuacamoleClientInformation;
|
import org.apache.guacamole.protocol.GuacamoleClientInformation;
|
||||||
@@ -123,14 +125,14 @@ public class APIConnectionWrapper implements Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getSharingProfileIdentifiers() {
|
public Set<String> getSharingProfileIdentifiers() throws GuacamoleException {
|
||||||
throw new UnsupportedOperationException("Operation not supported.");
|
throw new GuacamoleUnsupportedException("Operation not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GuacamoleTunnel connect(GuacamoleClientInformation info,
|
public GuacamoleTunnel connect(GuacamoleClientInformation info,
|
||||||
Map<String, String> tokens) throws GuacamoleException {
|
Map<String, String> tokens) throws GuacamoleException {
|
||||||
throw new UnsupportedOperationException("Operation not supported.");
|
throw new GuacamoleUnsupportedException("Operation not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -143,4 +145,11 @@ public class APIConnectionWrapper implements Connection {
|
|||||||
return Collections.<ConnectionRecord>emptyList();
|
return Collections.<ConnectionRecord>emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||||
|
throws GuacamoleException {
|
||||||
|
throw new GuacamoleUnsupportedException("APIConnectionWrapper does not "
|
||||||
|
+ "support retrieving connection history.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -22,8 +22,6 @@ package org.apache.guacamole.rest.connection;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
import com.google.inject.assistedinject.AssistedInject;
|
import com.google.inject.assistedinject.AssistedInject;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
@@ -33,7 +31,6 @@ import javax.ws.rs.core.MediaType;
|
|||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.GuacamoleSecurityException;
|
import org.apache.guacamole.GuacamoleSecurityException;
|
||||||
import org.apache.guacamole.net.auth.Connection;
|
import org.apache.guacamole.net.auth.Connection;
|
||||||
import org.apache.guacamole.net.auth.ConnectionRecord;
|
|
||||||
import org.apache.guacamole.net.auth.Directory;
|
import org.apache.guacamole.net.auth.Directory;
|
||||||
import org.apache.guacamole.net.auth.Permissions;
|
import org.apache.guacamole.net.auth.Permissions;
|
||||||
import org.apache.guacamole.rest.directory.DirectoryView;
|
import org.apache.guacamole.rest.directory.DirectoryView;
|
||||||
@@ -43,12 +40,12 @@ import org.apache.guacamole.net.auth.permission.ObjectPermission;
|
|||||||
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
|
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||||
import org.apache.guacamole.net.auth.permission.SystemPermission;
|
import org.apache.guacamole.net.auth.permission.SystemPermission;
|
||||||
import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
|
import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
|
||||||
import org.apache.guacamole.rest.history.APIConnectionRecord;
|
|
||||||
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
||||||
import org.apache.guacamole.rest.directory.DirectoryObjectResource;
|
import org.apache.guacamole.rest.directory.DirectoryObjectResource;
|
||||||
import org.apache.guacamole.rest.directory.DirectoryObjectTranslator;
|
import org.apache.guacamole.rest.directory.DirectoryObjectTranslator;
|
||||||
import org.apache.guacamole.rest.directory.DirectoryResource;
|
import org.apache.guacamole.rest.directory.DirectoryResource;
|
||||||
import org.apache.guacamole.rest.directory.DirectoryResourceFactory;
|
import org.apache.guacamole.rest.directory.DirectoryResourceFactory;
|
||||||
|
import org.apache.guacamole.rest.history.ConnectionHistoryResource;
|
||||||
import org.apache.guacamole.rest.sharingprofile.APISharingProfile;
|
import org.apache.guacamole.rest.sharingprofile.APISharingProfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,18 +147,11 @@ public class ConnectionResource extends DirectoryObjectResource<Connection, APIC
|
|||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If an error occurs while retrieving the connection history.
|
* If an error occurs while retrieving the connection history.
|
||||||
*/
|
*/
|
||||||
@GET
|
|
||||||
@Path("history")
|
@Path("history")
|
||||||
public List<APIConnectionRecord> getConnectionHistory()
|
public ConnectionHistoryResource getConnectionHistory()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
// Retrieve the requested connection's history
|
return new ConnectionHistoryResource(connection.getConnectionHistory());
|
||||||
List<APIConnectionRecord> apiRecords = new ArrayList<>();
|
|
||||||
for (ConnectionRecord record : connection.getHistory())
|
|
||||||
apiRecords.add(new APIConnectionRecord(record));
|
|
||||||
|
|
||||||
// Return the converted history
|
|
||||||
return apiRecords;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -84,7 +84,7 @@ public abstract class ActivityRecordSetResource<InternalRecordType extends Activ
|
|||||||
* A new record object containing the same data as the given internal
|
* A new record object containing the same data as the given internal
|
||||||
* record, but intended for use in interchange.
|
* record, but intended for use in interchange.
|
||||||
*/
|
*/
|
||||||
protected abstract ExternalRecordType toExternalRecord(InternalRecordType record);
|
public abstract ExternalRecordType toExternalRecord(InternalRecordType record);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the list of activity records stored within the underlying
|
* Retrieves the list of activity records stored within the underlying
|
||||||
|
@@ -42,7 +42,7 @@ public class ConnectionHistoryResource extends ActivityRecordSetResource<Connect
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected APIConnectionRecord toExternalRecord(ConnectionRecord record) {
|
public APIConnectionRecord toExternalRecord(ConnectionRecord record) {
|
||||||
return new APIConnectionRecord(record);
|
return new APIConnectionRecord(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ public class UserHistoryResource extends ActivityRecordSetResource<ActivityRecor
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected APIActivityRecord toExternalRecord(ActivityRecord record) {
|
public APIActivityRecord toExternalRecord(ActivityRecord record) {
|
||||||
return new APIActivityRecord(record);
|
return new APIActivityRecord(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -26,6 +26,7 @@ import java.util.Map;
|
|||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||||
import org.apache.guacamole.net.auth.ActivityRecord;
|
import org.apache.guacamole.net.auth.ActivityRecord;
|
||||||
|
import org.apache.guacamole.net.auth.ActivityRecordSet;
|
||||||
import org.apache.guacamole.net.auth.Permissions;
|
import org.apache.guacamole.net.auth.Permissions;
|
||||||
import org.apache.guacamole.net.auth.RelatedObjectSet;
|
import org.apache.guacamole.net.auth.RelatedObjectSet;
|
||||||
import org.apache.guacamole.net.auth.User;
|
import org.apache.guacamole.net.auth.User;
|
||||||
@@ -143,5 +144,11 @@ public class APIUserWrapper implements User {
|
|||||||
public List<? extends ActivityRecord> getHistory() throws GuacamoleException {
|
public List<? extends ActivityRecord> getHistory() throws GuacamoleException {
|
||||||
return Collections.<ActivityRecord>emptyList();
|
return Collections.<ActivityRecord>emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||||
|
throws GuacamoleException {
|
||||||
|
throw new GuacamoleUnsupportedException("APIUserWrapper does not provide login history.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,6 @@ import javax.ws.rs.core.Context;
|
|||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.GuacamoleSecurityException;
|
import org.apache.guacamole.GuacamoleSecurityException;
|
||||||
import org.apache.guacamole.net.auth.ActivityRecord;
|
|
||||||
import org.apache.guacamole.net.auth.AuthenticationProvider;
|
import org.apache.guacamole.net.auth.AuthenticationProvider;
|
||||||
import org.apache.guacamole.net.auth.Credentials;
|
import org.apache.guacamole.net.auth.Credentials;
|
||||||
import org.apache.guacamole.net.auth.User;
|
import org.apache.guacamole.net.auth.User;
|
||||||
@@ -42,7 +41,7 @@ import org.apache.guacamole.net.auth.UserContext;
|
|||||||
import org.apache.guacamole.net.auth.credentials.GuacamoleCredentialsException;
|
import org.apache.guacamole.net.auth.credentials.GuacamoleCredentialsException;
|
||||||
import org.apache.guacamole.rest.directory.DirectoryObjectResource;
|
import org.apache.guacamole.rest.directory.DirectoryObjectResource;
|
||||||
import org.apache.guacamole.rest.directory.DirectoryObjectTranslator;
|
import org.apache.guacamole.rest.directory.DirectoryObjectTranslator;
|
||||||
import org.apache.guacamole.rest.history.APIActivityRecord;
|
import org.apache.guacamole.rest.history.UserHistoryResource;
|
||||||
import org.apache.guacamole.rest.identifier.RelatedObjectSetResource;
|
import org.apache.guacamole.rest.identifier.RelatedObjectSetResource;
|
||||||
import org.apache.guacamole.rest.permission.APIPermissionSet;
|
import org.apache.guacamole.rest.permission.APIPermissionSet;
|
||||||
import org.apache.guacamole.rest.permission.PermissionSetResource;
|
import org.apache.guacamole.rest.permission.PermissionSetResource;
|
||||||
@@ -110,18 +109,11 @@ public class UserResource
|
|||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If an error occurs while retrieving the user history.
|
* If an error occurs while retrieving the user history.
|
||||||
*/
|
*/
|
||||||
@GET
|
|
||||||
@Path("history")
|
@Path("history")
|
||||||
public List<APIActivityRecord> getUserHistory()
|
public UserHistoryResource getUserHistory()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
// Retrieve the requested user's history
|
return new UserHistoryResource(user.getUserHistory());
|
||||||
List<APIActivityRecord> apiRecords = new ArrayList<APIActivityRecord>();
|
|
||||||
for (ActivityRecord record : user.getHistory())
|
|
||||||
apiRecords.add(new APIActivityRecord(record));
|
|
||||||
|
|
||||||
// Return the converted history
|
|
||||||
return apiRecords;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user