mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-542: Migrate to simpler AbstractAuthenticationProvider / AbstractUserContext base classes.
This commit is contained in:
@@ -21,7 +21,7 @@ package org.apache.guacamole.auth.jdbc;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.net.auth.AuthenticationProvider;
|
||||
import org.apache.guacamole.net.auth.AbstractAuthenticationProvider;
|
||||
import org.apache.guacamole.net.auth.Credentials;
|
||||
import org.apache.guacamole.net.auth.UserContext;
|
||||
import org.apache.guacamole.net.auth.AuthenticatedUser;
|
||||
@@ -34,7 +34,7 @@ import org.apache.guacamole.net.auth.AuthenticatedUser;
|
||||
* AuthenticationProvider, even though it is the AuthenticationProvider that
|
||||
* serves as the entry point.
|
||||
*/
|
||||
public abstract class InjectedAuthenticationProvider implements AuthenticationProvider {
|
||||
public abstract class InjectedAuthenticationProvider extends AbstractAuthenticationProvider {
|
||||
|
||||
/**
|
||||
* The AuthenticationProviderService to which all AuthenticationProvider
|
||||
@@ -70,26 +70,12 @@ public abstract class InjectedAuthenticationProvider implements AuthenticationPr
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResource() throws GuacamoleException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticatedUser authenticateUser(Credentials credentials)
|
||||
throws GuacamoleException {
|
||||
return authProviderService.authenticateUser(this, credentials);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser,
|
||||
Credentials credentials) throws GuacamoleException {
|
||||
|
||||
// No need to update authenticated users
|
||||
return authenticatedUser;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserContext getUserContext(AuthenticatedUser authenticatedUser)
|
||||
throws GuacamoleException {
|
||||
@@ -104,23 +90,4 @@ public abstract class InjectedAuthenticationProvider implements AuthenticationPr
|
||||
authenticatedUser, credentials);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserContext decorate(UserContext context,
|
||||
AuthenticatedUser authenticatedUser, Credentials credentials)
|
||||
throws GuacamoleException {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserContext redecorate(UserContext decorated, UserContext context,
|
||||
AuthenticatedUser authenticatedUser, Credentials credentials)
|
||||
throws GuacamoleException {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -20,27 +20,16 @@
|
||||
package org.apache.guacamole.auth.jdbc.sharing.user;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.auth.jdbc.sharing.connection.SharedConnectionDirectory;
|
||||
import org.apache.guacamole.auth.jdbc.sharing.connectiongroup.SharedRootConnectionGroup;
|
||||
import org.apache.guacamole.auth.jdbc.user.RemoteAuthenticatedUser;
|
||||
import org.apache.guacamole.form.Form;
|
||||
import org.apache.guacamole.net.auth.ActiveConnection;
|
||||
import org.apache.guacamole.net.auth.ActivityRecord;
|
||||
import org.apache.guacamole.net.auth.ActivityRecordSet;
|
||||
import org.apache.guacamole.net.auth.AbstractUserContext;
|
||||
import org.apache.guacamole.net.auth.AuthenticationProvider;
|
||||
import org.apache.guacamole.net.auth.Connection;
|
||||
import org.apache.guacamole.net.auth.ConnectionGroup;
|
||||
import org.apache.guacamole.net.auth.ConnectionRecord;
|
||||
import org.apache.guacamole.net.auth.Directory;
|
||||
import org.apache.guacamole.net.auth.SharingProfile;
|
||||
import org.apache.guacamole.net.auth.User;
|
||||
import org.apache.guacamole.net.auth.UserContext;
|
||||
import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet;
|
||||
import org.apache.guacamole.net.auth.simple.SimpleConnectionGroupDirectory;
|
||||
import org.apache.guacamole.net.auth.simple.SimpleDirectory;
|
||||
|
||||
/**
|
||||
* The user context of a SharedUser, providing access ONLY to the user
|
||||
@@ -48,7 +37,7 @@ import org.apache.guacamole.net.auth.simple.SimpleDirectory;
|
||||
* keys, and an internal root connection group containing only those
|
||||
* connections.
|
||||
*/
|
||||
public class SharedUserContext implements UserContext {
|
||||
public class SharedUserContext extends AbstractUserContext {
|
||||
|
||||
/**
|
||||
* The AuthenticationProvider that created this SharedUserContext.
|
||||
@@ -67,18 +56,6 @@ public class SharedUserContext implements UserContext {
|
||||
@Inject
|
||||
private SharedConnectionDirectory connectionDirectory;
|
||||
|
||||
/**
|
||||
* A directory of all connection groups visible to the user for whom this
|
||||
* user context was created.
|
||||
*/
|
||||
private Directory<ConnectionGroup> connectionGroupDirectory;
|
||||
|
||||
/**
|
||||
* A directory of all users visible to the user for whom this user context
|
||||
* was created.
|
||||
*/
|
||||
private Directory<User> userDirectory;
|
||||
|
||||
/**
|
||||
* The root connection group of the hierarchy containing all connections
|
||||
* and connection groups visible to the user for whom this user context was
|
||||
@@ -110,15 +87,10 @@ public class SharedUserContext implements UserContext {
|
||||
|
||||
// The connection group directory contains only the root group
|
||||
this.rootGroup = new SharedRootConnectionGroup(this);
|
||||
this.connectionGroupDirectory = new SimpleConnectionGroupDirectory(
|
||||
Collections.singletonList(this.rootGroup));
|
||||
|
||||
// Create internal pseudo-account representing the authenticated user
|
||||
this.self = new SharedUser(user, this);
|
||||
|
||||
// Do not provide access to any user accounts via the directory
|
||||
this.userDirectory = new SimpleDirectory<User>();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,83 +110,20 @@ public class SharedUserContext implements UserContext {
|
||||
return self;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResource() throws GuacamoleException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticationProvider getAuthenticationProvider() {
|
||||
return authProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Directory<User> getUserDirectory() {
|
||||
return userDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Directory<Connection> getConnectionDirectory()
|
||||
throws GuacamoleException {
|
||||
return connectionDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Directory<ConnectionGroup> getConnectionGroupDirectory() {
|
||||
return connectionGroupDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Directory<ActiveConnection> getActiveConnectionDirectory()
|
||||
throws GuacamoleException {
|
||||
return new SimpleDirectory<ActiveConnection>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Directory<SharingProfile> getSharingProfileDirectory()
|
||||
throws GuacamoleException {
|
||||
return new SimpleDirectory<SharingProfile>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ConnectionRecord> getConnectionHistory() {
|
||||
return new SimpleActivityRecordSet<ConnectionRecord>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||
throws GuacamoleException {
|
||||
return new SimpleActivityRecordSet<ActivityRecord>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectionGroup getRootConnectionGroup() {
|
||||
return rootGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Form> getUserAttributes() {
|
||||
return Collections.<Form>emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Form> getConnectionAttributes() {
|
||||
return Collections.<Form>emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Form> getConnectionGroupAttributes() {
|
||||
return Collections.<Form>emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Form> getSharingProfileAttributes() {
|
||||
return Collections.<Form>emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
// Nothing to invalidate
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user