From f32bb558e36443cd4b09cfd4b99d0c38ad41bae2 Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Fri, 20 Dec 2013 15:11:09 -0800 Subject: [PATCH] Ticket #362: Using FORBIDDEN for GuacamoleSecurityException. --- .../basic/rest/connection/ConnectionRESTService.java | 12 ++++++------ .../connectiongroup/ConnectionGroupRESTService.java | 12 ++++++------ .../basic/rest/permission/PermissionRESTService.java | 6 +++--- .../net/basic/rest/user/UserRESTService.java | 10 +++++----- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/ConnectionRESTService.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/ConnectionRESTService.java index 6a0e70d96..62e924f4c 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/ConnectionRESTService.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/ConnectionRESTService.java @@ -105,7 +105,7 @@ public class ConnectionRESTService { // Return the converted connection directory return connectionService.convertConnectionList(connectionDirectory); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -142,7 +142,7 @@ public class ConnectionRESTService { return new APIConnection(connection); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -176,7 +176,7 @@ public class ConnectionRESTService { // Delete the connection connectionDirectory.remove(connectionID); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -229,7 +229,7 @@ public class ConnectionRESTService { // Return the new connection identifier return connection.getIdentifier(); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -268,7 +268,7 @@ public class ConnectionRESTService { // Update the connection connectionDirectory.update(new APIConnectionWrapper(connection)); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -308,7 +308,7 @@ public class ConnectionRESTService { // Move the connection connectionDirectory.move(connectionID, parentConnectionGroup.getConnectionDirectory()); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/ConnectionGroupRESTService.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/ConnectionGroupRESTService.java index 5dede8ac9..ab6f742c6 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/ConnectionGroupRESTService.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/ConnectionGroupRESTService.java @@ -104,7 +104,7 @@ public class ConnectionGroupRESTService { // return the converted connection group list return connectionGroupService.convertConnectionGroupList(connectionGroupDirectory); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -142,7 +142,7 @@ public class ConnectionGroupRESTService { // Return the connectiion group return new APIConnectionGroup(connectionGroup); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -176,7 +176,7 @@ public class ConnectionGroupRESTService { // Delete the connection group connectionGroupDirectory.remove(connectionGroupID); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -229,7 +229,7 @@ public class ConnectionGroupRESTService { // Return the new connection group identifier return connectionGroup.getIdentifier(); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -268,7 +268,7 @@ public class ConnectionGroupRESTService { // Update the connection group connectionGroupDirectory.update(new APIConnectionGroupWrapper(connectionGroup)); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -308,7 +308,7 @@ public class ConnectionGroupRESTService { // Move the connection group connectionGroupDirectory.move(connectionGroupID, parentConnectionGroup.getConnectionGroupDirectory()); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/permission/PermissionRESTService.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/permission/PermissionRESTService.java index 91d779dc4..4a96a847b 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/permission/PermissionRESTService.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/permission/PermissionRESTService.java @@ -89,7 +89,7 @@ public class PermissionRESTService { return permissionService.convertPermissionList(user.getPermissions()); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -122,7 +122,7 @@ public class PermissionRESTService { // Add the new permission user.addPermission(permission.toPermission()); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -155,7 +155,7 @@ public class PermissionRESTService { // Remove the permission user.removePermission(permission.toPermission()); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { 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 e9fa90b94..44ccc3904 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 @@ -86,7 +86,7 @@ public class UserRESTService { // Convert and return the user directory listing return userService.convertUserList(userDirectory); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Response.Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Response.Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Response.Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -119,7 +119,7 @@ public class UserRESTService { // Return the user return new APIUser(user); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Response.Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Response.Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Response.Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -147,7 +147,7 @@ public class UserRESTService { return user.getUsername(); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Response.Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Response.Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Response.Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -187,7 +187,7 @@ public class UserRESTService { */ userDirectory.update(new APIUserWrapper(user, existingUser.getPermissions())); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Response.Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Response.Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Response.Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) { @@ -220,7 +220,7 @@ public class UserRESTService { // Delete the user userDirectory.remove(userID); } catch(GuacamoleSecurityException e) { - throw new HTTPException(Response.Status.UNAUTHORIZED, e.getMessage() != null ? e.getMessage() : "Permission denied."); + throw new HTTPException(Response.Status.FORBIDDEN, e.getMessage() != null ? e.getMessage() : "Permission denied."); } catch(GuacamoleClientException e) { throw new HTTPException(Response.Status.BAD_REQUEST, e.getMessage() != null ? e.getMessage() : "Invalid Request."); } catch(GuacamoleException e) {