diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/user/UserResource.java b/guacamole/src/main/java/org/apache/guacamole/rest/user/UserResource.java index 3f142ff08..75a49dbbf 100644 --- a/guacamole/src/main/java/org/apache/guacamole/rest/user/UserResource.java +++ b/guacamole/src/main/java/org/apache/guacamole/rest/user/UserResource.java @@ -21,8 +21,11 @@ package org.apache.guacamole.rest.user; import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.AssistedInject; +import java.util.ArrayList; +import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.Consumes; +import javax.ws.rs.GET; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; @@ -30,6 +33,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleSecurityException; +import org.apache.guacamole.net.auth.ActivityRecord; import org.apache.guacamole.net.auth.AuthenticationProvider; import org.apache.guacamole.net.auth.Credentials; import org.apache.guacamole.net.auth.User; @@ -38,6 +42,7 @@ import org.apache.guacamole.net.auth.UserContext; import org.apache.guacamole.net.auth.credentials.GuacamoleCredentialsException; import org.apache.guacamole.rest.directory.DirectoryObjectResource; import org.apache.guacamole.rest.directory.DirectoryObjectTranslator; +import org.apache.guacamole.rest.history.APIActivityRecord; import org.apache.guacamole.rest.permission.PermissionSetResource; /** @@ -93,6 +98,31 @@ public class UserResource this.user = user; } + /** + * Retrieves the login (session) history of a single user. + * + * @return + * A list of activity records, describing the start and end times of + * this user's sessions. + * + * @throws GuacamoleException + * If an error occurs while retrieving the user history. + */ + @GET + @Path("history") + public List getUserHistory() + throws GuacamoleException { + + // Retrieve the requested user's history + List apiRecords = new ArrayList(); + for (ActivityRecord record : user.getHistory()) + apiRecords.add(new APIActivityRecord(record)); + + // Return the converted history + return apiRecords; + + } + @Override public void updateObject(APIUser modifiedObject) throws GuacamoleException {