From d2aec9457fafb4ed7f337870cf3eb747d281299a Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Mon, 9 Dec 2013 20:35:29 -0800 Subject: [PATCH] Ticket #362: Cleaned up a bit. --- .../basic/rest/auth/BasicTokenUserContextMap.java | 5 +++++ .../net/basic/rest/user/UserRESTService.java | 14 ++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/auth/BasicTokenUserContextMap.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/auth/BasicTokenUserContextMap.java index 0629efdde..5ebb58e46 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/auth/BasicTokenUserContextMap.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/auth/BasicTokenUserContextMap.java @@ -95,6 +95,11 @@ public class BasicTokenUserContextMap implements TokenUserContextMap { lastAccessTimeMap.put(authToken, new Date().getTime()); } + /** + * Check if a session has timed out. + * @param authToken The auth token for the session. + * @return True if the session has timed out, false otherwise. + */ private boolean sessionHasTimedOut(String authToken) { if(!lastAccessTimeMap.containsKey(authToken)) return true; diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/UserRESTService.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/UserRESTService.java index 44c5c603f..d5b9397f6 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/UserRESTService.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/UserRESTService.java @@ -70,7 +70,7 @@ public class UserRESTService { private UserService userService; /** - * Get a list of users in the system. + * Gets a list of users in the system. * @param authToken The authentication token that is used to authenticate * the user performing the operation. * @return The user list. @@ -96,7 +96,7 @@ public class UserRESTService { } /** - * Get a user. + * Gets an individual user. * @param authToken The authentication token that is used to authenticate * the user performing the operation. * @return user The user. @@ -129,13 +129,13 @@ public class UserRESTService { } /** - * Create a new user. + * Creates a new user and returns the username. * @param authToken The authentication token that is used to authenticate * the user performing the operation. * @param user The new user to create. */ @POST - public void createUser(@QueryParam("token") String authToken, APIUser user) { + public String createUser(@QueryParam("token") String authToken, APIUser user) { UserContext userContext = authenticationService.getUserContextFromAuthToken(authToken); try { @@ -144,6 +144,8 @@ public class UserRESTService { // Create the user userDirectory.add(new APIUserWrapper(user)); + + return user.getUsername(); } catch(GuacamoleSecurityException e) { throw new HTTPException(Response.Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { @@ -155,7 +157,7 @@ public class UserRESTService { } /** - * Update an existing user. + * Updates an individual existing user. * @param authToken The authentication token that is used to authenticate * the user performing the operation. * @param userID The unique identifier of the user to update. @@ -195,7 +197,7 @@ public class UserRESTService { } /** - * Delete an existing user. + * Deletes an individual existing user. * @param authToken The authentication token that is used to authenticate * the user performing the operation. * @param userID The unique identifier of the user to delete.