mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-30 16:43:22 +00:00 
			
		
		
		
	GUACAMOLE-394: Merge refactor extension API to define user history
This commit is contained in:
		| @@ -27,15 +27,17 @@ import java.util.List; | ||||
| import java.util.Set; | ||||
| import org.apache.guacamole.GuacamoleException; | ||||
| import org.apache.guacamole.auth.jdbc.base.RestrictedObject; | ||||
| import org.apache.guacamole.net.auth.ActivityRecordSet; | ||||
| import org.apache.guacamole.net.auth.ActivityRecordSet.SortableProperty; | ||||
| import org.apache.guacamole.net.auth.ConnectionRecord; | ||||
|  | ||||
| /** | ||||
|  * A JDBC implementation of ConnectionRecordSet. Calls to asCollection() will  | ||||
|  * query connection history records from the database. Which records are | ||||
|  * returned will be determined by the values passed in earlier. | ||||
|  * A JDBC implementation of ActivityRecordSet for ConnectionRecords. Calls to | ||||
|  * asCollection() will query connection history records from the database. Which | ||||
|  * records are returned will be determined by the values passed in earlier. | ||||
|  */ | ||||
| public class ConnectionRecordSet extends RestrictedObject | ||||
|         implements org.apache.guacamole.net.auth.ConnectionRecordSet { | ||||
|         implements ActivityRecordSet<ConnectionRecord> { | ||||
|  | ||||
|     /** | ||||
|      * Service for managing connection objects. | ||||
|   | ||||
| @@ -19,7 +19,7 @@ | ||||
|  | ||||
| package org.apache.guacamole.auth.jdbc.connection; | ||||
|  | ||||
| import org.apache.guacamole.net.auth.ConnectionRecordSet; | ||||
| import org.apache.guacamole.net.auth.ActivityRecordSet; | ||||
|  | ||||
| /** | ||||
|  * A sort predicate which species the property to use when sorting connection | ||||
| @@ -30,7 +30,7 @@ public class ConnectionRecordSortPredicate { | ||||
|     /** | ||||
|      * The property to use when sorting ConnectionRecords. | ||||
|      */ | ||||
|     private final ConnectionRecordSet.SortableProperty property; | ||||
|     private final ActivityRecordSet.SortableProperty property; | ||||
|  | ||||
|     /** | ||||
|      * Whether the sort order is descending (true) or ascending (false). | ||||
| @@ -47,7 +47,7 @@ public class ConnectionRecordSortPredicate { | ||||
|      * @param descending  | ||||
|      *     Whether the sort order is descending (true) or ascending (false). | ||||
|      */ | ||||
|     public ConnectionRecordSortPredicate(ConnectionRecordSet.SortableProperty property,  | ||||
|     public ConnectionRecordSortPredicate(ActivityRecordSet.SortableProperty property, | ||||
|             boolean descending) { | ||||
|         this.property   = property; | ||||
|         this.descending = descending; | ||||
| @@ -59,7 +59,7 @@ public class ConnectionRecordSortPredicate { | ||||
|      * @return | ||||
|      *     The property that should be used when sorting ConnectionRecords. | ||||
|      */ | ||||
|     public ConnectionRecordSet.SortableProperty getProperty() { | ||||
|     public ActivityRecordSet.SortableProperty getProperty() { | ||||
|         return property; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -24,6 +24,7 @@ import com.google.inject.Provider; | ||||
| import java.util.Arrays; | ||||
| import java.util.Collection; | ||||
| import java.util.Collections; | ||||
| import java.util.Date; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| @@ -232,6 +233,11 @@ public class ModeledConnection extends ModeledChildDirectoryObject<ConnectionMod | ||||
|         return getModel().getSharingProfileIdentifiers(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Date getLastActive() { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<? extends ConnectionRecord> getHistory() throws GuacamoleException { | ||||
|         return connectionService.retrieveHistory(getCurrentUser(), this); | ||||
|   | ||||
| @@ -21,6 +21,7 @@ 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; | ||||
| @@ -146,6 +147,11 @@ public class SharedConnection implements Connection { | ||||
|         // Do nothing - changing attributes not supported | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Date getLastActive() { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<? extends ConnectionRecord> getHistory() | ||||
|             throws GuacamoleException { | ||||
|   | ||||
| @@ -20,9 +20,12 @@ | ||||
| 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.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.Connection; | ||||
| import org.apache.guacamole.net.auth.ConnectionGroup; | ||||
| @@ -88,6 +91,22 @@ public class SharedUser implements User { | ||||
|         // Do nothing - no attributes supported | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Date getLastActive() { | ||||
|  | ||||
|         // History is not recorded for shared users | ||||
|         return null; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<ActivityRecord> getHistory() throws GuacamoleException { | ||||
|  | ||||
|         // History is not recorded for shared users | ||||
|         return Collections.<ActivityRecord>emptyList(); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getPassword() { | ||||
|         return null; | ||||
|   | ||||
| @@ -28,16 +28,18 @@ import org.apache.guacamole.auth.jdbc.sharing.connectiongroup.SharedRootConnecti | ||||
| import org.apache.guacamole.auth.jdbc.user.RemoteAuthenticatedUser; | ||||
| import org.apache.guacamole.form.Form; | ||||
| import org.apache.guacamole.net.auth.ActiveConnection; | ||||
| import org.apache.guacamole.net.auth.ActivityRecord; | ||||
| import org.apache.guacamole.net.auth.ActivityRecordSet; | ||||
| import org.apache.guacamole.net.auth.AuthenticationProvider; | ||||
| import org.apache.guacamole.net.auth.Connection; | ||||
| import org.apache.guacamole.net.auth.ConnectionGroup; | ||||
| import org.apache.guacamole.net.auth.ConnectionRecordSet; | ||||
| import org.apache.guacamole.net.auth.ConnectionRecord; | ||||
| import org.apache.guacamole.net.auth.Directory; | ||||
| import org.apache.guacamole.net.auth.SharingProfile; | ||||
| import org.apache.guacamole.net.auth.User; | ||||
| import org.apache.guacamole.net.auth.UserContext; | ||||
| import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet; | ||||
| import org.apache.guacamole.net.auth.simple.SimpleConnectionGroupDirectory; | ||||
| import org.apache.guacamole.net.auth.simple.SimpleConnectionRecordSet; | ||||
| import org.apache.guacamole.net.auth.simple.SimpleDirectory; | ||||
|  | ||||
| /** | ||||
| @@ -175,8 +177,14 @@ public class SharedUserContext implements UserContext { | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ConnectionRecordSet getConnectionHistory() { | ||||
|         return new SimpleConnectionRecordSet(); | ||||
|     public ActivityRecordSet<ConnectionRecord> getConnectionHistory() { | ||||
|         return new SimpleActivityRecordSet<ConnectionRecord>(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ActivityRecordSet<ActivityRecord> getUserHistory() | ||||
|             throws GuacamoleException { | ||||
|         return new SimpleActivityRecordSet<ActivityRecord>(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -29,6 +29,7 @@ import java.util.Calendar; | ||||
| import java.util.Collection; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.TimeZone; | ||||
| 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.TimeField; | ||||
| 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.permission.ObjectPermissionSet; | ||||
| import org.apache.guacamole.net.auth.permission.SystemPermission; | ||||
| @@ -792,4 +794,14 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us | ||||
|         return getModel().isExpired(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Date getLastActive() { | ||||
|         return null; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<ActivityRecord> getHistory() throws GuacamoleException { | ||||
|         return Collections.<ActivityRecord>emptyList(); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -36,12 +36,15 @@ import org.apache.guacamole.auth.jdbc.sharingprofile.ModeledSharingProfile; | ||||
| import org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileDirectory; | ||||
| import org.apache.guacamole.form.Form; | ||||
| import org.apache.guacamole.net.auth.ActiveConnection; | ||||
| import org.apache.guacamole.net.auth.ActivityRecord; | ||||
| import org.apache.guacamole.net.auth.ActivityRecordSet; | ||||
| import org.apache.guacamole.net.auth.AuthenticationProvider; | ||||
| import org.apache.guacamole.net.auth.Connection; | ||||
| import org.apache.guacamole.net.auth.ConnectionGroup; | ||||
| import org.apache.guacamole.net.auth.Directory; | ||||
| import org.apache.guacamole.net.auth.SharingProfile; | ||||
| import org.apache.guacamole.net.auth.User; | ||||
| import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet; | ||||
|  | ||||
| /** | ||||
|  * UserContext implementation which is driven by an arbitrary, underlying | ||||
| @@ -161,6 +164,12 @@ public class ModeledUserContext extends RestrictedObject | ||||
|         return connectionRecordSet; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ActivityRecordSet<ActivityRecord> getUserHistory() | ||||
|             throws GuacamoleException { | ||||
|         return new SimpleActivityRecordSet<ActivityRecord>(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public ConnectionGroup getRootConnectionGroup() throws GuacamoleException { | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user