mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUAC-586: Associate AuthenticationProvider directly with UserContext.
This commit is contained in:
@@ -63,6 +63,7 @@ import org.glyptodon.guacamole.auth.jdbc.activeconnection.ActiveConnectionPermis
|
||||
import org.glyptodon.guacamole.auth.jdbc.activeconnection.ActiveConnectionService;
|
||||
import org.glyptodon.guacamole.auth.jdbc.activeconnection.TrackedActiveConnection;
|
||||
import org.glyptodon.guacamole.environment.Environment;
|
||||
import org.glyptodon.guacamole.net.auth.AuthenticationProvider;
|
||||
import org.mybatis.guice.MyBatisModule;
|
||||
import org.mybatis.guice.datasource.builtin.PooledDataSourceProvider;
|
||||
|
||||
@@ -86,19 +87,31 @@ public class JDBCAuthenticationProviderModule extends MyBatisModule {
|
||||
*/
|
||||
private final GuacamoleTunnelService tunnelService;
|
||||
|
||||
/**
|
||||
* The AuthenticationProvider which is using this module to configure
|
||||
* injection.
|
||||
*/
|
||||
private final AuthenticationProvider authProvider;
|
||||
|
||||
/**
|
||||
* Creates a new JDBC authentication provider module that configures the
|
||||
* various injected base classes using the given environment, and provides
|
||||
* connections using the given socket service.
|
||||
*
|
||||
* @param authProvider
|
||||
* The AuthenticationProvider which is using this module to configure
|
||||
* injection.
|
||||
*
|
||||
* @param environment
|
||||
* The environment to use to configure injected classes.
|
||||
*
|
||||
* @param tunnelService
|
||||
* The tunnel service to use to provide tunnels sockets for connections.
|
||||
*/
|
||||
public JDBCAuthenticationProviderModule(Environment environment,
|
||||
public JDBCAuthenticationProviderModule(AuthenticationProvider authProvider,
|
||||
Environment environment,
|
||||
GuacamoleTunnelService tunnelService) {
|
||||
this.authProvider = authProvider;
|
||||
this.environment = environment;
|
||||
this.tunnelService = tunnelService;
|
||||
}
|
||||
@@ -126,6 +139,7 @@ public class JDBCAuthenticationProviderModule extends MyBatisModule {
|
||||
// Bind core implementations of guacamole-ext classes
|
||||
bind(ActiveConnectionDirectory.class);
|
||||
bind(ActiveConnectionPermissionSet.class);
|
||||
bind(AuthenticationProvider.class).toInstance(authProvider);
|
||||
bind(Environment.class).toInstance(environment);
|
||||
bind(ConnectionDirectory.class);
|
||||
bind(ConnectionGroupDirectory.class);
|
||||
|
@@ -36,6 +36,7 @@ import org.glyptodon.guacamole.auth.jdbc.connection.ModeledConnection;
|
||||
import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ModeledConnectionGroup;
|
||||
import org.glyptodon.guacamole.form.Form;
|
||||
import org.glyptodon.guacamole.net.auth.ActiveConnection;
|
||||
import org.glyptodon.guacamole.net.auth.AuthenticationProvider;
|
||||
import org.glyptodon.guacamole.net.auth.Connection;
|
||||
import org.glyptodon.guacamole.net.auth.ConnectionGroup;
|
||||
import org.glyptodon.guacamole.net.auth.Directory;
|
||||
@@ -51,6 +52,12 @@ import org.glyptodon.guacamole.net.auth.User;
|
||||
public class UserContext extends RestrictedObject
|
||||
implements org.glyptodon.guacamole.net.auth.UserContext {
|
||||
|
||||
/**
|
||||
* The AuthenticationProvider that created this UserContext.
|
||||
*/
|
||||
@Inject
|
||||
private AuthenticationProvider authProvider;
|
||||
|
||||
/**
|
||||
* User directory restricted by the permissions of the user associated
|
||||
* with this context.
|
||||
@@ -103,6 +110,11 @@ public class UserContext extends RestrictedObject
|
||||
return getCurrentUser().getUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticationProvider getAuthenticationProvider() {
|
||||
return authProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Directory<User> getUserDirectory() throws GuacamoleException {
|
||||
return userDirectory;
|
||||
|
@@ -185,7 +185,8 @@ public class MySQLAuthenticationProvider implements AuthenticationProvider {
|
||||
new MySQLAuthenticationProviderModule(environment),
|
||||
|
||||
// Configure JDBC authentication core
|
||||
new JDBCAuthenticationProviderModule(environment, getTunnelService(environment))
|
||||
new JDBCAuthenticationProviderModule(this, environment,
|
||||
getTunnelService(environment))
|
||||
|
||||
);
|
||||
|
||||
|
@@ -185,7 +185,8 @@ public class PostgreSQLAuthenticationProvider implements AuthenticationProvider
|
||||
new PostgreSQLAuthenticationProviderModule(environment),
|
||||
|
||||
// Configure JDBC authentication core
|
||||
new JDBCAuthenticationProviderModule(environment, getTunnelService(environment))
|
||||
new JDBCAuthenticationProviderModule(this, environment,
|
||||
getTunnelService(environment))
|
||||
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user