From 9dffabfd23c775728afcd3a2f14dcf3f64bf798e Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 26 Feb 2015 22:29:34 -0800 Subject: [PATCH] GUAC-1101: Extract common base classes from user and connection. Add ID to connection. --- .../net/auth/mysql/DirectoryObject.java | 68 +++-------- .../net/auth/mysql/MySQLConnection.java | 68 ++--------- .../guacamole/net/auth/mysql/MySQLUser.java | 53 +-------- .../net/auth/mysql/RestrictedObject.java | 109 ++++++++++++++++++ .../net/auth/mysql/model/ConnectionModel.java | 36 +++--- .../net/auth/mysql/model/ObjectModel.java | 90 +++++++++++++++ .../net/auth/mysql/model/UserModel.java | 53 +-------- .../AbstractGuacamoleSocketService.java | 4 +- .../auth/mysql/service/ConnectionService.java | 5 +- .../mysql/service/DirectoryObjectService.java | 3 +- .../service/SystemPermissionService.java | 4 +- .../net/auth/mysql/service/UserService.java | 2 +- .../net/auth/mysql/dao/ConnectionMapper.xml | 12 +- .../auth/mysql/dao/SystemPermissionMapper.xml | 4 +- .../net/auth/mysql/dao/UserMapper.xml | 14 +-- 15 files changed, 265 insertions(+), 260 deletions(-) create mode 100644 extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/RestrictedObject.java create mode 100644 extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/model/ObjectModel.java diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/DirectoryObject.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/DirectoryObject.java index 836d29f44..168f1761f 100644 --- a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/DirectoryObject.java +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/DirectoryObject.java @@ -22,69 +22,29 @@ package net.sourceforge.guacamole.net.auth.mysql; +import net.sourceforge.guacamole.net.auth.mysql.model.ObjectModel; import org.glyptodon.guacamole.net.auth.Identifiable; /** - * Common interface for objects that will ultimately be made available through + * Common base class for objects that will ultimately be made available through * the Directory class. All such objects will need the same base set of queries * to fulfill the needs of the Directory class. * * @author Michael Jumper * @param - * The type of object contained within the directory whose objects are - * mapped by this mapper. + * The type of model object that corresponds to this object. */ -public interface DirectoryObject extends Identifiable { +public abstract class DirectoryObject + extends RestrictedObject implements Identifiable { - /** - * Initializes this object, associating it with the current authenticated - * user and populating it with data from the given model object - * - * @param currentUser - * The user that created or retrieved this object. - * - * @param model - * The backing model object. - */ - public void init(AuthenticatedUser currentUser, ModelType model); + @Override + public String getIdentifier() { + return getModel().getIdentifier(); + } - /** - * Returns the user that created or queried this object. This user's - * permissions dictate what operations can be performed on or through this - * object. - * - * @return - * The user that created or queried this object. - */ - public AuthenticatedUser getCurrentUser(); + @Override + public void setIdentifier(String identifier) { + getModel().setIdentifier(identifier); + } - /** - * Sets the user that created or queried this object. This user's - * permissions dictate what operations can be performed on or through this - * object. - * - * @param currentUser - * The user that created or queried this object. - */ - public void setCurrentUser(AuthenticatedUser currentUser); - - /** - * Returns the backing model object. Changes to the model object will - * affect this object, and changes to this object will affect the model - * object. - * - * @return - * The user model object backing this MySQLUser. - */ - public ModelType getModel(); - - /** - * Sets the backing model object. This will effectively replace all data - * contained within this object. - * - * @param model - * The backing model object. - */ - public void setModel(ModelType model); - -} \ No newline at end of file +} diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnection.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnection.java index 87f02959f..6c36a52e5 100644 --- a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnection.java +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnection.java @@ -39,19 +39,8 @@ import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; * A MySQL based implementation of the Connection object. * @author James Muehlner */ -public class MySQLConnection implements Connection, DirectoryObject { - - /** - * The user this connection belongs to. Access is based on his/her permission - * settings. - */ - private AuthenticatedUser currentUser; - - /** - * The internal model object containing the values which represent this - * connection in the database. - */ - private ConnectionModel connectionModel; +public class MySQLConnection extends DirectoryObject + implements Connection { /** * Service for managing connections. @@ -82,58 +71,21 @@ public class MySQLConnection implements Connection, DirectoryObject getHistory() throws GuacamoleException { - return connectionService.retrieveHistory(currentUser, this); + return connectionService.retrieveHistory(getCurrentUser(), this); } @Override public GuacamoleSocket connect(GuacamoleClientInformation info) throws GuacamoleException { - return connectionService.connect(currentUser, this, info); + return connectionService.connect(getCurrentUser(), this, info); } @Override diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLUser.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLUser.java index aaa3b817f..ed67c8284 100644 --- a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLUser.java +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLUser.java @@ -38,13 +38,7 @@ import org.glyptodon.guacamole.net.auth.simple.SimpleObjectPermissionSet; * A MySQL based implementation of the User object. * @author James Muehlner */ -public class MySQLUser implements User, DirectoryObject { - - /** - * The user this user belongs to. Access is based on his/her permission - * settings. - */ - private AuthenticatedUser currentUser; +public class MySQLUser extends DirectoryObject implements User { /** * Service for hashing passwords. @@ -64,12 +58,6 @@ public class MySQLUser implements User, DirectoryObject { @Inject private SystemPermissionService systemPermissionService; - /** - * The internal model object containing the values which represent this - * user in the database. - */ - private UserModel userModel; - /** * The plaintext password previously set by a call to setPassword(), if * any. The password of a user cannot be retrieved once saved into the @@ -85,43 +73,6 @@ public class MySQLUser implements User, DirectoryObject { public MySQLUser() { } - @Override - public void init(AuthenticatedUser currentUser, UserModel userModel) { - this.currentUser = currentUser; - setModel(userModel); - } - - @Override - public AuthenticatedUser getCurrentUser() { - return currentUser; - } - - @Override - public void setCurrentUser(AuthenticatedUser currentUser) { - this.currentUser = currentUser; - } - - @Override - public UserModel getModel() { - return userModel; - } - - @Override - public void setModel(UserModel userModel) { - this.userModel = userModel; - this.password = null; - } - - @Override - public String getIdentifier() { - return userModel.getUsername(); - } - - @Override - public void setIdentifier(String username) { - userModel.setUsername(username); - } - @Override public String getPassword() { return password; @@ -130,6 +81,8 @@ public class MySQLUser implements User, DirectoryObject { @Override public void setPassword(String password) { + UserModel userModel = getModel(); + // Store plaintext password internally this.password = password; diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/RestrictedObject.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/RestrictedObject.java new file mode 100644 index 000000000..16481d488 --- /dev/null +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/RestrictedObject.java @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2015 Glyptodon LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package net.sourceforge.guacamole.net.auth.mysql; + +/** + * Common base class for objects that are associated with the users that + * query them, and have an underlying model. + * + * @author Michael Jumper + * @param + * The type of model object which corresponds to this object. + */ +public abstract class RestrictedObject { + + /** + * The user this object belongs to. Access is based on his/her permission + * settings. + */ + private AuthenticatedUser currentUser; + + /** + * The internal model object containing the values which represent this + * object in the database. + */ + private ModelType model; + + /** + * Initializes this object, associating it with the current authenticated + * user and populating it with data from the given model object + * + * @param currentUser + * The user that created or retrieved this object. + * + * @param model + * The backing model object. + */ + public void init(AuthenticatedUser currentUser, ModelType model) { + setCurrentUser(currentUser); + setModel(model); + } + + /** + * Returns the user that created or queried this object. This user's + * permissions dictate what operations can be performed on or through this + * object. + * + * @return + * The user that created or queried this object. + */ + public AuthenticatedUser getCurrentUser() { + return currentUser; + } + + /** + * Sets the user that created or queried this object. This user's + * permissions dictate what operations can be performed on or through this + * object. + * + * @param currentUser + * The user that created or queried this object. + */ + public void setCurrentUser(AuthenticatedUser currentUser) { + this.currentUser = currentUser; + } + + /** + * Returns the backing model object. Changes to the model object will + * affect this object, and changes to this object will affect the model + * object. + * + * @return + * The backing model object. + */ + public ModelType getModel() { + return model; + } + + /** + * Sets the backing model object. This will effectively replace all data + * contained within this object. + * + * @param model + * The backing model object. + */ + public void setModel(ModelType model) { + this.model = model; + } + +} \ No newline at end of file diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/model/ConnectionModel.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/model/ConnectionModel.java index e65258a24..de2dac14a 100644 --- a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/model/ConnectionModel.java +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/model/ConnectionModel.java @@ -28,12 +28,7 @@ package net.sourceforge.guacamole.net.auth.mysql.model; * * @author Michael Jumper */ -public class ConnectionModel { - - /** - * The identifier of this connection in the database, if any. - */ - private String identifier; +public class ConnectionModel extends ObjectModel { /** * The identifier of the parent connection group in the database, or null @@ -117,29 +112,26 @@ public class ConnectionModel { * The identifier of the parent connection group, or null if the parent * connection group is the root connection group. */ - public void setParentID(String parentIdentifier) { + public void setParentIdentifier(String parentIdentifier) { this.parentIdentifier = parentIdentifier; } - /** - * Returns the identifier of this connection in the database, if it exists. - * - * @return - * The identifier of this connection in the database, or null if this - * connection was not retrieved from the database. - */ + @Override public String getIdentifier() { - return identifier; + + // If no associated ID, then no associated identifier + Integer id = getObjectID(); + if (id == null) + return null; + + // Otherwise, the identifier is the ID as a string + return id.toString(); + } - /** - * Sets the identifier of this connection to the given value. - * - * @param identifier - * The identifier to assign to this connection. - */ + @Override public void setIdentifier(String identifier) { - this.identifier = identifier; + throw new UnsupportedOperationException("Connection identifiers are derived from IDs. They cannot be set."); } } diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/model/ObjectModel.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/model/ObjectModel.java new file mode 100644 index 000000000..4c3077d1c --- /dev/null +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/model/ObjectModel.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2015 Glyptodon LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package net.sourceforge.guacamole.net.auth.mysql.model; + +/** + * Object representation of a Guacamole object, such as a user or connection, + * as represented in the database. + * + * @author Michael Jumper + */ +public abstract class ObjectModel { + + /** + * The ID of this object in the database, if any. + */ + private Integer objectID; + + /** + * The unique identifier which identifies this object. + */ + private String identifier; + + /** + * Creates a new, empty object. + */ + public ObjectModel() { + } + + /** + * Returns the identifier that uniquely identifies this object. + * + * @return + * The identifier that uniquely identifies this object. + */ + public String getIdentifier() { + return identifier; + } + + /** + * Sets the identifier that uniquely identifies this object. + * + * @param identifier + * The identifier that uniquely identifies this object. + */ + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + /** + * Returns the ID of this object in the database, if it exists. + * + * @return + * The ID of this object in the database, or null if this object was + * not retrieved from the database. + */ + public Integer getObjectID() { + return objectID; + } + + /** + * Sets the ID of this object to the given value. + * + * @param objectID + * The ID to assign to this object. + */ + public void setObjectID(Integer objectID) { + this.objectID = objectID; + } + +} diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/model/UserModel.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/model/UserModel.java index 4130b6033..5893fd4c9 100644 --- a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/model/UserModel.java +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/model/UserModel.java @@ -27,18 +27,8 @@ package net.sourceforge.guacamole.net.auth.mysql.model; * * @author Michael Jumper */ -public class UserModel { +public class UserModel extends ObjectModel { - /** - * The ID of this user in the database, if any. - */ - private Integer userID; - - /** - * The unique username which identifies this user. - */ - private String username; - /** * The SHA-256 hash of the password and salt. */ @@ -56,47 +46,6 @@ public class UserModel { public UserModel() { } - /** - * Returns the username that uniquely identifies this user. - * - * @return - * The username that uniquely identifies this user. - */ - public String getUsername() { - return username; - } - - /** - * Sets the username that uniquely identifies this user. - * - * @param username - * The username that uniquely identifies this user. - */ - public void setUsername(String username) { - this.username = username; - } - - /** - * Returns the ID of this user in the database, if it exists. - * - * @return - * The ID of this user in the database, or null if this user was not - * retrieved from the database. - */ - public Integer getUserID() { - return userID; - } - - /** - * Sets the ID of this user to the given value. - * - * @param userID - * The ID to assign to this user. - */ - public void setUserID(Integer userID) { - this.userID = userID; - } - /** * Returns the hash of this user's password and password salt. This may be * null if the user was not retrieved from the database, and setPassword() diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/AbstractGuacamoleSocketService.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/AbstractGuacamoleSocketService.java index a1c163375..d1d86cc2e 100644 --- a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/AbstractGuacamoleSocketService.java +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/AbstractGuacamoleSocketService.java @@ -225,8 +225,8 @@ public abstract class AbstractGuacamoleSocketService implements GuacamoleSocketS ConnectionRecordModel recordModel = new ConnectionRecordModel(); // Copy user information and timestamps into new record - recordModel.setUserID(userModel.getUserID()); - recordModel.setUsername(userModel.getUsername()); + recordModel.setUserID(userModel.getObjectID()); + recordModel.setUsername(userModel.getIdentifier()); recordModel.setConnectionIdentifier(connection.getIdentifier()); recordModel.setStartDate(activeConnection.getStartDate()); recordModel.setEndDate(new Date()); diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/ConnectionService.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/ConnectionService.java index a161b20d6..91879ca08 100644 --- a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/ConnectionService.java +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/ConnectionService.java @@ -112,7 +112,6 @@ public class ConnectionService extends DirectoryObjectService, - ExternalType, ModelType> { + ExternalType, ModelType extends ObjectModel> { /** * Returns an instance of a mapper for the type of object used by this diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/SystemPermissionService.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/SystemPermissionService.java index 6c025c0d1..3c8978e01 100644 --- a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/SystemPermissionService.java +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/SystemPermissionService.java @@ -73,8 +73,8 @@ public class SystemPermissionService SystemPermissionModel model = new SystemPermissionModel(); // Populate model object with data from user and permission - model.setUserID(targetUser.getModel().getUserID()); - model.setUsername(targetUser.getModel().getUsername()); + model.setUserID(targetUser.getModel().getObjectID()); + model.setUsername(targetUser.getModel().getIdentifier()); model.setType(permission.getType()); return model; diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/UserService.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/UserService.java index 008db8480..d2e67dc18 100644 --- a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/UserService.java +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/service/UserService.java @@ -138,7 +138,7 @@ public class UserService extends DirectoryObjectService - + @@ -45,7 +45,7 @@ SELECT connection_id FROM guacamole_connection_permission WHERE - user_id = #{user.userID,jdbcType=INTEGER} + user_id = #{user.objectID,jdbcType=INTEGER} AND permission = 'READ' @@ -66,7 +66,7 @@ WHERE parent_id = #{parentIdentifier,jdbcType=VARCHAR} parent_id IS NULL - AND user_id = #{user.userID,jdbcType=INTEGER} + AND user_id = #{user.objectID,jdbcType=INTEGER} AND permission = 'READ' @@ -102,7 +102,7 @@ open="(" separator="," close=")"> #{identifier,jdbcType=VARCHAR} - AND user_id = #{user.userID,jdbcType=INTEGER} + AND user_id = #{user.objectID,jdbcType=INTEGER} AND permission = 'READ' @@ -127,7 +127,7 @@ #{object.protocol,jdbcType=VARCHAR} ) - + SELECT LAST_INSERT_ID() @@ -139,7 +139,7 @@ SET connection_name = #{object.name,jdbcType=VARCHAR}, parent_id = #{object.parentIdentifier,jdbcType=VARCHAR}, protocol = #{object.protocol,jdbcType=VARCHAR} - WHERE connection_id = #{object.identifier,jdbcType=VARCHAR} + WHERE connection_id = #{object.objectID,jdbcType=INTEGER} \ No newline at end of file diff --git a/extensions/guacamole-auth-mysql/src/main/resources/net/sourceforge/guacamole/net/auth/mysql/dao/SystemPermissionMapper.xml b/extensions/guacamole-auth-mysql/src/main/resources/net/sourceforge/guacamole/net/auth/mysql/dao/SystemPermissionMapper.xml index 8b8e0f8eb..65a02a100 100644 --- a/extensions/guacamole-auth-mysql/src/main/resources/net/sourceforge/guacamole/net/auth/mysql/dao/SystemPermissionMapper.xml +++ b/extensions/guacamole-auth-mysql/src/main/resources/net/sourceforge/guacamole/net/auth/mysql/dao/SystemPermissionMapper.xml @@ -43,7 +43,7 @@ permission FROM guacamole_system_permission JOIN guacamole_user ON guacamole_system_permission.user_id = guacamole_user.user_id - WHERE guacamole_system_permission.user_id = #{user.userID,jdbcType=INTEGER} + WHERE guacamole_system_permission.user_id = #{user.objectID,jdbcType=INTEGER} @@ -57,7 +57,7 @@ FROM guacamole_system_permission JOIN guacamole_user ON guacamole_system_permission.user_id = guacamole_user.user_id WHERE - guacamole_system_permission.user_id = #{user.userID,jdbcType=INTEGER} + guacamole_system_permission.user_id = #{user.objectID,jdbcType=INTEGER} AND permission = #{type,jdbcType=VARCHAR} diff --git a/extensions/guacamole-auth-mysql/src/main/resources/net/sourceforge/guacamole/net/auth/mysql/dao/UserMapper.xml b/extensions/guacamole-auth-mysql/src/main/resources/net/sourceforge/guacamole/net/auth/mysql/dao/UserMapper.xml index fe149f1ac..118b098eb 100644 --- a/extensions/guacamole-auth-mysql/src/main/resources/net/sourceforge/guacamole/net/auth/mysql/dao/UserMapper.xml +++ b/extensions/guacamole-auth-mysql/src/main/resources/net/sourceforge/guacamole/net/auth/mysql/dao/UserMapper.xml @@ -28,8 +28,8 @@ - - + + @@ -46,7 +46,7 @@ FROM guacamole_user JOIN guacamole_user_permission ON affected_user_id = guacamole_user.user_id WHERE - guacamole_user_permission.user_id = #{user.userID,jdbcType=INTEGER} + guacamole_user_permission.user_id = #{user.objectID,jdbcType=INTEGER} AND permission = 'read' @@ -82,7 +82,7 @@ open="(" separator="," close=")"> #{identifier,jdbcType=VARCHAR} - AND guacamole_user_permission.user_id = #{user.userID,jdbcType=INTEGER} + AND guacamole_user_permission.user_id = #{user.objectID,jdbcType=INTEGER} AND permission = 'read' @@ -115,12 +115,12 @@ password_salt ) VALUES ( - #{object.username,jdbcType=VARCHAR}, + #{object.identifier,jdbcType=VARCHAR}, #{object.passwordHash,jdbcType=BINARY}, #{object.passwordSalt,jdbcType=BINARY} ) - + SELECT LAST_INSERT_ID() @@ -131,7 +131,7 @@ UPDATE guacamole_user SET password_hash = #{object.passwordHash,jdbcType=BINARY}, password_salt = #{object.passwordSalt,jdbcType=BINARY} - WHERE user_id = #{object.userID,jdbcType=VARCHAR} + WHERE user_id = #{object.objectID,jdbcType=VARCHAR} \ No newline at end of file