From 4d62cb9c920a1dd83b884f2c280a7326b4bc500e Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 22 Feb 2013 19:58:32 -0800 Subject: [PATCH] Ticket #269: Remove GuacamolePermissionException, use GuacamoleSecurityException instead. --- .../mysql/GuacamolePermissionException.java | 78 ---------- .../net/auth/mysql/UserDirectory.java | 9 +- .../mysql/utility/PermissionCheckUtility.java | 138 +++++++++--------- 3 files changed, 74 insertions(+), 151 deletions(-) delete mode 100644 extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/GuacamolePermissionException.java diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/GuacamolePermissionException.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/GuacamolePermissionException.java deleted file mode 100644 index 98df8f749..000000000 --- a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/GuacamolePermissionException.java +++ /dev/null @@ -1,78 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is guacamole-auth-mysql. - * - * The Initial Developer of the Original Code is - * James Muehlner. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -package net.sourceforge.guacamole.net.auth.mysql; - -import net.sourceforge.guacamole.GuacamoleException; - -/** - * Represents an error condition when a user tries to perform an action - * that he/she does not have permission to do. - * @author James Muehlner - */ -public class GuacamolePermissionException extends GuacamoleException { - - /** - * Creates a new GuacamoleException with the given message and cause. - * - * @param message A human readable description of the exception that - * occurred. - * @param cause The cause of this exception. - */ - public GuacamolePermissionException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Creates a new GuacamoleException with the given message. - * - * @param message A human readable description of the exception that - * occurred. - */ - public GuacamolePermissionException(String message) { - super(message); - } - - /** - * Creates a new GuacamoleException with the given cause. - * - * @param cause The cause of this exception. - */ - public GuacamolePermissionException(Throwable cause) { - super(cause); - } - - -} diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/UserDirectory.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/UserDirectory.java index 004ff66b0..3014d33cc 100644 --- a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/UserDirectory.java +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/UserDirectory.java @@ -46,6 +46,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import net.sourceforge.guacamole.GuacamoleException; +import net.sourceforge.guacamole.GuacamoleSecurityException; import net.sourceforge.guacamole.net.auth.Directory; import net.sourceforge.guacamole.net.auth.mysql.dao.ConnectionMapper; import net.sourceforge.guacamole.net.auth.mysql.dao.ConnectionPermissionMapper; @@ -288,7 +289,7 @@ public class UserDirectory implements Directory mySQLConnectionProvider; /** - * Verifies that the user has read access to the given user. If not, throws a GuacamolePermissionException. + * Verifies that the user has read access to the given user. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedUserID - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyUserReadAccess(int userID, int affectedUserID) throws GuacamolePermissionException { + public void verifyUserReadAccess(int userID, int affectedUserID) throws GuacamoleSecurityException { if(!checkUserReadAccess(userID, affectedUserID)) - throw new GuacamolePermissionException("User " + userID + " does not have read access to user " + affectedUserID); + throw new GuacamoleSecurityException("User " + userID + " does not have read access to user " + affectedUserID); } /** - * Verifies that the user has update access to the given user. If not, throws a GuacamolePermissionException. + * Verifies that the user has update access to the given user. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedUserID - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyUserUpdateAccess(int userID, int affectedUserID) throws GuacamolePermissionException { + public void verifyUserUpdateAccess(int userID, int affectedUserID) throws GuacamoleSecurityException { if(!checkUserUpdateAccess(userID, affectedUserID)) - throw new GuacamolePermissionException("User " + userID + " does not have update access to user " + affectedUserID); + throw new GuacamoleSecurityException("User " + userID + " does not have update access to user " + affectedUserID); } /** - * Verifies that the user has delete access to the given user. If not, throws a GuacamolePermissionException. + * Verifies that the user has delete access to the given user. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedUserID - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyUserDeleteAccess(int userID, int affectedUserID) throws GuacamolePermissionException { + public void verifyUserDeleteAccess(int userID, int affectedUserID) throws GuacamoleSecurityException { if(!checkUserDeleteAccess(userID, affectedUserID)) - throw new GuacamolePermissionException("User " + userID + " does not have delete access to user " + affectedUserID); + throw new GuacamoleSecurityException("User " + userID + " does not have delete access to user " + affectedUserID); } /** - * Verifies that the user has administer access to the given user. If not, throws a GuacamolePermissionException. + * Verifies that the user has administer access to the given user. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedUserID - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyUserAdministerAccess(int userID, int affectedUserID) throws GuacamolePermissionException { + public void verifyUserAdministerAccess(int userID, int affectedUserID) throws GuacamoleSecurityException { if(!checkUserAdministerAccess(userID, affectedUserID)) - throw new GuacamolePermissionException("User " + userID + " does not have administer access to user " + affectedUserID); + throw new GuacamoleSecurityException("User " + userID + " does not have administer access to user " + affectedUserID); } /** - * Verifies that the user has read access to the given user. If not, throws a GuacamolePermissionException. + * Verifies that the user has read access to the given user. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedUsername - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyUserReadAccess(int userID, String affectedUsername) throws GuacamolePermissionException { + public void verifyUserReadAccess(int userID, String affectedUsername) throws GuacamoleSecurityException { if(!checkUserReadAccess(userID, affectedUsername)) - throw new GuacamolePermissionException("User " + userID + " does not have read access to user '" + affectedUsername + "'"); + throw new GuacamoleSecurityException("User " + userID + " does not have read access to user '" + affectedUsername + "'"); } /** - * Verifies that the user has update access to the given user. If not, throws a GuacamolePermissionException. + * Verifies that the user has update access to the given user. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedUsername - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyUserUpdateAccess(int userID, String affectedUsername) throws GuacamolePermissionException { + public void verifyUserUpdateAccess(int userID, String affectedUsername) throws GuacamoleSecurityException { if(!checkUserUpdateAccess(userID, affectedUsername)) - throw new GuacamolePermissionException("User " + userID + " does not have update access to user '" + affectedUsername + "'"); + throw new GuacamoleSecurityException("User " + userID + " does not have update access to user '" + affectedUsername + "'"); } /** - * Verifies that the user has delete access to the given user. If not, throws a GuacamolePermissionException. + * Verifies that the user has delete access to the given user. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedUsername - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyUserDeleteAccess(int userID, String affectedUsername) throws GuacamolePermissionException { + public void verifyUserDeleteAccess(int userID, String affectedUsername) throws GuacamoleSecurityException { if(!checkUserDeleteAccess(userID, affectedUsername)) - throw new GuacamolePermissionException("User " + userID + " does not have delete access to user '" + affectedUsername + "'"); + throw new GuacamoleSecurityException("User " + userID + " does not have delete access to user '" + affectedUsername + "'"); } /** - * Verifies that the user has administer access to the given user. If not, throws a GuacamolePermissionException. + * Verifies that the user has administer access to the given user. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedUsername - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyUserAdministerAccess(int userID, String affectedUsername) throws GuacamolePermissionException { + public void verifyUserAdministerAccess(int userID, String affectedUsername) throws GuacamoleSecurityException { if(!checkUserAdministerAccess(userID, affectedUsername)) - throw new GuacamolePermissionException("User " + userID + " does not have administer access to user '" + affectedUsername + "'"); + throw new GuacamoleSecurityException("User " + userID + " does not have administer access to user '" + affectedUsername + "'"); } /** @@ -408,91 +408,91 @@ public class PermissionCheckUtility { } /** - * Verifies that the user has read access to the given connection. If not, throws a GuacamolePermissionException. + * Verifies that the user has read access to the given connection. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedConnectionID - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyConnectionReadAccess(int userID, int affectedConnectionID) throws GuacamolePermissionException { + public void verifyConnectionReadAccess(int userID, int affectedConnectionID) throws GuacamoleSecurityException { if(!checkConnectionReadAccess(userID, affectedConnectionID)) - throw new GuacamolePermissionException("User " + userID + " does not have read access to connection " + affectedConnectionID); + throw new GuacamoleSecurityException("User " + userID + " does not have read access to connection " + affectedConnectionID); } /** - * Verifies that the user has update access to the given connection. If not, throws a GuacamolePermissionException. + * Verifies that the user has update access to the given connection. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedConnectionID - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyConnectionUpdateAccess(int userID, int affectedConnectionID) throws GuacamolePermissionException { + public void verifyConnectionUpdateAccess(int userID, int affectedConnectionID) throws GuacamoleSecurityException { if(!checkConnectionUpdateAccess(userID, affectedConnectionID)) - throw new GuacamolePermissionException("User " + userID + " does not have update access to connection " + affectedConnectionID); + throw new GuacamoleSecurityException("User " + userID + " does not have update access to connection " + affectedConnectionID); } /** - * Verifies that the user has delete access to the given connection. If not, throws a GuacamolePermissionException. + * Verifies that the user has delete access to the given connection. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedConnectionID - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyConnectionDeleteAccess(int userID, int affectedConnectionID) throws GuacamolePermissionException { + public void verifyConnectionDeleteAccess(int userID, int affectedConnectionID) throws GuacamoleSecurityException { if(!checkConnectionDeleteAccess(userID, affectedConnectionID)) - throw new GuacamolePermissionException("User " + userID + " does not have delete access to connection " + affectedConnectionID); + throw new GuacamoleSecurityException("User " + userID + " does not have delete access to connection " + affectedConnectionID); } /** - * Verifies that the user has administer access to the given connection. If not, throws a GuacamolePermissionException. + * Verifies that the user has administer access to the given connection. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedConnectionID - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyConnectionAdministerAccess(int userID, int affectedConnectionID) throws GuacamolePermissionException { + public void verifyConnectionAdministerAccess(int userID, int affectedConnectionID) throws GuacamoleSecurityException { if(!checkConnectionAdministerAccess(userID, affectedConnectionID)) - throw new GuacamolePermissionException("User " + userID + " does not have administer access to connection " + affectedConnectionID); + throw new GuacamoleSecurityException("User " + userID + " does not have administer access to connection " + affectedConnectionID); } /** - * Verifies that the user has read access to the given connection. If not, throws a GuacamolePermissionException. + * Verifies that the user has read access to the given connection. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedConnectionName - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyConnectionReadAccess(int userID, String affectedConnectionName) throws GuacamolePermissionException { + public void verifyConnectionReadAccess(int userID, String affectedConnectionName) throws GuacamoleSecurityException { if(!checkConnectionReadAccess(userID, affectedConnectionName)) - throw new GuacamolePermissionException("User " + userID + " does not have read access to connection '" + affectedConnectionName + "'"); + throw new GuacamoleSecurityException("User " + userID + " does not have read access to connection '" + affectedConnectionName + "'"); } /** - * Verifies that the user has update access to the given connection. If not, throws a GuacamolePermissionException. + * Verifies that the user has update access to the given connection. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedConnectionName - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyConnectionUpdateAccess(int userID, String affectedConnectionName) throws GuacamolePermissionException { + public void verifyConnectionUpdateAccess(int userID, String affectedConnectionName) throws GuacamoleSecurityException { if(!checkConnectionUpdateAccess(userID, affectedConnectionName)) - throw new GuacamolePermissionException("User " + userID + " does not have update access to connection '" + affectedConnectionName + "'"); + throw new GuacamoleSecurityException("User " + userID + " does not have update access to connection '" + affectedConnectionName + "'"); } /** - * Verifies that the user has delete access to the given connection. If not, throws a GuacamolePermissionException. + * Verifies that the user has delete access to the given connection. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedConnectionName - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyConnectionDeleteAccess(int userID, String affectedConnectionName) throws GuacamolePermissionException { + public void verifyConnectionDeleteAccess(int userID, String affectedConnectionName) throws GuacamoleSecurityException { if(!checkConnectionDeleteAccess(userID, affectedConnectionName)) - throw new GuacamolePermissionException("User " + userID + " does not have delete access to connection '" + affectedConnectionName + "'"); + throw new GuacamoleSecurityException("User " + userID + " does not have delete access to connection '" + affectedConnectionName + "'"); } /** - * Verifies that the user has administer access to the given connection. If not, throws a GuacamolePermissionException. + * Verifies that the user has administer access to the given connection. If not, throws a GuacamoleSecurityException. * @param userID * @param affectedConnectionName - * @throws GuacamolePermissionException + * @throws GuacamoleSecurityException */ - public void verifyConnectionAdministerAccess(int userID, String affectedConnectionName) throws GuacamolePermissionException { + public void verifyConnectionAdministerAccess(int userID, String affectedConnectionName) throws GuacamoleSecurityException { if(!checkConnectionAdministerAccess(userID, affectedConnectionName)) - throw new GuacamolePermissionException("User " + userID + " does not have administer access to connection '" + affectedConnectionName + "'"); + throw new GuacamoleSecurityException("User " + userID + " does not have administer access to connection '" + affectedConnectionName + "'"); } /** @@ -716,14 +716,14 @@ public class PermissionCheckUtility { return connectionIDs; } - public void verifyCreateUserPermission(int userID) throws GuacamolePermissionException { + public void verifyCreateUserPermission(int userID) throws GuacamoleSecurityException { if(!checkCreateUserPermission(userID)) - throw new GuacamolePermissionException("User " + userID + " does not have permission to create users."); + throw new GuacamoleSecurityException("User " + userID + " does not have permission to create users."); } - public void verifyCreateConnectionPermission(int userID) throws GuacamolePermissionException { + public void verifyCreateConnectionPermission(int userID) throws GuacamoleSecurityException { if(!checkCreateConnectionPermission(userID)) - throw new GuacamolePermissionException("User " + userID + " does not have permission to create connections."); + throw new GuacamoleSecurityException("User " + userID + " does not have permission to create connections."); } /**