GUACAMOLE-394: Add history list at User object level (similar to Connection).

This commit is contained in:
Michael Jumper
2017-09-11 18:33:49 -07:00
parent 700005e823
commit b61f14e4db
5 changed files with 50 additions and 0 deletions

View File

@@ -20,9 +20,11 @@
package org.apache.guacamole.auth.jdbc.sharing.user; package org.apache.guacamole.auth.jdbc.sharing.user;
import java.util.Collections; import java.util.Collections;
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.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.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;
@@ -88,6 +90,14 @@ public class SharedUser implements User {
// Do nothing - no attributes supported // Do nothing - no attributes supported
} }
@Override
public List<ActivityRecord> getHistory() throws GuacamoleException {
// History is not recorded for shared users
return Collections.<ActivityRecord>emptyList();
}
@Override @Override
public String getPassword() { public String getPassword() {
return null; return null;

View File

@@ -29,6 +29,7 @@ import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import org.apache.guacamole.auth.jdbc.base.ModeledDirectoryObject; import org.apache.guacamole.auth.jdbc.base.ModeledDirectoryObject;
@@ -49,6 +50,7 @@ import org.apache.guacamole.form.Form;
import org.apache.guacamole.form.TextField; 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.User; import org.apache.guacamole.net.auth.User;
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;
@@ -792,4 +794,9 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
return getModel().isExpired(); return getModel().isExpired();
} }
@Override
public List<ActivityRecord> getHistory() throws GuacamoleException {
return Collections.<ActivityRecord>emptyList();
}
} }

View File

@@ -19,6 +19,7 @@
package org.apache.guacamole.net.auth; package org.apache.guacamole.net.auth;
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;
@@ -100,6 +101,23 @@ public interface User extends Identifiable {
*/ */
void setAttributes(Map<String, String> attributes); void setAttributes(Map<String, String> attributes);
/**
* Returns a list of ActivityRecords representing the login history
* 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).
*
* @return
* A list of ActivityRecords representing the login history of this
* User.
*
* @throws GuacamoleException
* If an error occurs while reading the history of this user, or if
* permission is denied.
*/
List<? extends ActivityRecord> getHistory() throws GuacamoleException;
/** /**
* Returns all system-level permissions given to this user. * Returns all system-level permissions given to this user.
* *

View File

@@ -22,10 +22,12 @@ package org.apache.guacamole.net.auth.simple;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
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.net.auth.AbstractUser; import org.apache.guacamole.net.auth.AbstractUser;
import org.apache.guacamole.net.auth.ActivityRecord;
import org.apache.guacamole.net.auth.permission.ObjectPermission; 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.SystemPermissionSet; import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
@@ -163,6 +165,11 @@ public class SimpleUser extends AbstractUser {
// Do nothing - there are no attributes // Do nothing - there are no attributes
} }
@Override
public List<ActivityRecord> getHistory() throws GuacamoleException {
return Collections.<ActivityRecord>emptyList();
}
@Override @Override
public SystemPermissionSet getSystemPermissions() public SystemPermissionSet getSystemPermissions()
throws GuacamoleException { throws GuacamoleException {

View File

@@ -19,9 +19,12 @@
package org.apache.guacamole.rest.user; package org.apache.guacamole.rest.user;
import java.util.Collections;
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.User; import org.apache.guacamole.net.auth.User;
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;
@@ -112,4 +115,9 @@ public class APIUserWrapper implements User {
throw new GuacamoleUnsupportedException("APIUserWrapper does not provide permission access."); throw new GuacamoleUnsupportedException("APIUserWrapper does not provide permission access.");
} }
@Override
public List<? extends ActivityRecord> getHistory() throws GuacamoleException {
return Collections.<ActivityRecord>emptyList();
}
} }