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:
@@ -259,12 +259,6 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
|
|||||||
public Date getLastActive() {
|
public Date getLastActive() {
|
||||||
return getModel().getLastActive();
|
return getModel().getLastActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@Override
|
|
||||||
public List<? extends ConnectionRecord> getHistory() throws GuacamoleException {
|
|
||||||
return connectionService.retrieveHistory(getCurrentUser(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||||
|
@@ -22,18 +22,14 @@ package org.apache.guacamole.auth.jdbc.sharing.connection;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
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.protocol.GuacamoleClientInformation;
|
import org.apache.guacamole.protocol.GuacamoleClientInformation;
|
||||||
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
||||||
|
|
||||||
@@ -154,19 +150,6 @@ public class SharedConnection implements Connection {
|
|||||||
return null;
|
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
|
@Override
|
||||||
public Set<String> getSharingProfileIdentifiers()
|
public Set<String> getSharingProfileIdentifiers()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
@@ -21,13 +21,9 @@ package org.apache.guacamole.auth.jdbc.sharing.user;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
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.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;
|
||||||
@@ -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
|
@Override
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return null;
|
return null;
|
||||||
|
@@ -754,12 +754,6 @@ public class ModeledUser extends ModeledPermissions<UserModel> implements User {
|
|||||||
return getModel().getLastActive();
|
return getModel().getLastActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@Override
|
|
||||||
public List<ActivityRecord> getHistory() throws GuacamoleException {
|
|
||||||
return userService.retrieveHistory(getCurrentUser(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
@@ -21,12 +21,10 @@ package org.apache.guacamole.net.auth;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
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.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
|
||||||
@@ -86,25 +84,7 @@ public abstract class AbstractUser extends AbstractIdentifiable
|
|||||||
public Date getLastActive() {
|
public Date getLastActive() {
|
||||||
return null;
|
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}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
@@ -20,10 +20,12 @@
|
|||||||
package org.apache.guacamole.net.auth;
|
package org.apache.guacamole.net.auth;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
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.protocol.GuacamoleConfiguration;
|
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
|
* of this Connection, including any active users. ConnectionRecords
|
||||||
* in this list will be sorted in descending order of end time (active
|
* in this list will be sorted in descending order of end time (active
|
||||||
* connections are first), and then in descending order of start time
|
* 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
|
* @deprecated
|
||||||
* This function has been deprecated in favor of
|
* 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,
|
* new implementations should avoid use of this method and, instead,
|
||||||
* implement the getConnectionHistory() method.
|
* implement the getConnectionHistory() method.
|
||||||
*
|
*
|
||||||
* @return A list of ConnectionRecrods representing the usage history
|
* @return
|
||||||
* of this Connection.
|
* A list of ConnectionRecrods representing the usage history of this
|
||||||
|
* Connection.
|
||||||
*
|
*
|
||||||
* @throws GuacamoleException If an error occurs while reading the history
|
* @throws GuacamoleException
|
||||||
* of this connection, or if permission is
|
* If history tracking is not implemented, if an error occurs while
|
||||||
* denied.
|
* reading the history of this connection, or if permission is
|
||||||
|
* denied.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@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
|
* Returns an ActivityRecordSet containing ConnectionRecords that
|
||||||
* represent the usage history of this Connection, including any active
|
* represent the usage history of this Connection, including any active
|
||||||
* users. ConnectionRecords in this list will be sorted in descending order
|
* users. ConnectionRecords in this list will be sorted in descending order
|
||||||
* of end time (active connections are first), and then 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
|
* @return
|
||||||
* An ActivityRecordSet containing ConnectionRecords representing the
|
* An ActivityRecordSet containing ConnectionRecords representing the
|
||||||
* usage history of this Connection.
|
* usage history of this Connection.
|
||||||
*
|
*
|
||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If an error occurs retrieving history for this Connection, or if
|
* If history tracking is not implemented, if an error occurs while
|
||||||
* permission to retrieve the history is denied.
|
* reading the history of this connection, or if permission is
|
||||||
|
* denied.
|
||||||
*/
|
*/
|
||||||
ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
default ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||||
throws GuacamoleException;
|
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
|
* Returns identifiers of all readable sharing profiles that can be used to
|
||||||
|
@@ -20,9 +20,11 @@
|
|||||||
package org.apache.guacamole.net.auth;
|
package org.apache.guacamole.net.auth;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
|
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A user of the Guacamole web application.
|
* 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
|
* of this user, including any active sessions. ActivityRecords
|
||||||
* in this list will be sorted in descending order of end time (active
|
* in this list will be sorted in descending order of end time (active
|
||||||
* sessions are first), and then in descending order of start time
|
* 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
|
* @deprecated
|
||||||
* This function is deprecated in favor of {@link getUserHistory}, which
|
* This function is deprecated in favor of {@link getUserHistory}, which
|
||||||
@@ -108,29 +111,35 @@ public interface User extends Identifiable, Attributes, Permissions {
|
|||||||
* User.
|
* User.
|
||||||
*
|
*
|
||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If an error occurs while reading the history of this user, or if
|
* If history tracking is not implemented, if an error occurs while
|
||||||
* permission is denied.
|
* reading the history of this user, or if permission is denied.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@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
|
* Returns an ActivityRecordSet containing ActivityRecords representing
|
||||||
* the login history for this user, including any active sessions.
|
* the login history for this user, including any active sessions.
|
||||||
* ActivityRecords in this list will be sorted in descending order of end
|
* 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 (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
|
* @return
|
||||||
* An ActivityRecordSet containing ActivityRecords representing the
|
* An ActivityRecordSet containing ActivityRecords representing the
|
||||||
* login history for this user.
|
* login history for this user.
|
||||||
*
|
*
|
||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If an error occurs retrieving this user's login history, or if
|
* If history tracking is not implemented, if an error occurs while
|
||||||
* permission to retrieve login history is denied.
|
* reading the history of this user, or if permission is denied.
|
||||||
*/
|
*/
|
||||||
ActivityRecordSet<ActivityRecord> getUserHistory()
|
default ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||||
throws GuacamoleException;
|
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.
|
* 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>
|
public class SimpleActivityRecordSet<RecordType extends ActivityRecord>
|
||||||
implements ActivityRecordSet<RecordType> {
|
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
|
@Override
|
||||||
public Collection<RecordType> asCollection()
|
public Collection<RecordType> asCollection()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
return Collections.<RecordType>emptyList();
|
return records;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -21,7 +21,6 @@ package org.apache.guacamole.net.auth.simple;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
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.GuacamoleServerException;
|
import org.apache.guacamole.GuacamoleServerException;
|
||||||
@@ -284,12 +283,6 @@ public class SimpleConnection extends AbstractConnection {
|
|||||||
public Date getLastActive() {
|
public Date getLastActive() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@Override
|
|
||||||
public List<ConnectionRecord> getHistory() throws GuacamoleException {
|
|
||||||
return Collections.<ConnectionRecord>emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||||
|
@@ -19,17 +19,13 @@
|
|||||||
|
|
||||||
package org.apache.guacamole.rest.connection;
|
package org.apache.guacamole.rest.connection;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
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.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.protocol.GuacamoleClientInformation;
|
import org.apache.guacamole.protocol.GuacamoleClientInformation;
|
||||||
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
||||||
|
|
||||||
@@ -139,19 +135,5 @@ public class APIConnectionWrapper implements Connection {
|
|||||||
public Date getLastActive() {
|
public Date getLastActive() {
|
||||||
return null;
|
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 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.GuacamoleUnsupportedException;
|
||||||
import org.apache.guacamole.net.auth.Connection;
|
import org.apache.guacamole.net.auth.Connection;
|
||||||
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;
|
||||||
@@ -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.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.net.auth.simple.SimpleActivityRecordSet;
|
||||||
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;
|
||||||
@@ -47,6 +49,8 @@ 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.history.ConnectionHistoryResource;
|
||||||
import org.apache.guacamole.rest.sharingprofile.APISharingProfile;
|
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
|
* 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)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public class ConnectionResource extends DirectoryObjectResource<Connection, APIConnection> {
|
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
|
* The UserContext associated with the Directory which contains the
|
||||||
* Connection exposed by this resource.
|
* Connection exposed by this resource.
|
||||||
@@ -147,11 +156,29 @@ 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.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Path("history")
|
@Path("history")
|
||||||
public ConnectionHistoryResource getConnectionHistory()
|
public ConnectionHistoryResource getConnectionHistory()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
return new ConnectionHistoryResource(connection.getConnectionHistory());
|
// 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.Produces;
|
||||||
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.GuacamoleUnsupportedException;
|
||||||
import org.apache.guacamole.net.auth.UserContext;
|
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
|
* A REST resource for retrieving and managing the history records of Guacamole
|
||||||
@@ -64,7 +66,12 @@ public class HistoryResource {
|
|||||||
*/
|
*/
|
||||||
@Path("connections")
|
@Path("connections")
|
||||||
public ConnectionHistoryResource getConnectionHistory() throws GuacamoleException {
|
public ConnectionHistoryResource getConnectionHistory() throws GuacamoleException {
|
||||||
return new ConnectionHistoryResource(userContext.getConnectionHistory());
|
try {
|
||||||
|
return new ConnectionHistoryResource(userContext.getConnectionHistory());
|
||||||
|
}
|
||||||
|
catch (GuacamoleUnsupportedException e) {
|
||||||
|
return new ConnectionHistoryResource(new SimpleActivityRecordSet<>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,7 +88,12 @@ public class HistoryResource {
|
|||||||
*/
|
*/
|
||||||
@Path("users")
|
@Path("users")
|
||||||
public UserHistoryResource getUserHistory() throws GuacamoleException {
|
public UserHistoryResource getUserHistory() throws GuacamoleException {
|
||||||
return new UserHistoryResource(userContext.getUserHistory());
|
try {
|
||||||
|
return new UserHistoryResource(userContext.getUserHistory());
|
||||||
|
}
|
||||||
|
catch (GuacamoleUnsupportedException e) {
|
||||||
|
return new UserHistoryResource(new SimpleActivityRecordSet<>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -19,14 +19,10 @@
|
|||||||
|
|
||||||
package org.apache.guacamole.rest.user;
|
package org.apache.guacamole.rest.user;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
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.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.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;
|
||||||
@@ -140,16 +136,4 @@ public class APIUserWrapper implements User {
|
|||||||
return null;
|
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.Assisted;
|
||||||
import com.google.inject.assistedinject.AssistedInject;
|
import com.google.inject.assistedinject.AssistedInject;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
@@ -33,18 +31,22 @@ 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.GuacamoleUnsupportedException;
|
||||||
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;
|
||||||
import org.apache.guacamole.net.auth.Directory;
|
import org.apache.guacamole.net.auth.Directory;
|
||||||
import org.apache.guacamole.net.auth.UserContext;
|
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.net.auth.simple.SimpleActivityRecordSet;
|
||||||
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.UserHistoryResource;
|
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;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A REST resource which abstracts the operations available on an existing
|
* 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
|
public class UserResource
|
||||||
extends DirectoryObjectResource<User, APIUser> {
|
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
|
* The UserContext associated with the Directory which contains the User
|
||||||
* exposed by this resource.
|
* exposed by this resource.
|
||||||
@@ -109,11 +116,29 @@ 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.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Path("history")
|
@Path("history")
|
||||||
public UserHistoryResource getUserHistory()
|
public UserHistoryResource getUserHistory()
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
return new UserHistoryResource(user.getUserHistory());
|
// 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