mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 09:03:21 +00:00 
			
		
		
		
	Ticket #269: Trim identifiers on add().
This commit is contained in:
		| @@ -130,7 +130,8 @@ public class ConnectionDirectory implements Directory<String, Connection>{ | ||||
|     @Override | ||||
|     public void add(Connection object) throws GuacamoleException { | ||||
|  | ||||
|         if(object.getIdentifier().isEmpty()) | ||||
|         String identifier = object.getIdentifier().trim(); | ||||
|         if(identifier.isEmpty()) | ||||
|             throw new GuacamoleClientException("The connection identifier cannot be blank."); | ||||
|          | ||||
|         // Verify permission to create | ||||
| @@ -139,13 +140,13 @@ public class ConnectionDirectory implements Directory<String, Connection>{ | ||||
|  | ||||
|         // Verify that no connection already exists with this identifier. | ||||
|         MySQLConnection previousConnection =  | ||||
|                 connectionService.retrieveConnection(object.getIdentifier(), user_id); | ||||
|                 connectionService.retrieveConnection(identifier, user_id); | ||||
|         if(previousConnection != null) | ||||
|             throw new GuacamoleClientException("That connection identifier is already in use."); | ||||
|          | ||||
|         // Create connection | ||||
|         MySQLConnection connection = connectionService.createConnection( | ||||
|                 object.getIdentifier(), object.getConfiguration().getProtocol(), | ||||
|                 identifier, object.getConfiguration().getProtocol(), | ||||
|                 user_id); | ||||
|  | ||||
|         // Add connection parameters | ||||
|   | ||||
| @@ -154,7 +154,8 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol | ||||
|     public void add(net.sourceforge.guacamole.net.auth.User object) | ||||
|             throws GuacamoleException { | ||||
|  | ||||
|         if(object.getUsername().isEmpty()) | ||||
|         String username = object.getUsername().trim(); | ||||
|         if(username.isEmpty()) | ||||
|             throw new GuacamoleClientException("The username cannot be blank."); | ||||
|  | ||||
|         // Verify current user has permission to create users | ||||
| @@ -163,14 +164,12 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol | ||||
|         Preconditions.checkNotNull(object); | ||||
|  | ||||
|         // Verify that no user already exists with this username. | ||||
|         MySQLUser previousUser =  | ||||
|                 userService.retrieveUser(object.getUsername()); | ||||
|         MySQLUser previousUser = userService.retrieveUser(username); | ||||
|         if(previousUser != null) | ||||
|             throw new GuacamoleClientException("That username is already in use."); | ||||
|  | ||||
|         // Create new user | ||||
|         MySQLUser user = userService.createUser(object.getUsername(), | ||||
|                 object.getPassword()); | ||||
|         MySQLUser user = userService.createUser(username, object.getPassword()); | ||||
|  | ||||
|         // Create permissions of new user in database | ||||
|         createPermissions(user.getUserID(), object.getPermissions()); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user