GUACAMOLE-394: Add getLastActive() function, returning the time that a user/connection was last logged-in / used.

This commit is contained in:
Michael Jumper
2017-09-11 18:49:11 -07:00
parent b61f14e4db
commit 3cd7f453c0
10 changed files with 75 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ import com.google.inject.Provider;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -232,6 +233,11 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod
return getModel().getSharingProfileIdentifiers(); return getModel().getSharingProfileIdentifiers();
} }
@Override
public Date getLastActive() {
return null;
}
@Override @Override
public List<? extends ConnectionRecord> getHistory() throws GuacamoleException { public List<? extends ConnectionRecord> getHistory() throws GuacamoleException {
return connectionService.retrieveHistory(getCurrentUser(), this); return connectionService.retrieveHistory(getCurrentUser(), this);

View File

@@ -21,6 +21,7 @@ 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.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -146,6 +147,11 @@ public class SharedConnection implements Connection {
// Do nothing - changing attributes not supported // Do nothing - changing attributes not supported
} }
@Override
public Date getLastActive() {
return null;
}
@Override @Override
public List<? extends ConnectionRecord> getHistory() public List<? extends ConnectionRecord> getHistory()
throws GuacamoleException { throws GuacamoleException {

View File

@@ -20,6 +20,7 @@
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.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;
@@ -90,6 +91,14 @@ public class SharedUser implements User {
// Do nothing - no attributes supported // Do nothing - no attributes supported
} }
@Override
public Date getLastActive() {
// History is not recorded for shared users
return null;
}
@Override @Override
public List<ActivityRecord> getHistory() throws GuacamoleException { public List<ActivityRecord> getHistory() throws GuacamoleException {

View File

@@ -794,6 +794,11 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
return getModel().isExpired(); return getModel().isExpired();
} }
@Override
public Date getLastActive() {
return null;
}
@Override @Override
public List<ActivityRecord> getHistory() throws GuacamoleException { public List<ActivityRecord> getHistory() throws GuacamoleException {
return Collections.<ActivityRecord>emptyList(); 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.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -102,6 +103,18 @@ public interface Connection extends Identifiable, Connectable {
*/ */
void setAttributes(Map<String, String> attributes); void setAttributes(Map<String, String> attributes);
/**
* Returns the date and time that this connection was last used. If the
* connection was never used, the time that the connection was last used is
* unknown, or this information is not visible to the current user, this
* may be null.
*
* @return
* The date and time this connection was last used, or null if this
* information is unavailable or inapplicable.
*/
Date getLastActive();
/** /**
* Returns a list of ConnectionRecords representing the usage history * Returns a list of ConnectionRecords representing the usage history
* of this Connection, including any active users. ConnectionRecords * of this Connection, including any active users. ConnectionRecords

View File

@@ -19,6 +19,7 @@
package org.apache.guacamole.net.auth; package org.apache.guacamole.net.auth;
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;
@@ -101,6 +102,17 @@ public interface User extends Identifiable {
*/ */
void setAttributes(Map<String, String> attributes); void setAttributes(Map<String, String> attributes);
/**
* Returns the date and time that this user was last active. If the user
* was never active, the time that the user was last active is unknown, or
* this information is not visible to the current user, this may be null.
*
* @return
* The date and time this user was last active, or null if this
* information is unavailable or inapplicable.
*/
Date getLastActive();
/** /**
* Returns a list of ActivityRecords representing the login history * Returns a list of ActivityRecords representing the login history
* of this user, including any active sessions. ActivityRecords * of this user, including any active sessions. ActivityRecords

View File

@@ -20,6 +20,7 @@
package org.apache.guacamole.net.auth.simple; package org.apache.guacamole.net.auth.simple;
import java.util.Collections; import java.util.Collections;
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;
@@ -136,6 +137,11 @@ public class SimpleConnection extends AbstractConnection {
} }
@Override
public Date getLastActive() {
return null;
}
@Override @Override
public List<ConnectionRecord> getHistory() throws GuacamoleException { public List<ConnectionRecord> getHistory() throws GuacamoleException {
return Collections.<ConnectionRecord>emptyList(); return Collections.<ConnectionRecord>emptyList();

View File

@@ -21,6 +21,7 @@ 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.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -165,6 +166,11 @@ public class SimpleUser extends AbstractUser {
// Do nothing - there are no attributes // Do nothing - there are no attributes
} }
@Override
public Date getLastActive() {
return null;
}
@Override @Override
public List<ActivityRecord> getHistory() throws GuacamoleException { public List<ActivityRecord> getHistory() throws GuacamoleException {
return Collections.<ActivityRecord>emptyList(); return Collections.<ActivityRecord>emptyList();

View File

@@ -20,6 +20,7 @@
package org.apache.guacamole.rest.connection; package org.apache.guacamole.rest.connection;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -131,6 +132,11 @@ public class APIConnectionWrapper implements Connection {
throw new UnsupportedOperationException("Operation not supported."); throw new UnsupportedOperationException("Operation not supported.");
} }
@Override
public Date getLastActive() {
return null;
}
@Override @Override
public List<? extends ConnectionRecord> getHistory() throws GuacamoleException { public List<? extends ConnectionRecord> getHistory() throws GuacamoleException {
return Collections.<ConnectionRecord>emptyList(); return Collections.<ConnectionRecord>emptyList();

View File

@@ -20,6 +20,7 @@
package org.apache.guacamole.rest.user; package org.apache.guacamole.rest.user;
import java.util.Collections; import java.util.Collections;
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;
@@ -115,6 +116,11 @@ 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 Date getLastActive() {
return null;
}
@Override @Override
public List<? extends ActivityRecord> getHistory() throws GuacamoleException { public List<? extends ActivityRecord> getHistory() throws GuacamoleException {
return Collections.<ActivityRecord>emptyList(); return Collections.<ActivityRecord>emptyList();