Ticket #263: Refined guacamole-ext.

This commit is contained in:
James Muehlner
2013-07-22 23:32:41 -07:00
parent 9cfb20d26e
commit aae2a8068a
5 changed files with 57 additions and 88 deletions

View File

@@ -52,7 +52,7 @@ import net.sourceforge.guacamole.protocol.GuacamoleConfiguration;
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
public interface Connection extends ConnectionGroupMember { public interface Connection {
/** /**
* Returns the unique identifier assigned to this Connection. * Returns the unique identifier assigned to this Connection.

View File

@@ -37,21 +37,18 @@ package net.sourceforge.guacamole.net.auth;
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
import java.util.Collection;
import net.sourceforge.guacamole.GuacamoleException; import net.sourceforge.guacamole.GuacamoleException;
import net.sourceforge.guacamole.net.GuacamoleSocket; import net.sourceforge.guacamole.net.GuacamoleSocket;
import net.sourceforge.guacamole.protocol.GuacamoleClientInformation; import net.sourceforge.guacamole.protocol.GuacamoleClientInformation;
/** /**
* Represents a pairing of a GuacamoleConfiguration with a unique, * Represents a connection group, which can contain both other connection groups
* human-readable identifier, and abstracts the connection process. The * as well as connections.
* backing GuacamoleConfiguration may be intentionally obfuscated or tokenized
* to protect sensitive configuration information.
* *
* @author James Muehlner * @author James Muehlner
*/ */
public interface ConnectionGroup extends ConnectionGroupMember { public interface ConnectionGroup {
/** /**
* Returns the unique identifier assigned to this ConnectionGroup. * Returns the unique identifier assigned to this ConnectionGroup.
@@ -60,24 +57,39 @@ public interface ConnectionGroup extends ConnectionGroupMember {
public String getIdentifier(); public String getIdentifier();
/** /**
* Sets the identifier assigned to this Connection group. * Sets the identifier assigned to this ConnectionGroup.
* *
* @param identifier The identifier to assign. * @param identifier The identifier to assign.
*/ */
public void setIdentifier(String identifier); public void setIdentifier(String identifier);
/** /**
* Returns all members of this ConnectionGroup. * Retrieves a Directory which can be used to view and manipulate
* @return all members of this ConnectionGroup. * connections and their configurations, but only as allowed by the
* permissions given to the user.
*
* @return A Directory whose operations are bound by the permissions of
* the user.
*
* @throws GuacamoleException If an error occurs while creating the
* Directory.
*/ */
public Collection<ConnectionGroupMember> getMembers(); Directory<String, Connection> getConnectionDirectory()
throws GuacamoleException;
/** /**
* Sets the new members for this ConnectionGroup. * Retrieves a Directory which can be used to view and manipulate
* * connection groups and their members, but only as allowed by the
* @param members The new members for this grouConnectionGroupp. * permissions given to the user.
*
* @return A Directory whose operations are bound by the permissions of
* the user.
*
* @throws GuacamoleException If an error occurs while creating the
* Directory.
*/ */
public void setMembers(Collection<ConnectionGroupMember> members); Directory<String, ConnectionGroup> getConnectionGroupDirectory()
throws GuacamoleException;
/** /**
* Establishes a connection to guacd using a connection chosen from among * Establishes a connection to guacd using a connection chosen from among

View File

@@ -1,46 +0,0 @@
package net.sourceforge.guacamole.net.auth;
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is guacamole-ext.
*
* The Initial Developer of the Original Code is
* Michael Jumper.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): James Muehlner
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* Represents a constituent member of a ConnectionGroup.
*
* @author James Muehlner
*/
public interface ConnectionGroupMember {}

View File

@@ -69,32 +69,18 @@ public interface UserContext {
*/ */
Directory<String, User> getUserDirectory() throws GuacamoleException; Directory<String, User> getUserDirectory() throws GuacamoleException;
/**
* Retrieves a Directory which can be used to view and manipulate
* connections and their configurations, but only as allowed by the
* permissions given to the user of this UserContext.
*
* @return A Directory whose operations are bound by the restrictions
* of this UserContext.
*
* @throws GuacamoleException If an error occurs while creating the
* Directory.
*/
Directory<String, Connection> getConnectionDirectory()
throws GuacamoleException;
/** /**
* Retrieves a Directory which can be used to view and manipulate * Retrieves a connection group which can be used to view and manipulate
* connection groups and their members, but only as allowed by the * connections, but only as allowed by the permissions given to the user of
* permissions given to the user of this UserContext. * this UserContext.
* *
* @return A Directory whose operations are bound by the restrictions * @return A connection group whose operations are bound by the restrictions
* of this UserContext. * of this UserContext.
* *
* @throws GuacamoleException If an error occurs while creating the * @throws GuacamoleException If an error occurs while creating the
* Directory. * Directory.
*/ */
Directory<String, ConnectionGroup> getConnectionGroupDirectory() ConnectionGroup getConnectionGroup() throws GuacamoleException;
throws GuacamoleException;
} }

View File

@@ -40,6 +40,7 @@ package net.sourceforge.guacamole.net.auth.simple;
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.Connection;
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;
import net.sourceforge.guacamole.net.auth.UserContext; import net.sourceforge.guacamole.net.auth.UserContext;
@@ -66,12 +67,24 @@ public class SimpleUserContext implements UserContext {
*/ */
private final Directory<String, Connection> connectionDirectory; 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.
*/ */
private final Directory<String, User> userDirectory; private final Directory<String, User> userDirectory;
/**
* The ConnectionGroup with access only to those Connections that the User
* associated with this UserContext has access to.
*/
private final ConnectionGroup connectionGroup;
/** /**
* Creates a new SimpleUserContext which provides access to only those * Creates a new SimpleUserContext which provides access to only those
* configurations within the given Map. The User given must be the user * configurations within the given Map. The User given must be the user
@@ -89,8 +102,13 @@ public class SimpleUserContext implements UserContext {
this.connectionDirectory = this.connectionDirectory =
new SimpleConnectionDirectory(configs); new SimpleConnectionDirectory(configs);
this.connectionGroupDirectory = new SimpleConnectionGroupDirectory();
this.userDirectory = new SimpleUserDirectory(self); this.userDirectory = new SimpleUserDirectory(self);
this.connectionGroup = new SimpleConnectionGroup(this.connectionDirectory,
this.connectionGroupDirectory);
} }
@@ -99,16 +117,15 @@ public class SimpleUserContext implements UserContext {
return self; return self;
} }
@Override
public Directory<String, Connection> getConnectionDirectory()
throws GuacamoleException {
return connectionDirectory;
}
@Override @Override
public Directory<String, User> getUserDirectory() public Directory<String, User> getUserDirectory()
throws GuacamoleException { throws GuacamoleException {
return userDirectory; return userDirectory;
} }
@Override
public ConnectionGroup getConnectionGroup() throws GuacamoleException {
return connectionGroup;
}
} }