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