GUACAMOLE-462: Add API-level support for associating data with history records.

This commit is contained in:
Michael Jumper
2021-12-01 22:52:22 -08:00
parent dc98633897
commit 9cbf4f045f
4 changed files with 82 additions and 9 deletions

View File

@@ -401,14 +401,7 @@ public class ActiveConnectionRecord implements ConnectionRecord {
} }
/** @Override
* Returns the UUID of the underlying tunnel. If there is no underlying
* tunnel, this will be the UUID assigned to the underlying tunnel when the
* tunnel is set.
*
* @return
* The current or future UUID of the underlying tunnel.
*/
public UUID getUUID() { public UUID getUUID() {
return uuid; return uuid;
} }

View File

@@ -19,13 +19,16 @@
package org.apache.guacamole.net.auth; package org.apache.guacamole.net.auth;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.Map;
import java.util.UUID;
/** /**
* A logging record describing when a user started and ended a particular * A logging record describing when a user started and ended a particular
* activity. * activity.
*/ */
public interface ActivityRecord { public interface ActivityRecord extends ReadableAttributes {
/** /**
* Returns the date and time the activity began. * Returns the date and time the activity began.
@@ -75,4 +78,23 @@ public interface ActivityRecord {
*/ */
public boolean isActive(); public boolean isActive();
/**
* Returns a UUID that uniquely identifies this record. If provided, this
* UUID MUST be deterministic and unique across all {@link ActivityRecord}
* objects within the same {@link ActivityRecordSet}, and SHOULD be unique
* across all {@link ActivityRecord} objects.
*
* @return
* A UUID that uniquely identifies this record, or null if no such
* unique identifier exists.
*/
public default UUID getUUID() {
return null;
}
@Override
public default Map<String, String> getAttributes() {
return Collections.emptyMap();
}
} }

View File

@@ -19,6 +19,8 @@
package org.apache.guacamole.net.auth; package org.apache.guacamole.net.auth;
import java.util.UUID;
/** /**
* A logging record describing when a user started and ended usage of a * A logging record describing when a user started and ended usage of a
* particular connection. * particular connection.
@@ -70,4 +72,15 @@ public interface ConnectionRecord extends ActivityRecord {
*/ */
public String getSharingProfileName(); public String getSharingProfileName();
/**
* {@inheritDoc}
* <p>If implemented, this UUID SHOULD be identical to the UUID of the
* {@link GuacamoleTunnel} originally returned when the connection was
* established to allow extensions and/or the web application to
* automatically associate connection information with corresponding
* history records, such as log messages and session recordings.
*/
@Override
public UUID getUUID();
} }

View File

@@ -20,6 +20,8 @@
package org.apache.guacamole.rest.history; package org.apache.guacamole.rest.history;
import java.util.Date; import java.util.Date;
import java.util.Map;
import java.util.UUID;
import org.apache.guacamole.net.auth.ActivityRecord; import org.apache.guacamole.net.auth.ActivityRecord;
/** /**
@@ -55,6 +57,24 @@ public class APIActivityRecord {
*/ */
private final boolean active; private final boolean active;
/**
* The unique identifier assigned to this record, or null if this record
* has no such identifier.
*/
private final String identifier;
/**
* A UUID that uniquely identifies this record, or null if no such unique
* identifier exists.
*/
private final UUID uuid;
/**
* A map of all attribute identifiers to their corresponding values, for
* all attributes associated with this record.
*/
private final Map<String, String> attributes;
/** /**
* Creates a new APIActivityRecord, copying the data from the given activity * Creates a new APIActivityRecord, copying the data from the given activity
* record. * record.
@@ -68,6 +88,8 @@ public class APIActivityRecord {
this.remoteHost = record.getRemoteHost(); this.remoteHost = record.getRemoteHost();
this.username = record.getUsername(); this.username = record.getUsername();
this.active = record.isActive(); this.active = record.isActive();
this.uuid = record.getUUID();
this.attributes = record.getAttributes();
} }
/** /**
@@ -128,4 +150,27 @@ public class APIActivityRecord {
return active; return active;
} }
/**
* Returns a UUID that uniquely identifies this record. If not implemented
* by the extension exposing this history record, this may be null.
*
* @return
* A UUID that uniquely identifies this record, or null if no such
* unique identifier exists.
*/
public UUID getUUID() {
return uuid;
}
/**
* Returns all attributes associated with this record.
*
* @return
* A map of all attribute identifiers to their corresponding values,
* for all attributes associated with this record.
*/
public Map<String, String> getAttributes() {
return attributes;
}
} }