mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Implement SimpleConnectionGroupDirectory.
This commit is contained in:
@@ -55,16 +55,47 @@ import net.sourceforge.guacamole.protocol.GuacamoleClientInformation;
|
|||||||
* @author James Muehlner
|
* @author James Muehlner
|
||||||
*/
|
*/
|
||||||
public class SimpleConnectionGroup extends AbstractConnectionGroup {
|
public class SimpleConnectionGroup extends AbstractConnectionGroup {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Underlying connection directory, containing all connections within this
|
||||||
|
* group.
|
||||||
|
*/
|
||||||
private final Directory<String, Connection> connectionDirectory;
|
private final Directory<String, Connection> connectionDirectory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Underlying connection group directory, containing all connections within
|
||||||
|
* this group.
|
||||||
|
*/
|
||||||
private final Directory<String, ConnectionGroup> connectionGroupDirectory;
|
private final Directory<String, ConnectionGroup> connectionGroupDirectory;
|
||||||
|
|
||||||
|
/**
|
||||||
public SimpleConnectionGroup(Directory<String, Connection> connectionDirectory,
|
* Creates a new SimpleConnectionGroup having the given name and identifier
|
||||||
|
* which will expose the given directories as its contents.
|
||||||
|
*
|
||||||
|
* @param name The name to associate with this connection.
|
||||||
|
* @param identifier The identifier to associate with this connection.
|
||||||
|
* @param connectionDirectory The connection directory to expose when
|
||||||
|
* requested.
|
||||||
|
* @param connectionGroupDirectory The connection group directory to expose
|
||||||
|
* when requested.
|
||||||
|
*/
|
||||||
|
public SimpleConnectionGroup(String name, String identifier,
|
||||||
|
Directory<String, Connection> connectionDirectory,
|
||||||
Directory<String, ConnectionGroup> connectionGroupDirectory) {
|
Directory<String, ConnectionGroup> connectionGroupDirectory) {
|
||||||
|
|
||||||
|
// Set name
|
||||||
|
setName(name);
|
||||||
|
|
||||||
|
// Set identifier
|
||||||
|
setIdentifier(identifier);
|
||||||
|
|
||||||
|
// Set group type
|
||||||
|
setType(ConnectionGroup.Type.ORGANIZATIONAL);
|
||||||
|
|
||||||
|
// Assign directories
|
||||||
this.connectionDirectory = connectionDirectory;
|
this.connectionDirectory = connectionDirectory;
|
||||||
this.connectionGroupDirectory = connectionGroupDirectory;
|
this.connectionGroupDirectory = connectionGroupDirectory;
|
||||||
this.setType(ConnectionGroup.Type.ORGANIZATIONAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -37,7 +37,9 @@ package net.sourceforge.guacamole.net.auth.simple;
|
|||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import net.sourceforge.guacamole.GuacamoleException;
|
import net.sourceforge.guacamole.GuacamoleException;
|
||||||
import net.sourceforge.guacamole.GuacamoleSecurityException;
|
import net.sourceforge.guacamole.GuacamoleSecurityException;
|
||||||
@@ -47,26 +49,44 @@ import net.sourceforge.guacamole.net.auth.Directory;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An extremely simple read-only implementation of a Directory of
|
* An extremely simple read-only implementation of a Directory of
|
||||||
* ConnectionGroup which provides an empty set of connection groups.
|
* ConnectionGroup which provides which provides access to a pre-defined
|
||||||
|
* Collection of ConnectionGroups.
|
||||||
*
|
*
|
||||||
* @author James Muehlner
|
* @author James Muehlner
|
||||||
*/
|
*/
|
||||||
public class SimpleConnectionGroupDirectory
|
public class SimpleConnectionGroupDirectory
|
||||||
implements Directory<String, ConnectionGroup> {
|
implements Directory<String, ConnectionGroup> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new SimpleConnectionGroupDirectory */
|
* The Map of ConnectionGroups to provide access to.
|
||||||
public SimpleConnectionGroupDirectory() {}
|
*/
|
||||||
|
private Map<String, ConnectionGroup> connectionGroups =
|
||||||
|
new HashMap<String, ConnectionGroup>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new SimpleConnectionGroupDirectory which contains the given
|
||||||
|
* groups.
|
||||||
|
*
|
||||||
|
* @param groups A Collection of all groups that should be present in this
|
||||||
|
* connection group directory.
|
||||||
|
*/
|
||||||
|
public SimpleConnectionGroupDirectory(Collection<ConnectionGroup> groups) {
|
||||||
|
|
||||||
|
// Add all given groups
|
||||||
|
for (ConnectionGroup group : groups)
|
||||||
|
connectionGroups.put(group.getIdentifier(), group);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConnectionGroup get(String identifier)
|
public ConnectionGroup get(String identifier)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
return null;
|
return connectionGroups.get(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getIdentifiers() throws GuacamoleException {
|
public Set<String> getIdentifiers() throws GuacamoleException {
|
||||||
return Collections.EMPTY_SET;
|
return connectionGroups.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -92,4 +112,27 @@ public class SimpleConnectionGroupDirectory
|
|||||||
throw new GuacamoleSecurityException("Permission denied.");
|
throw new GuacamoleSecurityException("Permission denied.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An internal method for modifying the ConnectionGroups in this Directory.
|
||||||
|
* Returns the previous connection group for the given identifier, if found.
|
||||||
|
*
|
||||||
|
* @param connectionGroup The connection group to add or update the
|
||||||
|
* Directory with.
|
||||||
|
* @return The previous connection group for the connection group
|
||||||
|
* identifier, if found.
|
||||||
|
*/
|
||||||
|
public ConnectionGroup putConnectionGroup(ConnectionGroup connectionGroup) {
|
||||||
|
return connectionGroups.put(connectionGroup.getIdentifier(), connectionGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An internal method for removing a ConnectionGroup from this Directory.
|
||||||
|
*
|
||||||
|
* @param identifier The identifier of the ConnectionGroup to remove.
|
||||||
|
* @return The previous connection group for the given identifier, if found.
|
||||||
|
*/
|
||||||
|
public ConnectionGroup removeConnectionGroup(String identifier) {
|
||||||
|
return connectionGroups.remove(identifier);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -37,9 +37,9 @@ package net.sourceforge.guacamole.net.auth.simple;
|
|||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.sourceforge.guacamole.GuacamoleException;
|
import net.sourceforge.guacamole.GuacamoleException;
|
||||||
import net.sourceforge.guacamole.net.auth.Connection;
|
|
||||||
import net.sourceforge.guacamole.net.auth.ConnectionGroup;
|
import net.sourceforge.guacamole.net.auth.ConnectionGroup;
|
||||||
import net.sourceforge.guacamole.net.auth.Directory;
|
import net.sourceforge.guacamole.net.auth.Directory;
|
||||||
import net.sourceforge.guacamole.net.auth.User;
|
import net.sourceforge.guacamole.net.auth.User;
|
||||||
@@ -61,18 +61,6 @@ public class SimpleUserContext implements UserContext {
|
|||||||
*/
|
*/
|
||||||
private final User self;
|
private final User self;
|
||||||
|
|
||||||
/**
|
|
||||||
* The Directory with access only to those Connections that the User
|
|
||||||
* associated with this UserContext has access to.
|
|
||||||
*/
|
|
||||||
private final Directory<String, Connection> connectionDirectory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Directory with access only to those Connection Groups that the User
|
|
||||||
* associated with this UserContext has access to.
|
|
||||||
*/
|
|
||||||
private final Directory<String, ConnectionGroup> connectionGroupDirectory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Directory with access only to the User associated with this
|
* The Directory with access only to the User associated with this
|
||||||
* UserContext.
|
* UserContext.
|
||||||
@@ -99,16 +87,12 @@ public class SimpleUserContext implements UserContext {
|
|||||||
Map<String, GuacamoleConfiguration> configs) {
|
Map<String, GuacamoleConfiguration> configs) {
|
||||||
|
|
||||||
this.self = self;
|
this.self = self;
|
||||||
|
|
||||||
this.connectionDirectory =
|
|
||||||
new SimpleConnectionDirectory(configs);
|
|
||||||
|
|
||||||
this.connectionGroupDirectory = new SimpleConnectionGroupDirectory();
|
|
||||||
|
|
||||||
this.userDirectory = new SimpleUserDirectory(self);
|
this.userDirectory = new SimpleUserDirectory(self);
|
||||||
|
|
||||||
this.connectionGroup = new SimpleConnectionGroup(this.connectionDirectory,
|
// Add root group that contains only configurations
|
||||||
this.connectionGroupDirectory);
|
this.connectionGroup = new SimpleConnectionGroup("ROOT", "ROOT",
|
||||||
|
new SimpleConnectionDirectory(configs),
|
||||||
|
new SimpleConnectionGroupDirectory(Collections.EMPTY_LIST));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user