mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-1123: Provide default interface implementations for history methods.
This commit is contained in:
@@ -260,12 +260,6 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
|
||||
return getModel().getLastActive();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<? extends ConnectionRecord> getHistory() throws GuacamoleException {
|
||||
return connectionService.retrieveHistory(getCurrentUser(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||
throws GuacamoleException {
|
||||
|
@@ -22,18 +22,14 @@ package org.apache.guacamole.auth.jdbc.sharing.connection;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
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.tunnel.GuacamoleTunnelService;
|
||||
import org.apache.guacamole.auth.jdbc.user.RemoteAuthenticatedUser;
|
||||
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.ConnectionRecord;
|
||||
import org.apache.guacamole.protocol.GuacamoleClientInformation;
|
||||
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
||||
|
||||
@@ -154,19 +150,6 @@ public class SharedConnection implements Connection {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<? extends ConnectionRecord> getHistory()
|
||||
throws GuacamoleException {
|
||||
throw new GuacamoleUnsupportedException("SharedConnection objects do not provide history.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||
throws GuacamoleException {
|
||||
throw new GuacamoleUnsupportedException("SharedConnection objects do not provide history.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSharingProfileIdentifiers()
|
||||
throws GuacamoleException {
|
||||
|
@@ -21,13 +21,9 @@ package org.apache.guacamole.auth.jdbc.sharing.user;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||
import org.apache.guacamole.auth.jdbc.sharing.permission.SharedObjectPermissionSet;
|
||||
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.Connection;
|
||||
import org.apache.guacamole.net.auth.ConnectionGroup;
|
||||
@@ -101,18 +97,6 @@ public class SharedUser implements User {
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<ActivityRecord> getHistory() throws GuacamoleException {
|
||||
throw new GuacamoleUnsupportedException("SharedUser objects do not provide login history.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||
throws GuacamoleException {
|
||||
throw new GuacamoleUnsupportedException("SharedUser objects do not provide login history.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return null;
|
||||
|
@@ -754,12 +754,6 @@ public class ModeledUser extends ModeledPermissions<UserModel> implements User {
|
||||
return getModel().getLastActive();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<ActivityRecord> getHistory() throws GuacamoleException {
|
||||
return userService.retrieveHistory(getCurrentUser(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||
throws GuacamoleException {
|
||||
|
@@ -21,12 +21,10 @@ package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||
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
|
||||
@@ -87,24 +85,6 @@ public abstract class AbstractUser extends AbstractIdentifiable
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty list. Implementations
|
||||
* that wish to expose user login history should override this function.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<ActivityRecord> getHistory() throws GuacamoleException {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||
throws GuacamoleException {
|
||||
return new SimpleActivityRecordSet<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
@@ -20,10 +20,12 @@
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
||||
|
||||
/**
|
||||
@@ -99,7 +101,8 @@ public interface Connection extends Identifiable, Connectable, Attributes {
|
||||
* 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).
|
||||
* (newer connections are first). If connection history tracking is
|
||||
* not implemented this method should throw GuacamoleUnsupportedException.
|
||||
*
|
||||
* @deprecated
|
||||
* This function has been deprecated in favor of
|
||||
@@ -109,33 +112,44 @@ public interface Connection extends Identifiable, Connectable, Attributes {
|
||||
* new implementations should avoid use of this method and, instead,
|
||||
* implement the getConnectionHistory() method.
|
||||
*
|
||||
* @return A list of ConnectionRecrods representing the usage history
|
||||
* of this Connection.
|
||||
* @return
|
||||
* A list of ConnectionRecrods representing the usage history of this
|
||||
* Connection.
|
||||
*
|
||||
* @throws GuacamoleException If an error occurs while reading the history
|
||||
* of this connection, or if permission is
|
||||
* @throws GuacamoleException
|
||||
* If history tracking is not implemented, if an error occurs while
|
||||
* reading the history of this connection, or if permission is
|
||||
* denied.
|
||||
*/
|
||||
@Deprecated
|
||||
List<? extends ConnectionRecord> getHistory() throws GuacamoleException;
|
||||
default List<? extends ConnectionRecord> getHistory()
|
||||
throws GuacamoleException {
|
||||
return Collections.unmodifiableList(new ArrayList<>(getConnectionHistory().asCollection()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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).
|
||||
* of start time (newer connections are first). If connection history
|
||||
* tracking has not been implemented, or has been implemented using the
|
||||
* deprecated {@link getHistory} method, this function should throw
|
||||
* GuacamoleUnsupportedExpcetion.
|
||||
*
|
||||
* @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.
|
||||
* If history tracking is not implemented, if an error occurs while
|
||||
* reading the history of this connection, or if permission is
|
||||
* denied.
|
||||
*/
|
||||
ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||
throws GuacamoleException;
|
||||
default ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||
throws GuacamoleException {
|
||||
throw new GuacamoleUnsupportedException("This implementation of Connection does not provide connection history.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns identifiers of all readable sharing profiles that can be used to
|
||||
|
@@ -20,9 +20,11 @@
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||
|
||||
/**
|
||||
* A user of the Guacamole web application.
|
||||
@@ -94,7 +96,8 @@ public interface User extends Identifiable, Attributes, Permissions {
|
||||
* of 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).
|
||||
* (newer sessions are first). If user login history is not implemented
|
||||
* this method should throw GuacamoleUnsupportedException.
|
||||
*
|
||||
* @deprecated
|
||||
* This function is deprecated in favor of {@link getUserHistory}, which
|
||||
@@ -108,29 +111,35 @@ public interface User extends Identifiable, Attributes, Permissions {
|
||||
* User.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while reading the history of this user, or if
|
||||
* permission is denied.
|
||||
* If history tracking is not implemented, if an error occurs while
|
||||
* reading the history of this user, or if permission is denied.
|
||||
*/
|
||||
@Deprecated
|
||||
List<? extends ActivityRecord> getHistory() throws GuacamoleException;
|
||||
default List<? extends ActivityRecord> getHistory() throws GuacamoleException {
|
||||
return Collections.unmodifiableList(new ArrayList<>(getUserHistory().asCollection()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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).
|
||||
* time (newer sessions are first). If login history tracking is not
|
||||
* implemented, or is only implemented using the deprecated {@link getHistory}
|
||||
* method, this method should throw GuacamoleUnsupportedException.
|
||||
*
|
||||
* @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.
|
||||
* If history tracking is not implemented, if an error occurs while
|
||||
* reading the history of this user, or if permission is denied.
|
||||
*/
|
||||
ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||
throws GuacamoleException;
|
||||
default ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||
throws GuacamoleException {
|
||||
throw new GuacamoleUnsupportedException("The default implementation of User does not provide login history.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of all readable user groups of which this user is a member.
|
||||
|
@@ -35,10 +35,34 @@ import org.apache.guacamole.net.auth.ActivityRecordSet.SortableProperty;
|
||||
public class SimpleActivityRecordSet<RecordType extends ActivityRecord>
|
||||
implements ActivityRecordSet<RecordType> {
|
||||
|
||||
/**
|
||||
* The records associated with this record set, if any.
|
||||
*/
|
||||
private final Collection<RecordType> records;
|
||||
|
||||
/**
|
||||
* Create a new SimpleActivityRecordSet that contains an empty set of
|
||||
* records.
|
||||
*/
|
||||
public SimpleActivityRecordSet() {
|
||||
records = Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SimpleActivityRecordSet that contains the provided records
|
||||
* which will back this record set.
|
||||
*
|
||||
* @param records
|
||||
* The records that this SimpleActivityRecordSet should contain.
|
||||
*/
|
||||
public SimpleActivityRecordSet(Collection<? extends RecordType> records) {
|
||||
this.records = Collections.unmodifiableCollection(records);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RecordType> asCollection()
|
||||
throws GuacamoleException {
|
||||
return Collections.<RecordType>emptyList();
|
||||
return records;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -21,7 +21,6 @@ package org.apache.guacamole.net.auth.simple;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleServerException;
|
||||
@@ -285,12 +284,6 @@ public class SimpleConnection extends AbstractConnection {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<ConnectionRecord> getHistory() throws GuacamoleException {
|
||||
return Collections.<ConnectionRecord>emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||
throws GuacamoleException {
|
||||
|
@@ -19,17 +19,13 @@
|
||||
|
||||
package org.apache.guacamole.rest.connection;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||
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.ConnectionRecord;
|
||||
import org.apache.guacamole.protocol.GuacamoleClientInformation;
|
||||
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
||||
|
||||
@@ -140,18 +136,4 @@ public class APIConnectionWrapper implements Connection {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<? extends ConnectionRecord> getHistory() throws GuacamoleException {
|
||||
throw new GuacamoleUnsupportedException("APIConnectionWrapper does not "
|
||||
+ "support retrieving connection history.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||
throws GuacamoleException {
|
||||
throw new GuacamoleUnsupportedException("APIConnectionWrapper does not "
|
||||
+ "support retrieving connection history.");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleSecurityException;
|
||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||
import org.apache.guacamole.net.auth.Connection;
|
||||
import org.apache.guacamole.net.auth.Directory;
|
||||
import org.apache.guacamole.net.auth.Permissions;
|
||||
@@ -40,6 +41,7 @@ import org.apache.guacamole.net.auth.permission.ObjectPermission;
|
||||
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||
import org.apache.guacamole.net.auth.permission.SystemPermission;
|
||||
import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
|
||||
import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet;
|
||||
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
||||
import org.apache.guacamole.rest.directory.DirectoryObjectResource;
|
||||
import org.apache.guacamole.rest.directory.DirectoryObjectTranslator;
|
||||
@@ -47,6 +49,8 @@ import org.apache.guacamole.rest.directory.DirectoryResource;
|
||||
import org.apache.guacamole.rest.directory.DirectoryResourceFactory;
|
||||
import org.apache.guacamole.rest.history.ConnectionHistoryResource;
|
||||
import org.apache.guacamole.rest.sharingprofile.APISharingProfile;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* A REST resource which abstracts the operations available on an existing
|
||||
@@ -56,6 +60,11 @@ import org.apache.guacamole.rest.sharingprofile.APISharingProfile;
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class ConnectionResource extends DirectoryObjectResource<Connection, APIConnection> {
|
||||
|
||||
/**
|
||||
* Logger for this class.
|
||||
*/
|
||||
private static final Logger logger = LoggerFactory.getLogger(ConnectionResource.class);
|
||||
|
||||
/**
|
||||
* The UserContext associated with the Directory which contains the
|
||||
* Connection exposed by this resource.
|
||||
@@ -147,11 +156,29 @@ public class ConnectionResource extends DirectoryObjectResource<Connection, APIC
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving the connection history.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Path("history")
|
||||
public ConnectionHistoryResource getConnectionHistory()
|
||||
throws GuacamoleException {
|
||||
|
||||
// Try the current getConnectionHistory() method, first, for connection history.
|
||||
try {
|
||||
return new ConnectionHistoryResource(connection.getConnectionHistory());
|
||||
}
|
||||
catch (GuacamoleUnsupportedException e) {
|
||||
logger.debug("Call to getConnectionHistory() is unsupported, falling back to getHistory().", e);
|
||||
}
|
||||
|
||||
// Fall back to the deprecated getHistory() method.
|
||||
try {
|
||||
return new ConnectionHistoryResource(new SimpleActivityRecordSet<>(connection.getHistory()));
|
||||
}
|
||||
catch (GuacamoleUnsupportedException e) {
|
||||
logger.debug("Call to getHistory() is unsupported, no connection history records will be returned.", e);
|
||||
}
|
||||
|
||||
// If all fails, return an empty connection history set.
|
||||
return new ConnectionHistoryResource(new SimpleActivityRecordSet<>());
|
||||
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,9 @@ import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||
import org.apache.guacamole.net.auth.UserContext;
|
||||
import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet;
|
||||
|
||||
/**
|
||||
* A REST resource for retrieving and managing the history records of Guacamole
|
||||
@@ -64,8 +66,13 @@ public class HistoryResource {
|
||||
*/
|
||||
@Path("connections")
|
||||
public ConnectionHistoryResource getConnectionHistory() throws GuacamoleException {
|
||||
try {
|
||||
return new ConnectionHistoryResource(userContext.getConnectionHistory());
|
||||
}
|
||||
catch (GuacamoleUnsupportedException e) {
|
||||
return new ConnectionHistoryResource(new SimpleActivityRecordSet<>());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the login history for all users. Filtering may be applied via
|
||||
@@ -81,7 +88,12 @@ public class HistoryResource {
|
||||
*/
|
||||
@Path("users")
|
||||
public UserHistoryResource getUserHistory() throws GuacamoleException {
|
||||
try {
|
||||
return new UserHistoryResource(userContext.getUserHistory());
|
||||
}
|
||||
catch (GuacamoleUnsupportedException e) {
|
||||
return new UserHistoryResource(new SimpleActivityRecordSet<>());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -19,14 +19,10 @@
|
||||
|
||||
package org.apache.guacamole.rest.user;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||
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.RelatedObjectSet;
|
||||
import org.apache.guacamole.net.auth.User;
|
||||
@@ -140,16 +136,4 @@ public class APIUserWrapper implements User {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<? extends ActivityRecord> getHistory() throws GuacamoleException {
|
||||
throw new GuacamoleUnsupportedException("APIUserWrapper does not provide login history.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||
throws GuacamoleException {
|
||||
throw new GuacamoleUnsupportedException("APIUserWrapper does not provide login history.");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,8 +21,6 @@ package org.apache.guacamole.rest.user;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
@@ -33,18 +31,22 @@ import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleSecurityException;
|
||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||
import org.apache.guacamole.net.auth.AuthenticationProvider;
|
||||
import org.apache.guacamole.net.auth.Credentials;
|
||||
import org.apache.guacamole.net.auth.User;
|
||||
import org.apache.guacamole.net.auth.Directory;
|
||||
import org.apache.guacamole.net.auth.UserContext;
|
||||
import org.apache.guacamole.net.auth.credentials.GuacamoleCredentialsException;
|
||||
import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet;
|
||||
import org.apache.guacamole.rest.directory.DirectoryObjectResource;
|
||||
import org.apache.guacamole.rest.directory.DirectoryObjectTranslator;
|
||||
import org.apache.guacamole.rest.history.UserHistoryResource;
|
||||
import org.apache.guacamole.rest.identifier.RelatedObjectSetResource;
|
||||
import org.apache.guacamole.rest.permission.APIPermissionSet;
|
||||
import org.apache.guacamole.rest.permission.PermissionSetResource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* A REST resource which abstracts the operations available on an existing
|
||||
@@ -55,6 +57,11 @@ import org.apache.guacamole.rest.permission.PermissionSetResource;
|
||||
public class UserResource
|
||||
extends DirectoryObjectResource<User, APIUser> {
|
||||
|
||||
/**
|
||||
* Logger for this class.
|
||||
*/
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserResource.class);
|
||||
|
||||
/**
|
||||
* The UserContext associated with the Directory which contains the User
|
||||
* exposed by this resource.
|
||||
@@ -109,11 +116,29 @@ public class UserResource
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving the user history.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Path("history")
|
||||
public UserHistoryResource getUserHistory()
|
||||
throws GuacamoleException {
|
||||
|
||||
// First try to retrieve history using the current getUserHistory() method.
|
||||
try {
|
||||
return new UserHistoryResource(user.getUserHistory());
|
||||
}
|
||||
catch (GuacamoleUnsupportedException e) {
|
||||
logger.debug("Call to getUserHistory() is unsupported, falling back to deprecated method getHistory().", e);
|
||||
}
|
||||
|
||||
// Fall back to deprecated getHistory() method.
|
||||
try {
|
||||
return new UserHistoryResource(new SimpleActivityRecordSet<>(user.getHistory()));
|
||||
}
|
||||
catch (GuacamoleUnsupportedException e) {
|
||||
logger.debug("Call to getHistory() is unsupported, no user history records will be returned.", e);
|
||||
}
|
||||
|
||||
// If both are unimplemented, return an empty history set.
|
||||
return new UserHistoryResource(new SimpleActivityRecordSet<>());
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user