From aae2a8068a4d335a5dd54b8e5440ca698f98491f Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Mon, 22 Jul 2013 23:32:41 -0700 Subject: [PATCH] Ticket #263: Refined guacamole-ext. --- .../guacamole/net/auth/Connection.java | 2 +- .../guacamole/net/auth/ConnectionGroup.java | 44 +++++++++++------- .../net/auth/ConnectionGroupMember.java | 46 ------------------- .../guacamole/net/auth/UserContext.java | 24 ++-------- .../net/auth/simple/SimpleUserContext.java | 29 +++++++++--- 5 files changed, 57 insertions(+), 88 deletions(-) delete mode 100644 guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/ConnectionGroupMember.java diff --git a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/Connection.java b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/Connection.java index 5dbba52e4..fdfea4577 100644 --- a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/Connection.java +++ b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/Connection.java @@ -52,7 +52,7 @@ import net.sourceforge.guacamole.protocol.GuacamoleConfiguration; * * @author Michael Jumper */ -public interface Connection extends ConnectionGroupMember { +public interface Connection { /** * Returns the unique identifier assigned to this Connection. diff --git a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/ConnectionGroup.java b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/ConnectionGroup.java index 28f38efc3..5be500394 100644 --- a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/ConnectionGroup.java +++ b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/ConnectionGroup.java @@ -37,21 +37,18 @@ package net.sourceforge.guacamole.net.auth; * * ***** END LICENSE BLOCK ***** */ -import java.util.Collection; import net.sourceforge.guacamole.GuacamoleException; import net.sourceforge.guacamole.net.GuacamoleSocket; import net.sourceforge.guacamole.protocol.GuacamoleClientInformation; /** - * Represents a pairing of a GuacamoleConfiguration with a unique, - * human-readable identifier, and abstracts the connection process. The - * backing GuacamoleConfiguration may be intentionally obfuscated or tokenized - * to protect sensitive configuration information. + * Represents a connection group, which can contain both other connection groups + * as well as connections. * * @author James Muehlner */ -public interface ConnectionGroup extends ConnectionGroupMember { +public interface ConnectionGroup { /** * Returns the unique identifier assigned to this ConnectionGroup. @@ -60,24 +57,39 @@ public interface ConnectionGroup extends ConnectionGroupMember { public String getIdentifier(); /** - * Sets the identifier assigned to this Connection group. + * Sets the identifier assigned to this ConnectionGroup. * * @param identifier The identifier to assign. */ public void setIdentifier(String identifier); - + /** - * Returns all members of this ConnectionGroup. - * @return all members of this ConnectionGroup. + * 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. + * + * @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 getMembers(); - + Directory getConnectionDirectory() + throws GuacamoleException; + /** - * Sets the new members for this ConnectionGroup. - * - * @param members The new members for this grouConnectionGroupp. + * Retrieves a Directory which can be used to view and manipulate + * connection groups and their members, 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 void setMembers(Collection members); + Directory getConnectionGroupDirectory() + throws GuacamoleException; /** * Establishes a connection to guacd using a connection chosen from among diff --git a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/ConnectionGroupMember.java b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/ConnectionGroupMember.java deleted file mode 100644 index ad0df292b..000000000 --- a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/ConnectionGroupMember.java +++ /dev/null @@ -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 {} diff --git a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/UserContext.java b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/UserContext.java index e94b922ca..1c54909ab 100644 --- a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/UserContext.java +++ b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/UserContext.java @@ -69,32 +69,18 @@ public interface UserContext { */ Directory 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 getConnectionDirectory() - throws GuacamoleException; /** - * Retrieves a Directory which can be used to view and manipulate - * connection groups and their members, but only as allowed by the - * permissions given to the user of this UserContext. + * Retrieves a connection group which can be used to view and manipulate + * connections, but only as allowed by the permissions given to the user of + * 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. * * @throws GuacamoleException If an error occurs while creating the * Directory. */ - Directory getConnectionGroupDirectory() - throws GuacamoleException; + ConnectionGroup getConnectionGroup() throws GuacamoleException; } diff --git a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/simple/SimpleUserContext.java b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/simple/SimpleUserContext.java index 65be77a89..493d1bfba 100644 --- a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/simple/SimpleUserContext.java +++ b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/simple/SimpleUserContext.java @@ -40,6 +40,7 @@ package net.sourceforge.guacamole.net.auth.simple; import java.util.Map; 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.Directory; import net.sourceforge.guacamole.net.auth.User; import net.sourceforge.guacamole.net.auth.UserContext; @@ -66,12 +67,24 @@ public class SimpleUserContext implements UserContext { */ private final Directory connectionDirectory; + /** + * The Directory with access only to those Connection Groups that the User + * associated with this UserContext has access to. + */ + private final Directory connectionGroupDirectory; + /** * The Directory with access only to the User associated with this * UserContext. */ private final Directory 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 * configurations within the given Map. The User given must be the user @@ -89,8 +102,13 @@ public class SimpleUserContext implements UserContext { this.connectionDirectory = new SimpleConnectionDirectory(configs); + + this.connectionGroupDirectory = new SimpleConnectionGroupDirectory(); this.userDirectory = new SimpleUserDirectory(self); + + this.connectionGroup = new SimpleConnectionGroup(this.connectionDirectory, + this.connectionGroupDirectory); } @@ -99,16 +117,15 @@ public class SimpleUserContext implements UserContext { return self; } - @Override - public Directory getConnectionDirectory() - throws GuacamoleException { - return connectionDirectory; - } - @Override public Directory getUserDirectory() throws GuacamoleException { return userDirectory; } + @Override + public ConnectionGroup getConnectionGroup() throws GuacamoleException { + return connectionGroup; + } + }