Ticket #263: Fixed some exceptions.

This commit is contained in:
James Muehlner
2013-08-13 18:48:17 -07:00
parent e66b06056a
commit 2467c5469f
3 changed files with 14 additions and 5 deletions

View File

@@ -173,7 +173,7 @@ public class ConnectionDirectory implements Directory<String, Connection>{
// Verify that no connection already exists with this name.
MySQLConnection previousConnection =
connectionService.retrieveConnection(name, user_id, parentID);
connectionService.retrieveConnection(name, parentID, user_id);
if(previousConnection != null)
throw new GuacamoleClientException("That connection name is already in use.");
@@ -329,7 +329,7 @@ public class ConnectionDirectory implements Directory<String, Connection>{
// Verify that no connection already exists with this name.
MySQLConnection previousConnection =
connectionService.retrieveConnection(mySQLConnection.getName(), user_id, parentID);
connectionService.retrieveConnection(mySQLConnection.getName(), parentID, user_id);
if(previousConnection != null)
throw new GuacamoleClientException("That connection name is already in use.");

View File

@@ -156,7 +156,7 @@ public class ConnectionGroupDirectory implements Directory<String, ConnectionGro
// Verify that no connection already exists with this name.
MySQLConnectionGroup previousConnectionGroup =
connectionGroupService.retrieveConnectionGroup(name, user_id, parentID);
connectionGroupService.retrieveConnectionGroup(name, parentID, user_id);
if(previousConnectionGroup != null)
throw new GuacamoleClientException("That connection group name is already in use.");
@@ -273,7 +273,7 @@ public class ConnectionGroupDirectory implements Directory<String, ConnectionGro
// Verify that no connection already exists with this name.
MySQLConnectionGroup previousConnectionGroup =
connectionGroupService.retrieveConnectionGroup(mySQLConnectionGroup.getName(), user_id, parentID);
connectionGroupService.retrieveConnectionGroup(mySQLConnectionGroup.getName(), parentID, user_id);
if(previousConnectionGroup != null)
throw new GuacamoleClientException("That connection group name is already in use.");

View File

@@ -37,6 +37,7 @@ package net.sourceforge.guacamole.net.auth.mysql.service;
import com.google.inject.Inject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -161,7 +162,7 @@ public class PermissionCheckService {
* @throws GuacamoleSecurityException If the specified permission is not
* granted.
*/
public void verifyConnectionGroupAccess(int userID, int affectedConnectionGroupID, String permissionType) throws GuacamoleSecurityException {
public void verifyConnectionGroupAccess(int userID, Integer affectedConnectionGroupID, String permissionType) throws GuacamoleSecurityException {
// If permission does not exist, throw exception
if(!checkConnectionGroupAccess(userID, affectedConnectionGroupID, permissionType))
@@ -440,6 +441,10 @@ public class PermissionCheckService {
if(checkParentID) {
// Get the IDs of all connections in the connection group
List<Integer> allConnectionIDs = connectionService.getAllConnectionIDs(parentID);
if(allConnectionIDs.isEmpty())
return Collections.EMPTY_LIST;
criteria.andConnection_idIn(allConnectionIDs);
}
@@ -522,6 +527,10 @@ public class PermissionCheckService {
// Get the IDs of all connection groups in the connection group
List<Integer> allConnectionGroupIDs = connectionGroupService
.getAllConnectionGroupIDs(parentID);
if(allConnectionGroupIDs.isEmpty())
return Collections.EMPTY_LIST;
criteria.andConnection_group_idIn(allConnectionGroupIDs);
}