GUAC-1101: Remove mention of MySQL from generic JDBC code.

This commit is contained in:
Michael Jumper
2015-02-28 12:11:39 -08:00
parent fc25bb33aa
commit acb6ea44fa
24 changed files with 164 additions and 149 deletions

View File

@@ -22,15 +22,15 @@
package org.glyptodon.guacamole.auth.jdbc; package org.glyptodon.guacamole.auth.jdbc;
import org.glyptodon.guacamole.auth.jdbc.user.MySQLUserContext; import org.glyptodon.guacamole.auth.jdbc.user.UserContext;
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.MySQLRootConnectionGroup; import org.glyptodon.guacamole.auth.jdbc.connectiongroup.RootConnectionGroup;
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.MySQLConnectionGroup; import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ModeledConnectionGroup;
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ConnectionGroupDirectory; import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ConnectionGroupDirectory;
import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionDirectory; import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionDirectory;
import org.glyptodon.guacamole.auth.jdbc.connection.MySQLGuacamoleConfiguration; import org.glyptodon.guacamole.auth.jdbc.connection.ModeledGuacamoleConfiguration;
import org.glyptodon.guacamole.auth.jdbc.connection.MySQLConnection; import org.glyptodon.guacamole.auth.jdbc.connection.ModeledConnection;
import org.glyptodon.guacamole.auth.jdbc.permission.MySQLSystemPermissionSet; import org.glyptodon.guacamole.auth.jdbc.permission.SystemPermissionSet;
import org.glyptodon.guacamole.auth.jdbc.user.MySQLUser; import org.glyptodon.guacamole.auth.jdbc.user.ModeledUser;
import org.glyptodon.guacamole.auth.jdbc.user.UserDirectory; import org.glyptodon.guacamole.auth.jdbc.user.UserDirectory;
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ConnectionGroupMapper; import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ConnectionGroupMapper;
import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionMapper; import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionMapper;
@@ -100,13 +100,13 @@ public class JDBCAuthenticationProviderModule extends MyBatisModule {
bind(Environment.class).toInstance(environment); bind(Environment.class).toInstance(environment);
bind(ConnectionDirectory.class); bind(ConnectionDirectory.class);
bind(ConnectionGroupDirectory.class); bind(ConnectionGroupDirectory.class);
bind(MySQLConnection.class); bind(ModeledConnection.class);
bind(MySQLConnectionGroup.class); bind(ModeledConnectionGroup.class);
bind(MySQLGuacamoleConfiguration.class); bind(ModeledGuacamoleConfiguration.class);
bind(MySQLUser.class); bind(ModeledUser.class);
bind(MySQLUserContext.class); bind(RootConnectionGroup.class);
bind(MySQLRootConnectionGroup.class); bind(SystemPermissionSet.class);
bind(MySQLSystemPermissionSet.class); bind(UserContext.class);
bind(UserDirectory.class); bind(UserDirectory.class);
// Bind services // Bind services

View File

@@ -21,8 +21,8 @@
*/ */
/** /**
* Base classes supporting the MySQL authentication provider and defining the * Base classes supporting JDBC-driven authentication providers and defining
* relationships between the model and the implementations of guacamole-ext * the relationships between the model and the implementations of guacamole-ext
* classes. * classes.
*/ */
package org.glyptodon.guacamole.auth.jdbc.base; package org.glyptodon.guacamole.auth.jdbc.base;

View File

@@ -34,7 +34,8 @@ import org.glyptodon.guacamole.net.auth.Directory;
import org.mybatis.guice.transactional.Transactional; import org.mybatis.guice.transactional.Transactional;
/** /**
* A MySQL based implementation of the Connection Directory. * Implementation of the Connection Directory which is driven by an underlying,
* arbitrary database.
* *
* @author James Muehlner * @author James Muehlner
* @author Michael Jumper * @author Michael Jumper
@@ -72,7 +73,7 @@ public class ConnectionDirectory implements Directory<Connection> {
@Override @Override
@Transactional @Transactional
public Collection<Connection> getAll(Collection<String> identifiers) throws GuacamoleException { public Collection<Connection> getAll(Collection<String> identifiers) throws GuacamoleException {
Collection<MySQLConnection> objects = connectionService.retrieveObjects(currentUser, identifiers); Collection<ModeledConnection> objects = connectionService.retrieveObjects(currentUser, identifiers);
return Collections.<Connection>unmodifiableCollection(objects); return Collections.<Connection>unmodifiableCollection(objects);
} }
@@ -91,7 +92,7 @@ public class ConnectionDirectory implements Directory<Connection> {
@Override @Override
@Transactional @Transactional
public void update(Connection object) throws GuacamoleException { public void update(Connection object) throws GuacamoleException {
MySQLConnection connection = (MySQLConnection) object; ModeledConnection connection = (ModeledConnection) object;
connectionService.updateObject(currentUser, connection); connectionService.updateObject(currentUser, connection);
} }

View File

@@ -52,7 +52,7 @@ import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;
* *
* @author Michael Jumper, James Muehlner * @author Michael Jumper, James Muehlner
*/ */
public class ConnectionService extends DirectoryObjectService<MySQLConnection, Connection, ConnectionModel> { public class ConnectionService extends DirectoryObjectService<ModeledConnection, Connection, ConnectionModel> {
/** /**
* Mapper for accessing connections. * Mapper for accessing connections.
@@ -76,7 +76,7 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
* Provider for creating connections. * Provider for creating connections.
*/ */
@Inject @Inject
private Provider<MySQLConnection> mySQLConnectionProvider; private Provider<ModeledConnection> connectionProvider;
/** /**
* Service for creating and tracking sockets. * Service for creating and tracking sockets.
@@ -90,9 +90,9 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
} }
@Override @Override
protected MySQLConnection getObjectInstance(AuthenticatedUser currentUser, protected ModeledConnection getObjectInstance(AuthenticatedUser currentUser,
ConnectionModel model) { ConnectionModel model) {
MySQLConnection connection = mySQLConnectionProvider.get(); ModeledConnection connection = connectionProvider.get();
connection.init(currentUser, model); connection.init(currentUser, model);
return connection; return connection;
} }
@@ -101,11 +101,11 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
protected ConnectionModel getModelInstance(AuthenticatedUser currentUser, protected ConnectionModel getModelInstance(AuthenticatedUser currentUser,
final Connection object) { final Connection object) {
// Create new MySQLConnection backed by blank model // Create new ModeledConnection backed by blank model
ConnectionModel model = new ConnectionModel(); ConnectionModel model = new ConnectionModel();
MySQLConnection connection = getObjectInstance(currentUser, model); ModeledConnection connection = getObjectInstance(currentUser, model);
// Set model contents through MySQLConnection, copying the provided connection // Set model contents through ModeledConnection, copying the provided connection
connection.setParentIdentifier(object.getParentIdentifier()); connection.setParentIdentifier(object.getParentIdentifier());
connection.setName(object.getName()); connection.setName(object.getName());
connection.setConfiguration(object.getConfiguration()); connection.setConfiguration(object.getConfiguration());
@@ -147,7 +147,7 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
@Override @Override
protected void validateExistingObject(AuthenticatedUser user, protected void validateExistingObject(AuthenticatedUser user,
MySQLConnection object) throws GuacamoleException { ModeledConnection object) throws GuacamoleException {
// Name must not be blank // Name must not be blank
if (object.getName().trim().isEmpty()) if (object.getName().trim().isEmpty())
@@ -170,7 +170,7 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
* A collection of parameter models containing the name/value pairs * A collection of parameter models containing the name/value pairs
* of the given connection's parameters. * of the given connection's parameters.
*/ */
private Collection<ParameterModel> getParameterModels(MySQLConnection connection) { private Collection<ParameterModel> getParameterModels(ModeledConnection connection) {
Map<String, String> parameters = connection.getConfiguration().getParameters(); Map<String, String> parameters = connection.getConfiguration().getParameters();
@@ -202,11 +202,11 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
} }
@Override @Override
public MySQLConnection createObject(AuthenticatedUser user, Connection object) public ModeledConnection createObject(AuthenticatedUser user, Connection object)
throws GuacamoleException { throws GuacamoleException {
// Create connection // Create connection
MySQLConnection connection = super.createObject(user, object); ModeledConnection connection = super.createObject(user, object);
connection.setConfiguration(object.getConfiguration()); connection.setConfiguration(object.getConfiguration());
// Insert new parameters, if any // Insert new parameters, if any
@@ -219,7 +219,7 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
} }
@Override @Override
public void updateObject(AuthenticatedUser user, MySQLConnection object) public void updateObject(AuthenticatedUser user, ModeledConnection object)
throws GuacamoleException { throws GuacamoleException {
// Update connection // Update connection
@@ -330,7 +330,7 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
* If permission to read the connection history is denied. * If permission to read the connection history is denied.
*/ */
public List<ConnectionRecord> retrieveHistory(AuthenticatedUser user, public List<ConnectionRecord> retrieveHistory(AuthenticatedUser user,
MySQLConnection connection) throws GuacamoleException { ModeledConnection connection) throws GuacamoleException {
String identifier = connection.getIdentifier(); String identifier = connection.getIdentifier();
@@ -345,7 +345,7 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
// Add past connections from model objects // Add past connections from model objects
for (ConnectionRecordModel model : models) for (ConnectionRecordModel model : models)
records.add(new MySQLConnectionRecord(model)); records.add(new ModeledConnectionRecord(model));
// Return converted history list // Return converted history list
return records; return records;
@@ -379,7 +379,7 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
* If permission to connect to this connection is denied. * If permission to connect to this connection is denied.
*/ */
public GuacamoleSocket connect(AuthenticatedUser user, public GuacamoleSocket connect(AuthenticatedUser user,
MySQLConnection connection, GuacamoleClientInformation info) ModeledConnection connection, GuacamoleClientInformation info)
throws GuacamoleException { throws GuacamoleException {
// Connect only if READ permission is granted // Connect only if READ permission is granted

View File

@@ -26,7 +26,7 @@ import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import java.util.List; import java.util.List;
import org.glyptodon.guacamole.auth.jdbc.base.DirectoryObject; import org.glyptodon.guacamole.auth.jdbc.base.DirectoryObject;
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.MySQLRootConnectionGroup; import org.glyptodon.guacamole.auth.jdbc.connectiongroup.RootConnectionGroup;
import org.glyptodon.guacamole.auth.jdbc.socket.GuacamoleSocketService; import org.glyptodon.guacamole.auth.jdbc.socket.GuacamoleSocketService;
import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.net.GuacamoleSocket; import org.glyptodon.guacamole.net.GuacamoleSocket;
@@ -36,10 +36,13 @@ import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;
import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
/** /**
* A MySQL based implementation of the Connection object. * An implementation of the Connection object which is backed by a database
* model.
*
* @author James Muehlner * @author James Muehlner
* @author Michael Jumper
*/ */
public class MySQLConnection extends DirectoryObject<ConnectionModel> public class ModeledConnection extends DirectoryObject<ConnectionModel>
implements Connection { implements Connection {
/** /**
@@ -58,7 +61,7 @@ public class MySQLConnection extends DirectoryObject<ConnectionModel>
* Provider for lazy-loaded, permission-controlled configurations. * Provider for lazy-loaded, permission-controlled configurations.
*/ */
@Inject @Inject
private Provider<MySQLGuacamoleConfiguration> configProvider; private Provider<ModeledGuacamoleConfiguration> configProvider;
/** /**
* The manually-set GuacamoleConfiguration, if any. * The manually-set GuacamoleConfiguration, if any.
@@ -66,9 +69,9 @@ public class MySQLConnection extends DirectoryObject<ConnectionModel>
private GuacamoleConfiguration config = null; private GuacamoleConfiguration config = null;
/** /**
* Creates a new, empty MySQLConnection. * Creates a new, empty ModeledConnection.
*/ */
public MySQLConnection() { public ModeledConnection() {
} }
@Override @Override
@@ -87,7 +90,7 @@ public class MySQLConnection extends DirectoryObject<ConnectionModel>
// Translate null parent to proper identifier // Translate null parent to proper identifier
String parentIdentifier = getModel().getParentIdentifier(); String parentIdentifier = getModel().getParentIdentifier();
if (parentIdentifier == null) if (parentIdentifier == null)
return MySQLRootConnectionGroup.IDENTIFIER; return RootConnectionGroup.IDENTIFIER;
return parentIdentifier; return parentIdentifier;
@@ -98,7 +101,7 @@ public class MySQLConnection extends DirectoryObject<ConnectionModel>
// Translate root identifier back into null // Translate root identifier back into null
if (parentIdentifier != null if (parentIdentifier != null
&& parentIdentifier.equals(MySQLRootConnectionGroup.IDENTIFIER)) && parentIdentifier.equals(RootConnectionGroup.IDENTIFIER))
parentIdentifier = null; parentIdentifier = null;
getModel().setParentIdentifier(parentIdentifier); getModel().setParentIdentifier(parentIdentifier);
@@ -113,7 +116,7 @@ public class MySQLConnection extends DirectoryObject<ConnectionModel>
return config; return config;
// Otherwise, return permission-controlled configuration // Otherwise, return permission-controlled configuration
MySQLGuacamoleConfiguration restrictedConfig = configProvider.get(); ModeledGuacamoleConfiguration restrictedConfig = configProvider.get();
restrictedConfig.init(getCurrentUser(), getModel()); restrictedConfig.init(getCurrentUser(), getModel());
return restrictedConfig; return restrictedConfig;

View File

@@ -27,27 +27,27 @@ import java.util.Date;
import org.glyptodon.guacamole.net.auth.ConnectionRecord; import org.glyptodon.guacamole.net.auth.ConnectionRecord;
/** /**
* A ConnectionRecord which is based on data stored in MySQL. * A ConnectionRecord which is backed by a database model.
* *
* @author James Muehlner * @author James Muehlner
* @author Michael Jumper * @author Michael Jumper
*/ */
public class MySQLConnectionRecord implements ConnectionRecord { public class ModeledConnectionRecord implements ConnectionRecord {
/** /**
* The model object backing this connection record. * The model object backing this connection record.
*/ */
private ConnectionRecordModel model; private final ConnectionRecordModel model;
/** /**
* Creates a new MySQLConnectionRecord backed by the given model object. * Creates a new ModeledConnectionRecord backed by the given model object.
* Changes to this record will affect the backing model object, and changes * Changes to this record will affect the backing model object, and changes
* to the backing model object will affect this record. * to the backing model object will affect this record.
* *
* @param model * @param model
* The model object to use to back this connection record. * The model object to use to back this connection record.
*/ */
public MySQLConnectionRecord(ConnectionRecordModel model) { public ModeledConnectionRecord(ConnectionRecordModel model) {
this.model = model; this.model = model;
} }

View File

@@ -33,7 +33,7 @@ import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
public class MySQLGuacamoleConfiguration extends GuacamoleConfiguration { public class ModeledGuacamoleConfiguration extends GuacamoleConfiguration {
/** /**
* The user this configuration belongs to. Access is based on his/her * The user this configuration belongs to. Access is based on his/her
@@ -59,9 +59,9 @@ public class MySQLGuacamoleConfiguration extends GuacamoleConfiguration {
private Map<String, String> parameters = null; private Map<String, String> parameters = null;
/** /**
* Creates a new, empty MySQLGuacamoleConfiguration. * Creates a new, empty ModelGuacamoleConfiguration.
*/ */
public MySQLGuacamoleConfiguration() { public ModeledGuacamoleConfiguration() {
} }
/** /**

View File

@@ -34,7 +34,8 @@ import org.glyptodon.guacamole.net.auth.Directory;
import org.mybatis.guice.transactional.Transactional; import org.mybatis.guice.transactional.Transactional;
/** /**
* A MySQL based implementation of the ConnectionGroup Directory. * Implementation of the ConnectionGroup Directory which is driven by an
* underlying, arbitrary database.
* *
* @author James Muehlner * @author James Muehlner
* @author Michael Jumper * @author Michael Jumper
@@ -72,7 +73,7 @@ public class ConnectionGroupDirectory implements Directory<ConnectionGroup> {
@Override @Override
@Transactional @Transactional
public Collection<ConnectionGroup> getAll(Collection<String> identifiers) throws GuacamoleException { public Collection<ConnectionGroup> getAll(Collection<String> identifiers) throws GuacamoleException {
Collection<MySQLConnectionGroup> objects = connectionGroupService.retrieveObjects(currentUser, identifiers); Collection<ModeledConnectionGroup> objects = connectionGroupService.retrieveObjects(currentUser, identifiers);
return Collections.<ConnectionGroup>unmodifiableCollection(objects); return Collections.<ConnectionGroup>unmodifiableCollection(objects);
} }
@@ -91,7 +92,7 @@ public class ConnectionGroupDirectory implements Directory<ConnectionGroup> {
@Override @Override
@Transactional @Transactional
public void update(ConnectionGroup object) throws GuacamoleException { public void update(ConnectionGroup object) throws GuacamoleException {
MySQLConnectionGroup connectionGroup = (MySQLConnectionGroup) object; ModeledConnectionGroup connectionGroup = (ModeledConnectionGroup) object;
connectionGroupService.updateObject(currentUser, connectionGroup); connectionGroupService.updateObject(currentUser, connectionGroup);
} }

View File

@@ -46,7 +46,7 @@ import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;
* *
* @author Michael Jumper, James Muehlner * @author Michael Jumper, James Muehlner
*/ */
public class ConnectionGroupService extends DirectoryObjectService<MySQLConnectionGroup, public class ConnectionGroupService extends DirectoryObjectService<ModeledConnectionGroup,
ConnectionGroup, ConnectionGroupModel> { ConnectionGroup, ConnectionGroupModel> {
/** /**
@@ -59,7 +59,7 @@ public class ConnectionGroupService extends DirectoryObjectService<MySQLConnecti
* Provider for creating connection groups. * Provider for creating connection groups.
*/ */
@Inject @Inject
private Provider<MySQLConnectionGroup> connectionGroupProvider; private Provider<ModeledConnectionGroup> connectionGroupProvider;
/** /**
* Service for creating and tracking sockets. * Service for creating and tracking sockets.
@@ -73,9 +73,9 @@ public class ConnectionGroupService extends DirectoryObjectService<MySQLConnecti
} }
@Override @Override
protected MySQLConnectionGroup getObjectInstance(AuthenticatedUser currentUser, protected ModeledConnectionGroup getObjectInstance(AuthenticatedUser currentUser,
ConnectionGroupModel model) { ConnectionGroupModel model) {
MySQLConnectionGroup connectionGroup = connectionGroupProvider.get(); ModeledConnectionGroup connectionGroup = connectionGroupProvider.get();
connectionGroup.init(currentUser, model); connectionGroup.init(currentUser, model);
return connectionGroup; return connectionGroup;
} }
@@ -84,11 +84,11 @@ public class ConnectionGroupService extends DirectoryObjectService<MySQLConnecti
protected ConnectionGroupModel getModelInstance(AuthenticatedUser currentUser, protected ConnectionGroupModel getModelInstance(AuthenticatedUser currentUser,
final ConnectionGroup object) { final ConnectionGroup object) {
// Create new MySQLConnectionGroup backed by blank model // Create new ModeledConnectionGroup backed by blank model
ConnectionGroupModel model = new ConnectionGroupModel(); ConnectionGroupModel model = new ConnectionGroupModel();
MySQLConnectionGroup connectionGroup = getObjectInstance(currentUser, model); ModeledConnectionGroup connectionGroup = getObjectInstance(currentUser, model);
// Set model contents through MySQLConnection, copying the provided connection group // Set model contents through ModeledConnectionGroup, copying the provided connection group
connectionGroup.setParentIdentifier(object.getParentIdentifier()); connectionGroup.setParentIdentifier(object.getParentIdentifier());
connectionGroup.setName(object.getName()); connectionGroup.setName(object.getName());
connectionGroup.setType(object.getType()); connectionGroup.setType(object.getType());
@@ -130,7 +130,7 @@ public class ConnectionGroupService extends DirectoryObjectService<MySQLConnecti
@Override @Override
protected void validateExistingObject(AuthenticatedUser user, protected void validateExistingObject(AuthenticatedUser user,
MySQLConnectionGroup object) throws GuacamoleException { ModeledConnectionGroup object) throws GuacamoleException {
// Name must not be blank // Name must not be blank
if (object.getName().trim().isEmpty()) if (object.getName().trim().isEmpty())
@@ -199,7 +199,7 @@ public class ConnectionGroupService extends DirectoryObjectService<MySQLConnecti
* If permission to connect to this connection is denied. * If permission to connect to this connection is denied.
*/ */
public GuacamoleSocket connect(AuthenticatedUser user, public GuacamoleSocket connect(AuthenticatedUser user,
MySQLConnectionGroup connectionGroup, GuacamoleClientInformation info) ModeledConnectionGroup connectionGroup, GuacamoleClientInformation info)
throws GuacamoleException { throws GuacamoleException {
// Connect only if READ permission is granted // Connect only if READ permission is granted

View File

@@ -33,11 +33,12 @@ import org.glyptodon.guacamole.net.auth.ConnectionGroup;
import org.glyptodon.guacamole.protocol.GuacamoleClientInformation; import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;
/** /**
* A MySQL based implementation of the ConnectionGroup object. * An implementation of the ConnectionGroup object which is backed by a
* database model.
* *
* @author James Muehlner * @author James Muehlner
*/ */
public class MySQLConnectionGroup extends DirectoryObject<ConnectionGroupModel> public class ModeledConnectionGroup extends DirectoryObject<ConnectionGroupModel>
implements ConnectionGroup { implements ConnectionGroup {
/** /**
@@ -59,9 +60,9 @@ public class MySQLConnectionGroup extends DirectoryObject<ConnectionGroupModel>
private GuacamoleSocketService socketService; private GuacamoleSocketService socketService;
/** /**
* Creates a new, empty MySQLConnection. * Creates a new, empty ModeledConnectionGroup.
*/ */
public MySQLConnectionGroup() { public ModeledConnectionGroup() {
} }
@Override @Override
@@ -80,7 +81,7 @@ public class MySQLConnectionGroup extends DirectoryObject<ConnectionGroupModel>
// Translate null parent to proper identifier // Translate null parent to proper identifier
String parentIdentifier = getModel().getParentIdentifier(); String parentIdentifier = getModel().getParentIdentifier();
if (parentIdentifier == null) if (parentIdentifier == null)
return MySQLRootConnectionGroup.IDENTIFIER; return RootConnectionGroup.IDENTIFIER;
return parentIdentifier; return parentIdentifier;
@@ -91,7 +92,7 @@ public class MySQLConnectionGroup extends DirectoryObject<ConnectionGroupModel>
// Translate root identifier back into null // Translate root identifier back into null
if (parentIdentifier != null if (parentIdentifier != null
&& parentIdentifier.equals(MySQLRootConnectionGroup.IDENTIFIER)) && parentIdentifier.equals(RootConnectionGroup.IDENTIFIER))
parentIdentifier = null; parentIdentifier = null;
getModel().setParentIdentifier(parentIdentifier); getModel().setParentIdentifier(parentIdentifier);

View File

@@ -38,7 +38,7 @@ import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
public class MySQLRootConnectionGroup implements ConnectionGroup { public class RootConnectionGroup implements ConnectionGroup {
/** /**
* The identifier used to represent the root connection group. There is no * The identifier used to represent the root connection group. There is no
@@ -73,9 +73,9 @@ public class MySQLRootConnectionGroup implements ConnectionGroup {
private ConnectionGroupService connectionGroupService; private ConnectionGroupService connectionGroupService;
/** /**
* Creates a new, empty MySQLRootConnectionGroup. * Creates a new, empty RootConnectionGroup.
*/ */
public MySQLRootConnectionGroup() { public RootConnectionGroup() {
} }
/** /**

View File

@@ -26,7 +26,7 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser; import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser;
import org.glyptodon.guacamole.auth.jdbc.user.MySQLUser; import org.glyptodon.guacamole.auth.jdbc.user.ModeledUser;
import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.GuacamoleSecurityException; import org.glyptodon.guacamole.GuacamoleSecurityException;
import org.glyptodon.guacamole.net.auth.permission.ObjectPermission; import org.glyptodon.guacamole.net.auth.permission.ObjectPermission;
@@ -89,7 +89,7 @@ public abstract class ObjectPermissionService<ModelType>
* If an error occurs while checking permission status, or if * If an error occurs while checking permission status, or if
* permission is denied to read the current user's permissions. * permission is denied to read the current user's permissions.
*/ */
protected boolean canAlterPermissions(AuthenticatedUser user, MySQLUser targetUser, protected boolean canAlterPermissions(AuthenticatedUser user, ModeledUser targetUser,
Collection<ObjectPermission> permissions) Collection<ObjectPermission> permissions)
throws GuacamoleException { throws GuacamoleException {
@@ -123,7 +123,7 @@ public abstract class ObjectPermissionService<ModelType>
} }
@Override @Override
public void createPermissions(AuthenticatedUser user, MySQLUser targetUser, public void createPermissions(AuthenticatedUser user, ModeledUser targetUser,
Collection<ObjectPermission> permissions) Collection<ObjectPermission> permissions)
throws GuacamoleException { throws GuacamoleException {
@@ -140,7 +140,7 @@ public abstract class ObjectPermissionService<ModelType>
} }
@Override @Override
public void deletePermissions(AuthenticatedUser user, MySQLUser targetUser, public void deletePermissions(AuthenticatedUser user, ModeledUser targetUser,
Collection<ObjectPermission> permissions) Collection<ObjectPermission> permissions)
throws GuacamoleException { throws GuacamoleException {

View File

@@ -27,7 +27,7 @@ import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser; import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser;
import org.glyptodon.guacamole.auth.jdbc.user.MySQLUser; import org.glyptodon.guacamole.auth.jdbc.user.ModeledUser;
import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.GuacamoleSecurityException; import org.glyptodon.guacamole.GuacamoleSecurityException;
import org.glyptodon.guacamole.net.auth.permission.Permission; import org.glyptodon.guacamole.net.auth.permission.Permission;
@@ -112,7 +112,7 @@ public abstract class PermissionService<PermissionSetType extends PermissionSet<
* A model object which is based on the given permission and target * A model object which is based on the given permission and target
* user. * user.
*/ */
protected abstract ModelType getModelInstance(MySQLUser targetUser, protected abstract ModelType getModelInstance(ModeledUser targetUser,
PermissionType permission); PermissionType permission);
/** /**
@@ -129,7 +129,7 @@ public abstract class PermissionService<PermissionSetType extends PermissionSet<
* A collection of model objects which are based on the given * A collection of model objects which are based on the given
* permissions and target user. * permissions and target user.
*/ */
protected Collection<ModelType> getModelInstances(MySQLUser targetUser, protected Collection<ModelType> getModelInstances(ModeledUser targetUser,
Collection<PermissionType> permissions) { Collection<PermissionType> permissions) {
// Create new collection of models by manually converting each permission // Create new collection of models by manually converting each permission
@@ -163,7 +163,7 @@ public abstract class PermissionService<PermissionSetType extends PermissionSet<
* user is denied. * user is denied.
*/ */
public abstract PermissionSetType getPermissionSet(AuthenticatedUser user, public abstract PermissionSetType getPermissionSet(AuthenticatedUser user,
MySQLUser targetUser) throws GuacamoleException; ModeledUser targetUser) throws GuacamoleException;
/** /**
* Retrieves all permissions associated with the given user. * Retrieves all permissions associated with the given user.
@@ -181,7 +181,7 @@ public abstract class PermissionService<PermissionSetType extends PermissionSet<
* If an error occurs while retrieving the requested permissions. * If an error occurs while retrieving the requested permissions.
*/ */
public Set<PermissionType> retrievePermissions(AuthenticatedUser user, public Set<PermissionType> retrievePermissions(AuthenticatedUser user,
MySQLUser targetUser) throws GuacamoleException { ModeledUser targetUser) throws GuacamoleException {
// Only an admin can read permissions that aren't his own // Only an admin can read permissions that aren't his own
if (user.getUser().getIdentifier().equals(targetUser.getIdentifier()) if (user.getUser().getIdentifier().equals(targetUser.getIdentifier())
@@ -211,7 +211,7 @@ public abstract class PermissionService<PermissionSetType extends PermissionSet<
* occurs while creating the permissions. * occurs while creating the permissions.
*/ */
public abstract void createPermissions(AuthenticatedUser user, public abstract void createPermissions(AuthenticatedUser user,
MySQLUser targetUser, ModeledUser targetUser,
Collection<PermissionType> permissions) throws GuacamoleException; Collection<PermissionType> permissions) throws GuacamoleException;
/** /**
@@ -232,7 +232,7 @@ public abstract class PermissionService<PermissionSetType extends PermissionSet<
* occurs while deleting the permissions. * occurs while deleting the permissions.
*/ */
public abstract void deletePermissions(AuthenticatedUser user, public abstract void deletePermissions(AuthenticatedUser user,
MySQLUser targetUser, ModeledUser targetUser,
Collection<PermissionType> permissions) throws GuacamoleException; Collection<PermissionType> permissions) throws GuacamoleException;
} }

View File

@@ -26,7 +26,7 @@ import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import java.util.Collection; import java.util.Collection;
import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser; import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser;
import org.glyptodon.guacamole.auth.jdbc.user.MySQLUser; import org.glyptodon.guacamole.auth.jdbc.user.ModeledUser;
import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.GuacamoleSecurityException; import org.glyptodon.guacamole.GuacamoleSecurityException;
import org.glyptodon.guacamole.net.auth.permission.SystemPermission; import org.glyptodon.guacamole.net.auth.permission.SystemPermission;
@@ -39,7 +39,7 @@ import org.glyptodon.guacamole.net.auth.permission.SystemPermission;
* @author Michael Jumper * @author Michael Jumper
*/ */
public class SystemPermissionService public class SystemPermissionService
extends PermissionService<MySQLSystemPermissionSet, SystemPermission, SystemPermissionModel> { extends PermissionService<SystemPermissionSet, SystemPermission, SystemPermissionModel> {
/** /**
* Mapper for system-level permissions. * Mapper for system-level permissions.
@@ -51,7 +51,7 @@ public class SystemPermissionService
* Provider for creating system permission sets. * Provider for creating system permission sets.
*/ */
@Inject @Inject
private Provider<MySQLSystemPermissionSet> systemPermissionSetProvider; private Provider<SystemPermissionSet> systemPermissionSetProvider;
@Override @Override
protected SystemPermissionMapper getPermissionMapper() { protected SystemPermissionMapper getPermissionMapper() {
@@ -64,7 +64,7 @@ public class SystemPermissionService
} }
@Override @Override
protected SystemPermissionModel getModelInstance(final MySQLUser targetUser, protected SystemPermissionModel getModelInstance(final ModeledUser targetUser,
final SystemPermission permission) { final SystemPermission permission) {
SystemPermissionModel model = new SystemPermissionModel(); SystemPermissionModel model = new SystemPermissionModel();
@@ -79,11 +79,11 @@ public class SystemPermissionService
} }
@Override @Override
public MySQLSystemPermissionSet getPermissionSet(AuthenticatedUser user, public SystemPermissionSet getPermissionSet(AuthenticatedUser user,
MySQLUser targetUser) throws GuacamoleException { ModeledUser targetUser) throws GuacamoleException {
// Create permission set for requested user // Create permission set for requested user
MySQLSystemPermissionSet permissionSet = systemPermissionSetProvider.get(); SystemPermissionSet permissionSet = systemPermissionSetProvider.get();
permissionSet.init(user, targetUser); permissionSet.init(user, targetUser);
return permissionSet; return permissionSet;
@@ -91,7 +91,7 @@ public class SystemPermissionService
} }
@Override @Override
public void createPermissions(AuthenticatedUser user, MySQLUser targetUser, public void createPermissions(AuthenticatedUser user, ModeledUser targetUser,
Collection<SystemPermission> permissions) throws GuacamoleException { Collection<SystemPermission> permissions) throws GuacamoleException {
// Only an admin can create system permissions // Only an admin can create system permissions
@@ -107,7 +107,7 @@ public class SystemPermissionService
} }
@Override @Override
public void deletePermissions(AuthenticatedUser user, MySQLUser targetUser, public void deletePermissions(AuthenticatedUser user, ModeledUser targetUser,
Collection<SystemPermission> permissions) throws GuacamoleException { Collection<SystemPermission> permissions) throws GuacamoleException {
// Only an admin can delete system permissions // Only an admin can delete system permissions
@@ -143,7 +143,7 @@ public class SystemPermissionService
* If an error occurs while retrieving the requested permission. * If an error occurs while retrieving the requested permission.
*/ */
public SystemPermission retrievePermission(AuthenticatedUser user, public SystemPermission retrievePermission(AuthenticatedUser user,
MySQLUser targetUser, SystemPermission.Type type) throws GuacamoleException { ModeledUser targetUser, SystemPermission.Type type) throws GuacamoleException {
// Only an admin can read permissions that aren't his own // Only an admin can read permissions that aren't his own
if (user.getUser().getIdentifier().equals(targetUser.getIdentifier()) if (user.getUser().getIdentifier().equals(targetUser.getIdentifier())

View File

@@ -22,14 +22,13 @@
package org.glyptodon.guacamole.auth.jdbc.permission; package org.glyptodon.guacamole.auth.jdbc.permission;
import org.glyptodon.guacamole.auth.jdbc.user.MySQLUser; import org.glyptodon.guacamole.auth.jdbc.user.ModeledUser;
import com.google.inject.Inject; import com.google.inject.Inject;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser; import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser;
import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.net.auth.permission.SystemPermission; import org.glyptodon.guacamole.net.auth.permission.SystemPermission;
import org.glyptodon.guacamole.net.auth.permission.SystemPermissionSet;
/** /**
* A database implementation of SystemPermissionSet which uses an injected * A database implementation of SystemPermissionSet which uses an injected
@@ -38,7 +37,8 @@ import org.glyptodon.guacamole.net.auth.permission.SystemPermissionSet;
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
public class MySQLSystemPermissionSet implements SystemPermissionSet { public class SystemPermissionSet
implements org.glyptodon.guacamole.net.auth.permission.SystemPermissionSet {
/** /**
* The user that queried this permission set. Access is based on his/her * The user that queried this permission set. Access is based on his/her
@@ -50,7 +50,7 @@ public class MySQLSystemPermissionSet implements SystemPermissionSet {
* The user associated with this permission set. Each of the permissions in * The user associated with this permission set. Each of the permissions in
* this permission set is granted to this user. * this permission set is granted to this user.
*/ */
private MySQLUser user; private ModeledUser user;
/** /**
* Service for reading and manipulating system permissions. * Service for reading and manipulating system permissions.
@@ -59,11 +59,11 @@ public class MySQLSystemPermissionSet implements SystemPermissionSet {
private SystemPermissionService systemPermissionService; private SystemPermissionService systemPermissionService;
/** /**
* Creates a new MySQLSystemPermissionSet. The resulting permission set * Creates a new SystemPermissionSet. The resulting permission set
* must still be initialized by a call to init(), or the information * must still be initialized by a call to init(), or the information
* necessary to read and modify this set will be missing. * necessary to read and modify this set will be missing.
*/ */
public MySQLSystemPermissionSet() { public SystemPermissionSet() {
} }
/** /**
@@ -77,7 +77,7 @@ public class MySQLSystemPermissionSet implements SystemPermissionSet {
* @param user * @param user
* The user to whom the permissions in this set are granted. * The user to whom the permissions in this set are granted.
*/ */
public void init(AuthenticatedUser currentUser, MySQLUser user) { public void init(AuthenticatedUser currentUser, ModeledUser user) {
this.currentUser = currentUser; this.currentUser = currentUser;
this.user = user; this.user = user;
} }

View File

@@ -31,8 +31,8 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser; import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser;
import org.glyptodon.guacamole.auth.jdbc.connection.MySQLConnection; import org.glyptodon.guacamole.auth.jdbc.connection.ModeledConnection;
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.MySQLConnectionGroup; import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ModeledConnectionGroup;
import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionRecordMapper; import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionRecordMapper;
import org.glyptodon.guacamole.auth.jdbc.connection.ParameterMapper; import org.glyptodon.guacamole.auth.jdbc.connection.ParameterMapper;
import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionModel; import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionModel;
@@ -154,7 +154,7 @@ public abstract class AbstractGuacamoleSocketService implements GuacamoleSocketS
* If access is denied to the given user for any reason. * If access is denied to the given user for any reason.
*/ */
protected abstract void acquire(AuthenticatedUser user, protected abstract void acquire(AuthenticatedUser user,
MySQLConnection connection) throws GuacamoleException; ModeledConnection connection) throws GuacamoleException;
/** /**
* Releases possibly-exclusive access to the given connection on behalf of * Releases possibly-exclusive access to the given connection on behalf of
@@ -168,11 +168,11 @@ public abstract class AbstractGuacamoleSocketService implements GuacamoleSocketS
* The connection being released. * The connection being released.
*/ */
protected abstract void release(AuthenticatedUser user, protected abstract void release(AuthenticatedUser user,
MySQLConnection connection); ModeledConnection connection);
@Override @Override
public GuacamoleSocket getGuacamoleSocket(final AuthenticatedUser user, public GuacamoleSocket getGuacamoleSocket(final AuthenticatedUser user,
final MySQLConnection connection, GuacamoleClientInformation info) final ModeledConnection connection, GuacamoleClientInformation info)
throws GuacamoleException { throws GuacamoleException {
// Create record for active connection // Create record for active connection
@@ -273,7 +273,7 @@ public abstract class AbstractGuacamoleSocketService implements GuacamoleSocketS
@Override @Override
public GuacamoleSocket getGuacamoleSocket(AuthenticatedUser user, public GuacamoleSocket getGuacamoleSocket(AuthenticatedUser user,
MySQLConnectionGroup connectionGroup, ModeledConnectionGroup connectionGroup,
GuacamoleClientInformation info) throws GuacamoleException { GuacamoleClientInformation info) throws GuacamoleException {
// STUB // STUB
throw new UnsupportedOperationException("STUB"); throw new UnsupportedOperationException("STUB");

View File

@@ -24,8 +24,8 @@ package org.glyptodon.guacamole.auth.jdbc.socket;
import java.util.List; import java.util.List;
import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser; import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser;
import org.glyptodon.guacamole.auth.jdbc.connection.MySQLConnection; import org.glyptodon.guacamole.auth.jdbc.connection.ModeledConnection;
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.MySQLConnectionGroup; import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ModeledConnectionGroup;
import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.net.GuacamoleSocket; import org.glyptodon.guacamole.net.GuacamoleSocket;
import org.glyptodon.guacamole.net.auth.Connection; import org.glyptodon.guacamole.net.auth.Connection;
@@ -68,7 +68,7 @@ public interface GuacamoleSocketService {
* rules. * rules.
*/ */
GuacamoleSocket getGuacamoleSocket(AuthenticatedUser user, GuacamoleSocket getGuacamoleSocket(AuthenticatedUser user,
MySQLConnection connection, GuacamoleClientInformation info) ModeledConnection connection, GuacamoleClientInformation info)
throws GuacamoleException; throws GuacamoleException;
/** /**
@@ -111,7 +111,7 @@ public interface GuacamoleSocketService {
* rules, or if the connection group is not balancing. * rules, or if the connection group is not balancing.
*/ */
GuacamoleSocket getGuacamoleSocket(AuthenticatedUser user, GuacamoleSocket getGuacamoleSocket(AuthenticatedUser user,
MySQLConnectionGroup connectionGroup, ModeledConnectionGroup connectionGroup,
GuacamoleClientInformation info) GuacamoleClientInformation info)
throws GuacamoleException; throws GuacamoleException;

View File

@@ -24,7 +24,7 @@ package org.glyptodon.guacamole.auth.jdbc.socket;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser; import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser;
import org.glyptodon.guacamole.auth.jdbc.connection.MySQLConnection; import org.glyptodon.guacamole.auth.jdbc.connection.ModeledConnection;
import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleException;
@@ -39,13 +39,13 @@ public class UnrestrictedGuacamoleSocketService
extends AbstractGuacamoleSocketService { extends AbstractGuacamoleSocketService {
@Override @Override
protected void acquire(AuthenticatedUser user, MySQLConnection connection) protected void acquire(AuthenticatedUser user, ModeledConnection connection)
throws GuacamoleException { throws GuacamoleException {
// Do nothing // Do nothing
} }
@Override @Override
protected void release(AuthenticatedUser user, MySQLConnection connection) { protected void release(AuthenticatedUser user, ModeledConnection connection) {
// Do nothing // Do nothing
} }

View File

@@ -34,7 +34,7 @@ public class AuthenticatedUser {
/** /**
* The user that authenticated. * The user that authenticated.
*/ */
private final MySQLUser user; private final ModeledUser user;
/** /**
* The credentials given when this user authenticated. * The credentials given when this user authenticated.
@@ -51,7 +51,7 @@ public class AuthenticatedUser {
* @param credentials * @param credentials
* The credentials given by the user when they authenticated. * The credentials given by the user when they authenticated.
*/ */
public AuthenticatedUser(MySQLUser user, Credentials credentials) { public AuthenticatedUser(ModeledUser user, Credentials credentials) {
this.user = user; this.user = user;
this.credentials = credentials; this.credentials = credentials;
} }
@@ -62,7 +62,7 @@ public class AuthenticatedUser {
* @return * @return
* The user that authenticated. * The user that authenticated.
*/ */
public MySQLUser getUser() { public ModeledUser getUser() {
return user; return user;
} }

View File

@@ -35,10 +35,12 @@ import org.glyptodon.guacamole.net.auth.permission.SystemPermissionSet;
import org.glyptodon.guacamole.net.auth.simple.SimpleObjectPermissionSet; import org.glyptodon.guacamole.net.auth.simple.SimpleObjectPermissionSet;
/** /**
* A MySQL based implementation of the User object. * An implementation of the User object which is backed by a database model.
*
* @author James Muehlner * @author James Muehlner
* @author Michael Jumper
*/ */
public class MySQLUser extends DirectoryObject<UserModel> implements User { public class ModeledUser extends DirectoryObject<UserModel> implements User {
/** /**
* Service for hashing passwords. * Service for hashing passwords.
@@ -68,9 +70,9 @@ public class MySQLUser extends DirectoryObject<UserModel> implements User {
private String password = null; private String password = null;
/** /**
* Creates a new, empty MySQLUser. * Creates a new, empty ModeledUser.
*/ */
public MySQLUser() { public ModeledUser() {
} }
@Override @Override

View File

@@ -23,7 +23,7 @@
package org.glyptodon.guacamole.auth.jdbc.user; package org.glyptodon.guacamole.auth.jdbc.user;
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.MySQLRootConnectionGroup; import org.glyptodon.guacamole.auth.jdbc.connectiongroup.RootConnectionGroup;
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ConnectionGroupDirectory; import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ConnectionGroupDirectory;
import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionDirectory; import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionDirectory;
import com.google.inject.Inject; import com.google.inject.Inject;
@@ -33,13 +33,16 @@ import org.glyptodon.guacamole.net.auth.Connection;
import org.glyptodon.guacamole.net.auth.ConnectionGroup; import org.glyptodon.guacamole.net.auth.ConnectionGroup;
import org.glyptodon.guacamole.net.auth.Directory; import org.glyptodon.guacamole.net.auth.Directory;
import org.glyptodon.guacamole.net.auth.User; import org.glyptodon.guacamole.net.auth.User;
import org.glyptodon.guacamole.net.auth.UserContext;
/** /**
* The MySQL representation of a UserContext. * UserContext implementation which is driven by an arbitrary, underlying
* database.
*
* @author James Muehlner * @author James Muehlner
* @author Michael Jumper
*/ */
public class MySQLUserContext implements UserContext { public class UserContext
implements org.glyptodon.guacamole.net.auth.UserContext {
/** /**
* The the user owning this context. * The the user owning this context.
@@ -71,7 +74,7 @@ public class MySQLUserContext implements UserContext {
* Provider for creating the root group. * Provider for creating the root group.
*/ */
@Inject @Inject
private Provider<MySQLRootConnectionGroup> rootGroupProvider; private Provider<RootConnectionGroup> rootGroupProvider;
/** /**
* Initializes the user and directories associated with this context. * Initializes the user and directories associated with this context.
@@ -114,7 +117,7 @@ public class MySQLUserContext implements UserContext {
public ConnectionGroup getRootConnectionGroup() throws GuacamoleException { public ConnectionGroup getRootConnectionGroup() throws GuacamoleException {
// Build and return a root group for the current user // Build and return a root group for the current user
MySQLRootConnectionGroup rootGroup = rootGroupProvider.get(); RootConnectionGroup rootGroup = rootGroupProvider.get();
rootGroup.init(currentUser); rootGroup.init(currentUser);
return rootGroup; return rootGroup;

View File

@@ -26,7 +26,6 @@ import com.google.inject.Inject;
import com.google.inject.Provider; import com.google.inject.Provider;
import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.net.auth.Credentials; import org.glyptodon.guacamole.net.auth.Credentials;
import org.glyptodon.guacamole.net.auth.UserContext;
/** /**
* Service which creates new UserContext instances for valid users based on * Service which creates new UserContext instances for valid users based on
@@ -46,7 +45,7 @@ public class UserContextService {
* Provider for retrieving UserContext instances. * Provider for retrieving UserContext instances.
*/ */
@Inject @Inject
private Provider<MySQLUserContext> userContextProvider; private Provider<UserContext> userContextProvider;
/** /**
* Authenticates the user having the given credentials, returning a new * Authenticates the user having the given credentials, returning a new
@@ -62,15 +61,16 @@ public class UserContextService {
* @throws GuacamoleException * @throws GuacamoleException
* If an error occurs during authentication. * If an error occurs during authentication.
*/ */
public UserContext getUserContext(Credentials credentials) public org.glyptodon.guacamole.net.auth.UserContext
throws GuacamoleException { getUserContext(Credentials credentials)
throws GuacamoleException {
// Authenticate user // Authenticate user
MySQLUser user = userService.retrieveUser(credentials); ModeledUser user = userService.retrieveUser(credentials);
if (user != null) { if (user != null) {
// Upon successful authentication, return new user context // Upon successful authentication, return new user context
MySQLUserContext context = userContextProvider.get(); UserContext context = userContextProvider.get();
context.init(user.getCurrentUser()); context.init(user.getCurrentUser());
return context; return context;

View File

@@ -33,7 +33,8 @@ import org.glyptodon.guacamole.net.auth.User;
import org.mybatis.guice.transactional.Transactional; import org.mybatis.guice.transactional.Transactional;
/** /**
* A MySQL based implementation of the User Directory. * Implementation of the User Directory which is driven by an underlying,
* arbitrary database.
* *
* @author James Muehlner * @author James Muehlner
* @author Michael Jumper * @author Michael Jumper
@@ -71,7 +72,7 @@ public class UserDirectory implements Directory<User> {
@Override @Override
@Transactional @Transactional
public Collection<User> getAll(Collection<String> identifiers) throws GuacamoleException { public Collection<User> getAll(Collection<String> identifiers) throws GuacamoleException {
Collection<MySQLUser> objects = userService.retrieveObjects(currentUser, identifiers); Collection<ModeledUser> objects = userService.retrieveObjects(currentUser, identifiers);
return Collections.<User>unmodifiableCollection(objects); return Collections.<User>unmodifiableCollection(objects);
} }
@@ -90,7 +91,7 @@ public class UserDirectory implements Directory<User> {
@Override @Override
@Transactional @Transactional
public void update(User object) throws GuacamoleException { public void update(User object) throws GuacamoleException {
MySQLUser user = (MySQLUser) object; ModeledUser user = (ModeledUser) object;
userService.updateObject(currentUser, user); userService.updateObject(currentUser, user);
} }

View File

@@ -42,7 +42,7 @@ import org.glyptodon.guacamole.net.auth.permission.SystemPermissionSet;
* *
* @author Michael Jumper, James Muehlner * @author Michael Jumper, James Muehlner
*/ */
public class UserService extends DirectoryObjectService<MySQLUser, User, UserModel> { public class UserService extends DirectoryObjectService<ModeledUser, User, UserModel> {
/** /**
* Mapper for accessing users. * Mapper for accessing users.
@@ -54,7 +54,7 @@ public class UserService extends DirectoryObjectService<MySQLUser, User, UserMod
* Provider for creating users. * Provider for creating users.
*/ */
@Inject @Inject
private Provider<MySQLUser> mySQLUserProvider; private Provider<ModeledUser> userProvider;
@Override @Override
protected DirectoryObjectMapper<UserModel> getObjectMapper() { protected DirectoryObjectMapper<UserModel> getObjectMapper() {
@@ -62,9 +62,9 @@ public class UserService extends DirectoryObjectService<MySQLUser, User, UserMod
} }
@Override @Override
protected MySQLUser getObjectInstance(AuthenticatedUser currentUser, protected ModeledUser getObjectInstance(AuthenticatedUser currentUser,
UserModel model) { UserModel model) {
MySQLUser user = mySQLUserProvider.get(); ModeledUser user = userProvider.get();
user.init(currentUser, model); user.init(currentUser, model);
return user; return user;
} }
@@ -73,11 +73,11 @@ public class UserService extends DirectoryObjectService<MySQLUser, User, UserMod
protected UserModel getModelInstance(AuthenticatedUser currentUser, protected UserModel getModelInstance(AuthenticatedUser currentUser,
final User object) { final User object) {
// Create new MySQLUser backed by blank model // Create new ModeledUser backed by blank model
UserModel model = new UserModel(); UserModel model = new UserModel();
MySQLUser user = getObjectInstance(currentUser, model); ModeledUser user = getObjectInstance(currentUser, model);
// Set model contents through MySQLUser, copying the provided user // Set model contents through ModeledUser, copying the provided user
user.setIdentifier(object.getIdentifier()); user.setIdentifier(object.getIdentifier());
user.setPassword(object.getPassword()); user.setPassword(object.getPassword());
@@ -121,14 +121,14 @@ public class UserService extends DirectoryObjectService<MySQLUser, User, UserMod
@Override @Override
protected void validateExistingObject(AuthenticatedUser user, protected void validateExistingObject(AuthenticatedUser user,
MySQLUser object) throws GuacamoleException { ModeledUser object) throws GuacamoleException {
// Username must not be blank // Username must not be blank
if (object.getIdentifier().trim().isEmpty()) if (object.getIdentifier().trim().isEmpty())
throw new GuacamoleClientException("The username must not be blank."); throw new GuacamoleClientException("The username must not be blank.");
// Check whether such a user is already present // Check whether such a user is already present
MySQLUser existing = retrieveObject(user, object.getIdentifier()); ModeledUser existing = retrieveObject(user, object.getIdentifier());
if (existing != null) { if (existing != null) {
UserModel existingModel = existing.getModel(); UserModel existingModel = existing.getModel();
@@ -146,11 +146,14 @@ public class UserService extends DirectoryObjectService<MySQLUser, User, UserMod
* Retrieves the user corresponding to the given credentials from the * Retrieves the user corresponding to the given credentials from the
* database. * database.
* *
* @param credentials The credentials to use when locating the user. * @param credentials
* @return The existing MySQLUser object if the credentials given are * The credentials to use when locating the user.
* valid, null otherwise. *
* @return
* The existing ModeledUser object if the credentials given are valid,
* null otherwise.
*/ */
public MySQLUser retrieveUser(Credentials credentials) { public ModeledUser retrieveUser(Credentials credentials) {
// Get username and password // Get username and password
String username = credentials.getUsername(); String username = credentials.getUsername();
@@ -162,7 +165,7 @@ public class UserService extends DirectoryObjectService<MySQLUser, User, UserMod
return null; return null;
// Return corresponding user, set up cyclic reference // Return corresponding user, set up cyclic reference
MySQLUser user = getObjectInstance(null, userModel); ModeledUser user = getObjectInstance(null, userModel);
user.setCurrentUser(new AuthenticatedUser(user, credentials)); user.setCurrentUser(new AuthenticatedUser(user, credentials));
return user; return user;