mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-1101: Remove mention of MySQL from generic JDBC code.
This commit is contained in:
@@ -22,15 +22,15 @@
|
||||
|
||||
package org.glyptodon.guacamole.auth.jdbc;
|
||||
|
||||
import org.glyptodon.guacamole.auth.jdbc.user.MySQLUserContext;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.MySQLRootConnectionGroup;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.MySQLConnectionGroup;
|
||||
import org.glyptodon.guacamole.auth.jdbc.user.UserContext;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.RootConnectionGroup;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ModeledConnectionGroup;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ConnectionGroupDirectory;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionDirectory;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connection.MySQLGuacamoleConfiguration;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connection.MySQLConnection;
|
||||
import org.glyptodon.guacamole.auth.jdbc.permission.MySQLSystemPermissionSet;
|
||||
import org.glyptodon.guacamole.auth.jdbc.user.MySQLUser;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connection.ModeledGuacamoleConfiguration;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connection.ModeledConnection;
|
||||
import org.glyptodon.guacamole.auth.jdbc.permission.SystemPermissionSet;
|
||||
import org.glyptodon.guacamole.auth.jdbc.user.ModeledUser;
|
||||
import org.glyptodon.guacamole.auth.jdbc.user.UserDirectory;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ConnectionGroupMapper;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionMapper;
|
||||
@@ -100,13 +100,13 @@ public class JDBCAuthenticationProviderModule extends MyBatisModule {
|
||||
bind(Environment.class).toInstance(environment);
|
||||
bind(ConnectionDirectory.class);
|
||||
bind(ConnectionGroupDirectory.class);
|
||||
bind(MySQLConnection.class);
|
||||
bind(MySQLConnectionGroup.class);
|
||||
bind(MySQLGuacamoleConfiguration.class);
|
||||
bind(MySQLUser.class);
|
||||
bind(MySQLUserContext.class);
|
||||
bind(MySQLRootConnectionGroup.class);
|
||||
bind(MySQLSystemPermissionSet.class);
|
||||
bind(ModeledConnection.class);
|
||||
bind(ModeledConnectionGroup.class);
|
||||
bind(ModeledGuacamoleConfiguration.class);
|
||||
bind(ModeledUser.class);
|
||||
bind(RootConnectionGroup.class);
|
||||
bind(SystemPermissionSet.class);
|
||||
bind(UserContext.class);
|
||||
bind(UserDirectory.class);
|
||||
|
||||
// Bind services
|
||||
|
@@ -21,8 +21,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base classes supporting the MySQL authentication provider and defining the
|
||||
* relationships between the model and the implementations of guacamole-ext
|
||||
* Base classes supporting JDBC-driven authentication providers and defining
|
||||
* the relationships between the model and the implementations of guacamole-ext
|
||||
* classes.
|
||||
*/
|
||||
package org.glyptodon.guacamole.auth.jdbc.base;
|
||||
|
@@ -34,7 +34,8 @@ import org.glyptodon.guacamole.net.auth.Directory;
|
||||
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 Michael Jumper
|
||||
@@ -72,7 +73,7 @@ public class ConnectionDirectory implements Directory<Connection> {
|
||||
@Override
|
||||
@Transactional
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ public class ConnectionDirectory implements Directory<Connection> {
|
||||
@Override
|
||||
@Transactional
|
||||
public void update(Connection object) throws GuacamoleException {
|
||||
MySQLConnection connection = (MySQLConnection) object;
|
||||
ModeledConnection connection = (ModeledConnection) object;
|
||||
connectionService.updateObject(currentUser, connection);
|
||||
}
|
||||
|
||||
|
@@ -52,7 +52,7 @@ import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;
|
||||
*
|
||||
* @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.
|
||||
@@ -76,7 +76,7 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
|
||||
* Provider for creating connections.
|
||||
*/
|
||||
@Inject
|
||||
private Provider<MySQLConnection> mySQLConnectionProvider;
|
||||
private Provider<ModeledConnection> connectionProvider;
|
||||
|
||||
/**
|
||||
* Service for creating and tracking sockets.
|
||||
@@ -90,9 +90,9 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MySQLConnection getObjectInstance(AuthenticatedUser currentUser,
|
||||
protected ModeledConnection getObjectInstance(AuthenticatedUser currentUser,
|
||||
ConnectionModel model) {
|
||||
MySQLConnection connection = mySQLConnectionProvider.get();
|
||||
ModeledConnection connection = connectionProvider.get();
|
||||
connection.init(currentUser, model);
|
||||
return connection;
|
||||
}
|
||||
@@ -101,11 +101,11 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
|
||||
protected ConnectionModel getModelInstance(AuthenticatedUser currentUser,
|
||||
final Connection object) {
|
||||
|
||||
// Create new MySQLConnection backed by blank model
|
||||
// Create new ModeledConnection backed by blank model
|
||||
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.setName(object.getName());
|
||||
connection.setConfiguration(object.getConfiguration());
|
||||
@@ -147,7 +147,7 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
|
||||
|
||||
@Override
|
||||
protected void validateExistingObject(AuthenticatedUser user,
|
||||
MySQLConnection object) throws GuacamoleException {
|
||||
ModeledConnection object) throws GuacamoleException {
|
||||
|
||||
// Name must not be blank
|
||||
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
|
||||
* 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();
|
||||
|
||||
@@ -202,11 +202,11 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
|
||||
}
|
||||
|
||||
@Override
|
||||
public MySQLConnection createObject(AuthenticatedUser user, Connection object)
|
||||
public ModeledConnection createObject(AuthenticatedUser user, Connection object)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Create connection
|
||||
MySQLConnection connection = super.createObject(user, object);
|
||||
ModeledConnection connection = super.createObject(user, object);
|
||||
connection.setConfiguration(object.getConfiguration());
|
||||
|
||||
// Insert new parameters, if any
|
||||
@@ -219,7 +219,7 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateObject(AuthenticatedUser user, MySQLConnection object)
|
||||
public void updateObject(AuthenticatedUser user, ModeledConnection object)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Update connection
|
||||
@@ -330,7 +330,7 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
|
||||
* If permission to read the connection history is denied.
|
||||
*/
|
||||
public List<ConnectionRecord> retrieveHistory(AuthenticatedUser user,
|
||||
MySQLConnection connection) throws GuacamoleException {
|
||||
ModeledConnection connection) throws GuacamoleException {
|
||||
|
||||
String identifier = connection.getIdentifier();
|
||||
|
||||
@@ -345,7 +345,7 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
|
||||
|
||||
// Add past connections from model objects
|
||||
for (ConnectionRecordModel model : models)
|
||||
records.add(new MySQLConnectionRecord(model));
|
||||
records.add(new ModeledConnectionRecord(model));
|
||||
|
||||
// Return converted history list
|
||||
return records;
|
||||
@@ -379,7 +379,7 @@ public class ConnectionService extends DirectoryObjectService<MySQLConnection, C
|
||||
* If permission to connect to this connection is denied.
|
||||
*/
|
||||
public GuacamoleSocket connect(AuthenticatedUser user,
|
||||
MySQLConnection connection, GuacamoleClientInformation info)
|
||||
ModeledConnection connection, GuacamoleClientInformation info)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Connect only if READ permission is granted
|
||||
|
@@ -26,7 +26,7 @@ import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import java.util.List;
|
||||
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.GuacamoleException;
|
||||
import org.glyptodon.guacamole.net.GuacamoleSocket;
|
||||
@@ -36,10 +36,13 @@ import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;
|
||||
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 Michael Jumper
|
||||
*/
|
||||
public class MySQLConnection extends DirectoryObject<ConnectionModel>
|
||||
public class ModeledConnection extends DirectoryObject<ConnectionModel>
|
||||
implements Connection {
|
||||
|
||||
/**
|
||||
@@ -58,7 +61,7 @@ public class MySQLConnection extends DirectoryObject<ConnectionModel>
|
||||
* Provider for lazy-loaded, permission-controlled configurations.
|
||||
*/
|
||||
@Inject
|
||||
private Provider<MySQLGuacamoleConfiguration> configProvider;
|
||||
private Provider<ModeledGuacamoleConfiguration> configProvider;
|
||||
|
||||
/**
|
||||
* The manually-set GuacamoleConfiguration, if any.
|
||||
@@ -66,9 +69,9 @@ public class MySQLConnection extends DirectoryObject<ConnectionModel>
|
||||
private GuacamoleConfiguration config = null;
|
||||
|
||||
/**
|
||||
* Creates a new, empty MySQLConnection.
|
||||
* Creates a new, empty ModeledConnection.
|
||||
*/
|
||||
public MySQLConnection() {
|
||||
public ModeledConnection() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,7 +90,7 @@ public class MySQLConnection extends DirectoryObject<ConnectionModel>
|
||||
// Translate null parent to proper identifier
|
||||
String parentIdentifier = getModel().getParentIdentifier();
|
||||
if (parentIdentifier == null)
|
||||
return MySQLRootConnectionGroup.IDENTIFIER;
|
||||
return RootConnectionGroup.IDENTIFIER;
|
||||
|
||||
return parentIdentifier;
|
||||
|
||||
@@ -98,7 +101,7 @@ public class MySQLConnection extends DirectoryObject<ConnectionModel>
|
||||
|
||||
// Translate root identifier back into null
|
||||
if (parentIdentifier != null
|
||||
&& parentIdentifier.equals(MySQLRootConnectionGroup.IDENTIFIER))
|
||||
&& parentIdentifier.equals(RootConnectionGroup.IDENTIFIER))
|
||||
parentIdentifier = null;
|
||||
|
||||
getModel().setParentIdentifier(parentIdentifier);
|
||||
@@ -113,7 +116,7 @@ public class MySQLConnection extends DirectoryObject<ConnectionModel>
|
||||
return config;
|
||||
|
||||
// Otherwise, return permission-controlled configuration
|
||||
MySQLGuacamoleConfiguration restrictedConfig = configProvider.get();
|
||||
ModeledGuacamoleConfiguration restrictedConfig = configProvider.get();
|
||||
restrictedConfig.init(getCurrentUser(), getModel());
|
||||
return restrictedConfig;
|
||||
|
@@ -27,27 +27,27 @@ import java.util.Date;
|
||||
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 Michael Jumper
|
||||
*/
|
||||
public class MySQLConnectionRecord implements ConnectionRecord {
|
||||
public class ModeledConnectionRecord implements ConnectionRecord {
|
||||
|
||||
/**
|
||||
* 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
|
||||
* to the backing model object will affect this record.
|
||||
*
|
||||
* @param model
|
||||
* The model object to use to back this connection record.
|
||||
*/
|
||||
public MySQLConnectionRecord(ConnectionRecordModel model) {
|
||||
public ModeledConnectionRecord(ConnectionRecordModel model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ import org.glyptodon.guacamole.protocol.GuacamoleConfiguration;
|
||||
*
|
||||
* @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
|
||||
@@ -59,9 +59,9 @@ public class MySQLGuacamoleConfiguration extends GuacamoleConfiguration {
|
||||
private Map<String, String> parameters = null;
|
||||
|
||||
/**
|
||||
* Creates a new, empty MySQLGuacamoleConfiguration.
|
||||
* Creates a new, empty ModelGuacamoleConfiguration.
|
||||
*/
|
||||
public MySQLGuacamoleConfiguration() {
|
||||
public ModeledGuacamoleConfiguration() {
|
||||
}
|
||||
|
||||
/**
|
@@ -34,7 +34,8 @@ import org.glyptodon.guacamole.net.auth.Directory;
|
||||
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 Michael Jumper
|
||||
@@ -72,7 +73,7 @@ public class ConnectionGroupDirectory implements Directory<ConnectionGroup> {
|
||||
@Override
|
||||
@Transactional
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ public class ConnectionGroupDirectory implements Directory<ConnectionGroup> {
|
||||
@Override
|
||||
@Transactional
|
||||
public void update(ConnectionGroup object) throws GuacamoleException {
|
||||
MySQLConnectionGroup connectionGroup = (MySQLConnectionGroup) object;
|
||||
ModeledConnectionGroup connectionGroup = (ModeledConnectionGroup) object;
|
||||
connectionGroupService.updateObject(currentUser, connectionGroup);
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,7 @@ import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;
|
||||
*
|
||||
* @author Michael Jumper, James Muehlner
|
||||
*/
|
||||
public class ConnectionGroupService extends DirectoryObjectService<MySQLConnectionGroup,
|
||||
public class ConnectionGroupService extends DirectoryObjectService<ModeledConnectionGroup,
|
||||
ConnectionGroup, ConnectionGroupModel> {
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ public class ConnectionGroupService extends DirectoryObjectService<MySQLConnecti
|
||||
* Provider for creating connection groups.
|
||||
*/
|
||||
@Inject
|
||||
private Provider<MySQLConnectionGroup> connectionGroupProvider;
|
||||
private Provider<ModeledConnectionGroup> connectionGroupProvider;
|
||||
|
||||
/**
|
||||
* Service for creating and tracking sockets.
|
||||
@@ -73,9 +73,9 @@ public class ConnectionGroupService extends DirectoryObjectService<MySQLConnecti
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MySQLConnectionGroup getObjectInstance(AuthenticatedUser currentUser,
|
||||
protected ModeledConnectionGroup getObjectInstance(AuthenticatedUser currentUser,
|
||||
ConnectionGroupModel model) {
|
||||
MySQLConnectionGroup connectionGroup = connectionGroupProvider.get();
|
||||
ModeledConnectionGroup connectionGroup = connectionGroupProvider.get();
|
||||
connectionGroup.init(currentUser, model);
|
||||
return connectionGroup;
|
||||
}
|
||||
@@ -84,11 +84,11 @@ public class ConnectionGroupService extends DirectoryObjectService<MySQLConnecti
|
||||
protected ConnectionGroupModel getModelInstance(AuthenticatedUser currentUser,
|
||||
final ConnectionGroup object) {
|
||||
|
||||
// Create new MySQLConnectionGroup backed by blank model
|
||||
// Create new ModeledConnectionGroup backed by blank model
|
||||
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.setName(object.getName());
|
||||
connectionGroup.setType(object.getType());
|
||||
@@ -130,7 +130,7 @@ public class ConnectionGroupService extends DirectoryObjectService<MySQLConnecti
|
||||
|
||||
@Override
|
||||
protected void validateExistingObject(AuthenticatedUser user,
|
||||
MySQLConnectionGroup object) throws GuacamoleException {
|
||||
ModeledConnectionGroup object) throws GuacamoleException {
|
||||
|
||||
// Name must not be blank
|
||||
if (object.getName().trim().isEmpty())
|
||||
@@ -199,7 +199,7 @@ public class ConnectionGroupService extends DirectoryObjectService<MySQLConnecti
|
||||
* If permission to connect to this connection is denied.
|
||||
*/
|
||||
public GuacamoleSocket connect(AuthenticatedUser user,
|
||||
MySQLConnectionGroup connectionGroup, GuacamoleClientInformation info)
|
||||
ModeledConnectionGroup connectionGroup, GuacamoleClientInformation info)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Connect only if READ permission is granted
|
||||
|
@@ -33,11 +33,12 @@ import org.glyptodon.guacamole.net.auth.ConnectionGroup;
|
||||
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
|
||||
*/
|
||||
public class MySQLConnectionGroup extends DirectoryObject<ConnectionGroupModel>
|
||||
public class ModeledConnectionGroup extends DirectoryObject<ConnectionGroupModel>
|
||||
implements ConnectionGroup {
|
||||
|
||||
/**
|
||||
@@ -59,9 +60,9 @@ public class MySQLConnectionGroup extends DirectoryObject<ConnectionGroupModel>
|
||||
private GuacamoleSocketService socketService;
|
||||
|
||||
/**
|
||||
* Creates a new, empty MySQLConnection.
|
||||
* Creates a new, empty ModeledConnectionGroup.
|
||||
*/
|
||||
public MySQLConnectionGroup() {
|
||||
public ModeledConnectionGroup() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,7 +81,7 @@ public class MySQLConnectionGroup extends DirectoryObject<ConnectionGroupModel>
|
||||
// Translate null parent to proper identifier
|
||||
String parentIdentifier = getModel().getParentIdentifier();
|
||||
if (parentIdentifier == null)
|
||||
return MySQLRootConnectionGroup.IDENTIFIER;
|
||||
return RootConnectionGroup.IDENTIFIER;
|
||||
|
||||
return parentIdentifier;
|
||||
|
||||
@@ -91,7 +92,7 @@ public class MySQLConnectionGroup extends DirectoryObject<ConnectionGroupModel>
|
||||
|
||||
// Translate root identifier back into null
|
||||
if (parentIdentifier != null
|
||||
&& parentIdentifier.equals(MySQLRootConnectionGroup.IDENTIFIER))
|
||||
&& parentIdentifier.equals(RootConnectionGroup.IDENTIFIER))
|
||||
parentIdentifier = null;
|
||||
|
||||
getModel().setParentIdentifier(parentIdentifier);
|
@@ -38,7 +38,7 @@ import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;
|
||||
*
|
||||
* @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
|
||||
@@ -73,9 +73,9 @@ public class MySQLRootConnectionGroup implements ConnectionGroup {
|
||||
private ConnectionGroupService connectionGroupService;
|
||||
|
||||
/**
|
||||
* Creates a new, empty MySQLRootConnectionGroup.
|
||||
* Creates a new, empty RootConnectionGroup.
|
||||
*/
|
||||
public MySQLRootConnectionGroup() {
|
||||
public RootConnectionGroup() {
|
||||
}
|
||||
|
||||
/**
|
@@ -26,7 +26,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
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.GuacamoleSecurityException;
|
||||
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
|
||||
* 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)
|
||||
throws GuacamoleException {
|
||||
|
||||
@@ -123,7 +123,7 @@ public abstract class ObjectPermissionService<ModelType>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createPermissions(AuthenticatedUser user, MySQLUser targetUser,
|
||||
public void createPermissions(AuthenticatedUser user, ModeledUser targetUser,
|
||||
Collection<ObjectPermission> permissions)
|
||||
throws GuacamoleException {
|
||||
|
||||
@@ -140,7 +140,7 @@ public abstract class ObjectPermissionService<ModelType>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePermissions(AuthenticatedUser user, MySQLUser targetUser,
|
||||
public void deletePermissions(AuthenticatedUser user, ModeledUser targetUser,
|
||||
Collection<ObjectPermission> permissions)
|
||||
throws GuacamoleException {
|
||||
|
||||
|
@@ -27,7 +27,7 @@ import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
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.GuacamoleSecurityException;
|
||||
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
|
||||
* user.
|
||||
*/
|
||||
protected abstract ModelType getModelInstance(MySQLUser targetUser,
|
||||
protected abstract ModelType getModelInstance(ModeledUser targetUser,
|
||||
PermissionType permission);
|
||||
|
||||
/**
|
||||
@@ -129,7 +129,7 @@ public abstract class PermissionService<PermissionSetType extends PermissionSet<
|
||||
* A collection of model objects which are based on the given
|
||||
* permissions and target user.
|
||||
*/
|
||||
protected Collection<ModelType> getModelInstances(MySQLUser targetUser,
|
||||
protected Collection<ModelType> getModelInstances(ModeledUser targetUser,
|
||||
Collection<PermissionType> permissions) {
|
||||
|
||||
// Create new collection of models by manually converting each permission
|
||||
@@ -163,7 +163,7 @@ public abstract class PermissionService<PermissionSetType extends PermissionSet<
|
||||
* user is denied.
|
||||
*/
|
||||
public abstract PermissionSetType getPermissionSet(AuthenticatedUser user,
|
||||
MySQLUser targetUser) throws GuacamoleException;
|
||||
ModeledUser targetUser) throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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
|
||||
if (user.getUser().getIdentifier().equals(targetUser.getIdentifier())
|
||||
@@ -211,7 +211,7 @@ public abstract class PermissionService<PermissionSetType extends PermissionSet<
|
||||
* occurs while creating the permissions.
|
||||
*/
|
||||
public abstract void createPermissions(AuthenticatedUser user,
|
||||
MySQLUser targetUser,
|
||||
ModeledUser targetUser,
|
||||
Collection<PermissionType> permissions) throws GuacamoleException;
|
||||
|
||||
/**
|
||||
@@ -232,7 +232,7 @@ public abstract class PermissionService<PermissionSetType extends PermissionSet<
|
||||
* occurs while deleting the permissions.
|
||||
*/
|
||||
public abstract void deletePermissions(AuthenticatedUser user,
|
||||
MySQLUser targetUser,
|
||||
ModeledUser targetUser,
|
||||
Collection<PermissionType> permissions) throws GuacamoleException;
|
||||
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import java.util.Collection;
|
||||
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.GuacamoleSecurityException;
|
||||
import org.glyptodon.guacamole.net.auth.permission.SystemPermission;
|
||||
@@ -39,7 +39,7 @@ import org.glyptodon.guacamole.net.auth.permission.SystemPermission;
|
||||
* @author Michael Jumper
|
||||
*/
|
||||
public class SystemPermissionService
|
||||
extends PermissionService<MySQLSystemPermissionSet, SystemPermission, SystemPermissionModel> {
|
||||
extends PermissionService<SystemPermissionSet, SystemPermission, SystemPermissionModel> {
|
||||
|
||||
/**
|
||||
* Mapper for system-level permissions.
|
||||
@@ -51,7 +51,7 @@ public class SystemPermissionService
|
||||
* Provider for creating system permission sets.
|
||||
*/
|
||||
@Inject
|
||||
private Provider<MySQLSystemPermissionSet> systemPermissionSetProvider;
|
||||
private Provider<SystemPermissionSet> systemPermissionSetProvider;
|
||||
|
||||
@Override
|
||||
protected SystemPermissionMapper getPermissionMapper() {
|
||||
@@ -64,7 +64,7 @@ public class SystemPermissionService
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SystemPermissionModel getModelInstance(final MySQLUser targetUser,
|
||||
protected SystemPermissionModel getModelInstance(final ModeledUser targetUser,
|
||||
final SystemPermission permission) {
|
||||
|
||||
SystemPermissionModel model = new SystemPermissionModel();
|
||||
@@ -79,11 +79,11 @@ public class SystemPermissionService
|
||||
}
|
||||
|
||||
@Override
|
||||
public MySQLSystemPermissionSet getPermissionSet(AuthenticatedUser user,
|
||||
MySQLUser targetUser) throws GuacamoleException {
|
||||
public SystemPermissionSet getPermissionSet(AuthenticatedUser user,
|
||||
ModeledUser targetUser) throws GuacamoleException {
|
||||
|
||||
// Create permission set for requested user
|
||||
MySQLSystemPermissionSet permissionSet = systemPermissionSetProvider.get();
|
||||
SystemPermissionSet permissionSet = systemPermissionSetProvider.get();
|
||||
permissionSet.init(user, targetUser);
|
||||
|
||||
return permissionSet;
|
||||
@@ -91,7 +91,7 @@ public class SystemPermissionService
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createPermissions(AuthenticatedUser user, MySQLUser targetUser,
|
||||
public void createPermissions(AuthenticatedUser user, ModeledUser targetUser,
|
||||
Collection<SystemPermission> permissions) throws GuacamoleException {
|
||||
|
||||
// Only an admin can create system permissions
|
||||
@@ -107,7 +107,7 @@ public class SystemPermissionService
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePermissions(AuthenticatedUser user, MySQLUser targetUser,
|
||||
public void deletePermissions(AuthenticatedUser user, ModeledUser targetUser,
|
||||
Collection<SystemPermission> permissions) throws GuacamoleException {
|
||||
|
||||
// Only an admin can delete system permissions
|
||||
@@ -143,7 +143,7 @@ public class SystemPermissionService
|
||||
* If an error occurs while retrieving the requested permission.
|
||||
*/
|
||||
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
|
||||
if (user.getUser().getIdentifier().equals(targetUser.getIdentifier())
|
||||
|
@@ -22,14 +22,13 @@
|
||||
|
||||
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 java.util.Collections;
|
||||
import java.util.Set;
|
||||
import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser;
|
||||
import org.glyptodon.guacamole.GuacamoleException;
|
||||
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
|
||||
@@ -38,7 +37,8 @@ import org.glyptodon.guacamole.net.auth.permission.SystemPermissionSet;
|
||||
*
|
||||
* @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
|
||||
@@ -50,7 +50,7 @@ public class MySQLSystemPermissionSet implements SystemPermissionSet {
|
||||
* The user associated with this permission set. Each of the permissions in
|
||||
* this permission set is granted to this user.
|
||||
*/
|
||||
private MySQLUser user;
|
||||
private ModeledUser user;
|
||||
|
||||
/**
|
||||
* Service for reading and manipulating system permissions.
|
||||
@@ -59,11 +59,11 @@ public class MySQLSystemPermissionSet implements SystemPermissionSet {
|
||||
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
|
||||
* 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
|
||||
* 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.user = user;
|
||||
}
|
@@ -31,8 +31,8 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connection.MySQLConnection;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.MySQLConnectionGroup;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connection.ModeledConnection;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ModeledConnectionGroup;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionRecordMapper;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connection.ParameterMapper;
|
||||
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.
|
||||
*/
|
||||
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
|
||||
@@ -168,11 +168,11 @@ public abstract class AbstractGuacamoleSocketService implements GuacamoleSocketS
|
||||
* The connection being released.
|
||||
*/
|
||||
protected abstract void release(AuthenticatedUser user,
|
||||
MySQLConnection connection);
|
||||
ModeledConnection connection);
|
||||
|
||||
@Override
|
||||
public GuacamoleSocket getGuacamoleSocket(final AuthenticatedUser user,
|
||||
final MySQLConnection connection, GuacamoleClientInformation info)
|
||||
final ModeledConnection connection, GuacamoleClientInformation info)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Create record for active connection
|
||||
@@ -273,7 +273,7 @@ public abstract class AbstractGuacamoleSocketService implements GuacamoleSocketS
|
||||
|
||||
@Override
|
||||
public GuacamoleSocket getGuacamoleSocket(AuthenticatedUser user,
|
||||
MySQLConnectionGroup connectionGroup,
|
||||
ModeledConnectionGroup connectionGroup,
|
||||
GuacamoleClientInformation info) throws GuacamoleException {
|
||||
// STUB
|
||||
throw new UnsupportedOperationException("STUB");
|
||||
|
@@ -24,8 +24,8 @@ package org.glyptodon.guacamole.auth.jdbc.socket;
|
||||
|
||||
import java.util.List;
|
||||
import org.glyptodon.guacamole.auth.jdbc.user.AuthenticatedUser;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connection.MySQLConnection;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.MySQLConnectionGroup;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connection.ModeledConnection;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ModeledConnectionGroup;
|
||||
import org.glyptodon.guacamole.GuacamoleException;
|
||||
import org.glyptodon.guacamole.net.GuacamoleSocket;
|
||||
import org.glyptodon.guacamole.net.auth.Connection;
|
||||
@@ -68,7 +68,7 @@ public interface GuacamoleSocketService {
|
||||
* rules.
|
||||
*/
|
||||
GuacamoleSocket getGuacamoleSocket(AuthenticatedUser user,
|
||||
MySQLConnection connection, GuacamoleClientInformation info)
|
||||
ModeledConnection connection, GuacamoleClientInformation info)
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
@@ -111,7 +111,7 @@ public interface GuacamoleSocketService {
|
||||
* rules, or if the connection group is not balancing.
|
||||
*/
|
||||
GuacamoleSocket getGuacamoleSocket(AuthenticatedUser user,
|
||||
MySQLConnectionGroup connectionGroup,
|
||||
ModeledConnectionGroup connectionGroup,
|
||||
GuacamoleClientInformation info)
|
||||
throws GuacamoleException;
|
||||
|
||||
|
@@ -24,7 +24,7 @@ package org.glyptodon.guacamole.auth.jdbc.socket;
|
||||
|
||||
import com.google.inject.Singleton;
|
||||
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;
|
||||
|
||||
|
||||
@@ -39,13 +39,13 @@ public class UnrestrictedGuacamoleSocketService
|
||||
extends AbstractGuacamoleSocketService {
|
||||
|
||||
@Override
|
||||
protected void acquire(AuthenticatedUser user, MySQLConnection connection)
|
||||
protected void acquire(AuthenticatedUser user, ModeledConnection connection)
|
||||
throws GuacamoleException {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void release(AuthenticatedUser user, MySQLConnection connection) {
|
||||
protected void release(AuthenticatedUser user, ModeledConnection connection) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,7 @@ public class AuthenticatedUser {
|
||||
/**
|
||||
* The user that authenticated.
|
||||
*/
|
||||
private final MySQLUser user;
|
||||
private final ModeledUser user;
|
||||
|
||||
/**
|
||||
* The credentials given when this user authenticated.
|
||||
@@ -51,7 +51,7 @@ public class AuthenticatedUser {
|
||||
* @param credentials
|
||||
* 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.credentials = credentials;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class AuthenticatedUser {
|
||||
* @return
|
||||
* The user that authenticated.
|
||||
*/
|
||||
public MySQLUser getUser() {
|
||||
public ModeledUser getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
|
@@ -35,10 +35,12 @@ import org.glyptodon.guacamole.net.auth.permission.SystemPermissionSet;
|
||||
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 Michael Jumper
|
||||
*/
|
||||
public class MySQLUser extends DirectoryObject<UserModel> implements User {
|
||||
public class ModeledUser extends DirectoryObject<UserModel> implements User {
|
||||
|
||||
/**
|
||||
* Service for hashing passwords.
|
||||
@@ -68,9 +70,9 @@ public class MySQLUser extends DirectoryObject<UserModel> implements User {
|
||||
private String password = null;
|
||||
|
||||
/**
|
||||
* Creates a new, empty MySQLUser.
|
||||
* Creates a new, empty ModeledUser.
|
||||
*/
|
||||
public MySQLUser() {
|
||||
public ModeledUser() {
|
||||
}
|
||||
|
||||
@Override
|
@@ -23,7 +23,7 @@
|
||||
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.connection.ConnectionDirectory;
|
||||
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.Directory;
|
||||
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 Michael Jumper
|
||||
*/
|
||||
public class MySQLUserContext implements UserContext {
|
||||
public class UserContext
|
||||
implements org.glyptodon.guacamole.net.auth.UserContext {
|
||||
|
||||
/**
|
||||
* The the user owning this context.
|
||||
@@ -71,7 +74,7 @@ public class MySQLUserContext implements UserContext {
|
||||
* Provider for creating the root group.
|
||||
*/
|
||||
@Inject
|
||||
private Provider<MySQLRootConnectionGroup> rootGroupProvider;
|
||||
private Provider<RootConnectionGroup> rootGroupProvider;
|
||||
|
||||
/**
|
||||
* Initializes the user and directories associated with this context.
|
||||
@@ -114,7 +117,7 @@ public class MySQLUserContext implements UserContext {
|
||||
public ConnectionGroup getRootConnectionGroup() throws GuacamoleException {
|
||||
|
||||
// Build and return a root group for the current user
|
||||
MySQLRootConnectionGroup rootGroup = rootGroupProvider.get();
|
||||
RootConnectionGroup rootGroup = rootGroupProvider.get();
|
||||
rootGroup.init(currentUser);
|
||||
return rootGroup;
|
||||
|
@@ -26,7 +26,6 @@ import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import org.glyptodon.guacamole.GuacamoleException;
|
||||
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
|
||||
@@ -46,7 +45,7 @@ public class UserContextService {
|
||||
* Provider for retrieving UserContext instances.
|
||||
*/
|
||||
@Inject
|
||||
private Provider<MySQLUserContext> userContextProvider;
|
||||
private Provider<UserContext> userContextProvider;
|
||||
|
||||
/**
|
||||
* Authenticates the user having the given credentials, returning a new
|
||||
@@ -62,15 +61,16 @@ public class UserContextService {
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs during authentication.
|
||||
*/
|
||||
public UserContext getUserContext(Credentials credentials)
|
||||
throws GuacamoleException {
|
||||
public org.glyptodon.guacamole.net.auth.UserContext
|
||||
getUserContext(Credentials credentials)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Authenticate user
|
||||
MySQLUser user = userService.retrieveUser(credentials);
|
||||
ModeledUser user = userService.retrieveUser(credentials);
|
||||
if (user != null) {
|
||||
|
||||
// Upon successful authentication, return new user context
|
||||
MySQLUserContext context = userContextProvider.get();
|
||||
UserContext context = userContextProvider.get();
|
||||
context.init(user.getCurrentUser());
|
||||
return context;
|
||||
|
||||
|
@@ -33,7 +33,8 @@ import org.glyptodon.guacamole.net.auth.User;
|
||||
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 Michael Jumper
|
||||
@@ -71,7 +72,7 @@ public class UserDirectory implements Directory<User> {
|
||||
@Override
|
||||
@Transactional
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@ public class UserDirectory implements Directory<User> {
|
||||
@Override
|
||||
@Transactional
|
||||
public void update(User object) throws GuacamoleException {
|
||||
MySQLUser user = (MySQLUser) object;
|
||||
ModeledUser user = (ModeledUser) object;
|
||||
userService.updateObject(currentUser, user);
|
||||
}
|
||||
|
||||
|
@@ -42,7 +42,7 @@ import org.glyptodon.guacamole.net.auth.permission.SystemPermissionSet;
|
||||
*
|
||||
* @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.
|
||||
@@ -54,7 +54,7 @@ public class UserService extends DirectoryObjectService<MySQLUser, User, UserMod
|
||||
* Provider for creating users.
|
||||
*/
|
||||
@Inject
|
||||
private Provider<MySQLUser> mySQLUserProvider;
|
||||
private Provider<ModeledUser> userProvider;
|
||||
|
||||
@Override
|
||||
protected DirectoryObjectMapper<UserModel> getObjectMapper() {
|
||||
@@ -62,9 +62,9 @@ public class UserService extends DirectoryObjectService<MySQLUser, User, UserMod
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MySQLUser getObjectInstance(AuthenticatedUser currentUser,
|
||||
protected ModeledUser getObjectInstance(AuthenticatedUser currentUser,
|
||||
UserModel model) {
|
||||
MySQLUser user = mySQLUserProvider.get();
|
||||
ModeledUser user = userProvider.get();
|
||||
user.init(currentUser, model);
|
||||
return user;
|
||||
}
|
||||
@@ -73,11 +73,11 @@ public class UserService extends DirectoryObjectService<MySQLUser, User, UserMod
|
||||
protected UserModel getModelInstance(AuthenticatedUser currentUser,
|
||||
final User object) {
|
||||
|
||||
// Create new MySQLUser backed by blank model
|
||||
// Create new ModeledUser backed by blank model
|
||||
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.setPassword(object.getPassword());
|
||||
|
||||
@@ -121,14 +121,14 @@ public class UserService extends DirectoryObjectService<MySQLUser, User, UserMod
|
||||
|
||||
@Override
|
||||
protected void validateExistingObject(AuthenticatedUser user,
|
||||
MySQLUser object) throws GuacamoleException {
|
||||
ModeledUser object) throws GuacamoleException {
|
||||
|
||||
// Username must not be blank
|
||||
if (object.getIdentifier().trim().isEmpty())
|
||||
throw new GuacamoleClientException("The username must not be blank.");
|
||||
|
||||
// Check whether such a user is already present
|
||||
MySQLUser existing = retrieveObject(user, object.getIdentifier());
|
||||
ModeledUser existing = retrieveObject(user, object.getIdentifier());
|
||||
if (existing != null) {
|
||||
|
||||
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
|
||||
* database.
|
||||
*
|
||||
* @param credentials The credentials to use when locating the user.
|
||||
* @return The existing MySQLUser object if the credentials given are
|
||||
* valid, null otherwise.
|
||||
* @param credentials
|
||||
* The credentials to use when locating the user.
|
||||
*
|
||||
* @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
|
||||
String username = credentials.getUsername();
|
||||
@@ -162,7 +165,7 @@ public class UserService extends DirectoryObjectService<MySQLUser, User, UserMod
|
||||
return null;
|
||||
|
||||
// Return corresponding user, set up cyclic reference
|
||||
MySQLUser user = getObjectInstance(null, userModel);
|
||||
ModeledUser user = getObjectInstance(null, userModel);
|
||||
user.setCurrentUser(new AuthenticatedUser(user, credentials));
|
||||
return user;
|
||||
|
||||
|
Reference in New Issue
Block a user