From 9585d0fc6ca62cd2a1d6242c173258e7cd66e87e Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 24 May 2015 15:01:15 -0700 Subject: [PATCH] GUAC-800: Handle attributes as dynamic properties (no GuacamoleExceptions). Use Attribute for schema information only. Allow retrieval of schema information from UserContext. Add attributes to ConnectionGroup. --- .../guacamole/net/auth/Connection.java | 34 ++-- .../guacamole/net/auth/ConnectionGroup.java | 22 ++- .../glyptodon/guacamole/net/auth/User.java | 33 ++-- .../guacamole/net/auth/UserContext.java | 35 ++++ .../net/auth/attribute/Attribute.java | 53 +++--- .../net/auth/attribute/AttributeSet.java | 69 -------- .../net/auth/attribute/ObjectAttribute.java | 152 ------------------ .../auth/attribute/ObjectAttributeSet.java | 31 ---- .../net/auth/simple/SimpleConnection.java | 17 +- .../auth/simple/SimpleConnectionGroup.java | 12 ++ .../auth/simple/SimpleObjectAttributeSet.java | 85 ---------- .../guacamole/net/auth/simple/SimpleUser.java | 19 ++- .../net/auth/simple/SimpleUserContext.java | 16 ++ 13 files changed, 177 insertions(+), 401 deletions(-) delete mode 100644 guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/AttributeSet.java delete mode 100644 guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/ObjectAttribute.java delete mode 100644 guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/ObjectAttributeSet.java delete mode 100644 guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleObjectAttributeSet.java diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/Connection.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/Connection.java index ecd30dcce..6ab34dab4 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/Connection.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/Connection.java @@ -23,8 +23,8 @@ package org.glyptodon.guacamole.net.auth; import java.util.List; +import java.util.Map; import org.glyptodon.guacamole.GuacamoleException; -import org.glyptodon.guacamole.net.auth.attribute.ObjectAttributeSet; import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; /** @@ -85,6 +85,25 @@ public interface Connection extends Identifiable, Connectable { */ public void setConfiguration(GuacamoleConfiguration config); + /** + * Returns all attributes associated with this connection. + * + * @return + * A map of all attribute identifiers to their corresponding values, + * for all attributes associated with this connection. + */ + Map getAttributes(); + + /** + * Replaces all attributes associated with this connection with the + * attributes in the given map. + * + * @param attributes + * A map of all attribute identifiers to their corresponding values, + * for all attributes associated with this connection. + */ + void setAttributes(Map attributes); + /** * Returns a list of ConnectionRecords representing the usage history * of this Connection, including any active users. ConnectionRecords @@ -101,17 +120,4 @@ public interface Connection extends Identifiable, Connectable { */ public List getHistory() throws GuacamoleException; - /** - * Returns all attributes associated with this connection. - * - * @return - * An ObjectAttributeSet of all attributes associated with this - * connection - * - * @throws GuacamoleException - * If an error occurs while retrieving the attributes, or if reading - * attributes is not allowed. - */ - ObjectAttributeSet getAttributes() throws GuacamoleException; - } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/ConnectionGroup.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/ConnectionGroup.java index 97c66ad02..25eb11797 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/ConnectionGroup.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/ConnectionGroup.java @@ -22,6 +22,7 @@ package org.glyptodon.guacamole.net.auth; +import java.util.Map; import java.util.Set; import org.glyptodon.guacamole.GuacamoleException; @@ -127,5 +128,24 @@ public interface ConnectionGroup extends Identifiable, Connectable { public Set getConnectionGroupIdentifiers() throws GuacamoleException; - + + /** + * Returns all attributes associated with this connection group. + * + * @return + * A map of all attribute identifiers to their corresponding values, + * for all attributes associated with this connection group. + */ + Map getAttributes(); + + /** + * Replaces all attributes associated with this connection group with the + * attributes in the given map. + * + * @param attributes + * A map of all attribute identifiers to their corresponding values, + * for all attributes associated with this connection group. + */ + void setAttributes(Map attributes); + } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/User.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/User.java index 99773501f..b2f13ea23 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/User.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/User.java @@ -22,8 +22,8 @@ package org.glyptodon.guacamole.net.auth; +import java.util.Map; import org.glyptodon.guacamole.GuacamoleException; -import org.glyptodon.guacamole.net.auth.attribute.ObjectAttributeSet; import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet; import org.glyptodon.guacamole.net.auth.permission.SystemPermissionSet; @@ -52,6 +52,25 @@ public interface User extends Identifiable { */ public void setPassword(String password); + /** + * Returns all attributes associated with this user. + * + * @return + * A map of all attribute identifiers to their corresponding values, + * for all attributes associated with this user. + */ + Map getAttributes(); + + /** + * Replaces all attributes associated with this user with the attributes in + * the given map. + * + * @param attributes + * A map of all attribute identifiers to their corresponding values, + * for all attributes associated with this user. + */ + void setAttributes(Map attributes); + /** * Returns all system-level permissions given to this user. * @@ -120,16 +139,4 @@ public interface User extends Identifiable { */ ObjectPermissionSet getUserPermissions() throws GuacamoleException; - /** - * Returns all attributes associated with this user. - * - * @return - * An ObjectAttributeSet of all attributes associated with this user. - * - * @throws GuacamoleException - * If an error occurs while retrieving the attributes, or if reading - * attributes is not allowed. - */ - ObjectAttributeSet getAttributes() throws GuacamoleException; - } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/UserContext.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/UserContext.java index 38538bce1..0d782e9dc 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/UserContext.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/UserContext.java @@ -22,7 +22,9 @@ package org.glyptodon.guacamole.net.auth; +import java.util.Collection; import org.glyptodon.guacamole.GuacamoleException; +import org.glyptodon.guacamole.net.auth.attribute.Attribute; /** * The context of an active user. The functions of this class enforce all @@ -110,4 +112,37 @@ public interface UserContext { */ ConnectionGroup getRootConnectionGroup() throws GuacamoleException; + /** + * Retrieves a collection of all attributes applicable to users. This + * collection will contain only those attributes which the current user has + * general permission to view or modify. If there are no such attributes, + * this collection will be empty. + * + * @return + * A collection of all attributes applicable to users. + */ + Collection getUserAttributes(); + + /** + * Retrieves a collection of all attributes applicable to connections. This + * collection will contain only those attributes which the current user has + * general permission to view or modify. If there are no such attributes, + * this collection will be empty. + * + * @return + * A collection of all attributes applicable to connections. + */ + Collection getConnectionAttributes(); + + /** + * Retrieves a collection of all attributes applicable to connection + * groups. This collection will contain only those attributes which the + * current user has general permission to view or modify. If there are no + * such attributes, this collection will be empty. + * + * @return + * A collection of all attributes applicable to connection groups. + */ + Collection getConnectionGroupAttributes(); + } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/Attribute.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/Attribute.java index 446eb0c4e..38e75b538 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/Attribute.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/Attribute.java @@ -26,12 +26,22 @@ import org.glyptodon.guacamole.net.auth.Identifiable; /** * An arbitrary attribute. Each attribute associates an identifier with a - * value, essentially a key/value pair, where the type dictates the semantics - * and legal values of the attribute. + * type, where the type dictates the semantics and legal values of the + * attribute. * * @author Michael Jumper */ -public interface Attribute extends Identifiable { +public class Attribute implements Identifiable { + + /** + * The string which uniquely identifies this attribute. + */ + private String identifier; + + /** + * The type of this attribute. + */ + private Type type; /** * Specific types of attributes. Each attribute type describes the kind of @@ -80,6 +90,16 @@ public interface Attribute extends Identifiable { } + @Override + public String getIdentifier() { + return identifier; + } + + @Override + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + /** * Returns the type of this attribute. The attribute type dictates the kind * of values the attribute can contain, and the semantics of the attribute @@ -88,7 +108,9 @@ public interface Attribute extends Identifiable { * @return * The type of this attribute. */ - Type getType(); + public Type getType() { + return type; + } /** * Sets the type of this attribute. Attribute type dictates the kind of @@ -98,25 +120,8 @@ public interface Attribute extends Identifiable { * @param type * The type to associate with this attribute. */ - void setType(Type type); - - /** - * Returns the value currently associated with this attribute, if any. The - * values acceptable by this attribute are dictated by the type. - * - * @return - * The value currently associated with this attribute, or null if no - * value is present. - */ - String getValue(); - - /** - * Sets the value currently associated with this attribute, if any. The - * values acceptable by this attribute are dictated by the type. - * - * @param value - * The value to associate with this attribute. - */ - void setValue(String value); + void setType(Type type) { + this.type = type; + } } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/AttributeSet.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/AttributeSet.java deleted file mode 100644 index 8b02b2cd8..000000000 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/AttributeSet.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2015 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package org.glyptodon.guacamole.net.auth.attribute; - -import java.util.Set; -import org.glyptodon.guacamole.GuacamoleException; - -/** - * An arbitrary set of attributes. - * - * @author Michael Jumper - * @param - * The type of attribute stored within this AttributeSet. - */ -public interface AttributeSet { - - /** - * Returns a Set which contains all attributes stored or storable within - * this attribute set. The value of each attribute, if any, is associated - * with the attribute object within the set. The set itself may not be - * mutable. - * - * @return - * A Set containing all attributes stored or storable within this - * attribute set, which may not be mutable. - * - * @throws GuacamoleException - * If an error occurs while retrieving the attributes, or if attributes - * cannot be retrieved due to lack of permissions to do so. - */ - Set getAttributes() throws GuacamoleException; - - /** - * Changes each of the given attributes. If a specified attribute is - * already set, the previous value will be overwritten with the new value. - * If the new value is null, the previous value will be unset. - * - * @param attributes - * The attributes to update. - * - * @throws GuacamoleException - * If an error occurs while updating the attributes, if permission to - * update attributes is denied, or if any one of the given attributes - * is invalid or malformed. - */ - void updateAttributes(Set attributes) - throws GuacamoleException; - -} diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/ObjectAttribute.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/ObjectAttribute.java deleted file mode 100644 index 820f9da90..000000000 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/ObjectAttribute.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) 2015 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package org.glyptodon.guacamole.net.auth.attribute; - -/** - * An attribute which applies to a specific object. - * - * @author Michael Jumper - */ -public class ObjectAttribute implements Attribute { - - /** - * The identifier of the object associated with the attribute. - */ - private String objectIdentifier; - - /** - * The type of value stored within this attribute. - */ - private Type type; - - /** - * A string which uniquely identifies this attribute. - */ - private String identifier; - - /** - * The value currently assigned to this attribute. - */ - private String value; - - /** - * Creates a new ObjectAttribute having the given identifier and type. - * The identifier must be unique with respect to other attributes that - * apply to the same kind of object. - * - * @param identifier - * The string which uniquely identifies this attribute. - * - * @param type - * The type of value stored within this attribute. - */ - public ObjectAttribute(String identifier, Type type) { - this.identifier = identifier; - this.type = type; - } - - /** - * Returns the identifier of the specific object associated with this - * attribute. - * - * @return - * The identifier of the specific object associated with this - * attribute. - */ - public String getObjectIdentifier() { - return objectIdentifier; - } - - /** - * Sets the identifier of the specific object associated with this - * attribute. - * - * @param objectIdentifier - * The identifier of the specific object associated with this - * attribute. - */ - public void setObjectIdentifier(String objectIdentifier) { - this.objectIdentifier = objectIdentifier; - } - - @Override - public Type getType() { - return type; - } - - @Override - public void setType(Type type) { - this.type = type; - } - - @Override - public String getIdentifier() { - return identifier; - } - - @Override - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - @Override - public String getValue() { - return value; - } - - @Override - public void setValue(String value) { - this.value = value; - } - - @Override - public int hashCode() { - - // The identifier always uniquely identifies an attribute - if (identifier != null) - return identifier.hashCode(); - - return 0; - - } - - @Override - public boolean equals(Object obj) { - - // Not equal if null or wrong type - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - - final ObjectAttribute other = (ObjectAttribute) obj; - - // If null identifier, equality depends on whether other identifier - // is null - if (identifier == null) - return other.identifier == null; - - // Otherwise, equality depends entirely on identifier - return identifier.equals(other.identifier); - - } - -} diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/ObjectAttributeSet.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/ObjectAttributeSet.java deleted file mode 100644 index 57def7004..000000000 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/attribute/ObjectAttributeSet.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2015 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package org.glyptodon.guacamole.net.auth.attribute; - -/** - * A set of attributes associated with a particular object or group of objects. - * - * @author Michael Jumper - */ -public interface ObjectAttributeSet extends AttributeSet { -} diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnection.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnection.java index a7f98ec79..f59d205b0 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnection.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnection.java @@ -24,6 +24,7 @@ package org.glyptodon.guacamole.net.auth.simple; import java.util.Collections; import java.util.List; +import java.util.Map; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.environment.Environment; import org.glyptodon.guacamole.environment.LocalEnvironment; @@ -34,7 +35,6 @@ import org.glyptodon.guacamole.net.SSLGuacamoleSocket; import org.glyptodon.guacamole.net.SimpleGuacamoleTunnel; import org.glyptodon.guacamole.net.auth.AbstractConnection; import org.glyptodon.guacamole.net.auth.ConnectionRecord; -import org.glyptodon.guacamole.net.auth.attribute.ObjectAttributeSet; import org.glyptodon.guacamole.protocol.ConfiguredGuacamoleSocket; import org.glyptodon.guacamole.protocol.GuacamoleClientInformation; import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; @@ -98,6 +98,16 @@ public class SimpleConnection extends AbstractConnection { return 0; } + @Override + public Map getAttributes() { + return Collections.emptyMap(); + } + + @Override + public void setAttributes(Map attributes) { + // Do nothing - there are no attributes + } + @Override public GuacamoleTunnel connect(GuacamoleClientInformation info) throws GuacamoleException { @@ -133,9 +143,4 @@ public class SimpleConnection extends AbstractConnection { return Collections.emptyList(); } - @Override - public ObjectAttributeSet getAttributes() throws GuacamoleException { - return new SimpleObjectAttributeSet(); - } - } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnectionGroup.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnectionGroup.java index a302f4676..179a86b64 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnectionGroup.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnectionGroup.java @@ -23,7 +23,9 @@ package org.glyptodon.guacamole.net.auth.simple; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; +import java.util.Map; import java.util.Set; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleSecurityException; @@ -101,6 +103,16 @@ public class SimpleConnectionGroup extends AbstractConnectionGroup { return connectionGroupIdentifiers; } + @Override + public Map getAttributes() { + return Collections.emptyMap(); + } + + @Override + public void setAttributes(Map attributes) { + // Do nothing - there are no attributes + } + @Override public GuacamoleTunnel connect(GuacamoleClientInformation info) throws GuacamoleException { diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleObjectAttributeSet.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleObjectAttributeSet.java deleted file mode 100644 index 0bf395d2b..000000000 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleObjectAttributeSet.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2015 Glyptodon LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package org.glyptodon.guacamole.net.auth.simple; - -import java.util.Collections; -import java.util.Set; -import org.glyptodon.guacamole.GuacamoleException; -import org.glyptodon.guacamole.GuacamoleSecurityException; -import org.glyptodon.guacamole.net.auth.attribute.ObjectAttribute; -import org.glyptodon.guacamole.net.auth.attribute.ObjectAttributeSet; - -/** - * A read-only implementation of ObjectAttributeSet which uses a backing Set - * of Attribute for attribute/value storage. - * - * @author Michael Jumper - */ -public class SimpleObjectAttributeSet implements ObjectAttributeSet { - - /** - * The set of all attributes currently set. - */ - private Set attributes = Collections.emptySet(); - - /** - * Creates a new empty SimpleObjectAttributeSet. - */ - public SimpleObjectAttributeSet() { - } - - /** - * Creates a new SimpleObjectAttributeSet which contains the attributes - * within the given Set. - * - * @param attributes - * The Set of attributes this SimpleObjectAttributeSet should - * contain. - */ - public SimpleObjectAttributeSet(Set attributes) { - this.attributes = attributes; - } - - /** - * Sets the Set which backs this SimpleObjectAttributeSet. Future function - * calls on this SimpleObjectAttributeSet will use the provided Set. - * - * @param attributes - * The Set of attributes this SimpleObjectAttributeSet should - * contain. - */ - protected void setAttributes(Set attributes) { - this.attributes = attributes; - } - - @Override - public Set getAttributes() throws GuacamoleException { - return attributes; - } - - @Override - public void updateAttributes(Set attributes) throws GuacamoleException { - throw new GuacamoleSecurityException("Permission denied."); - } - -} diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUser.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUser.java index 7b9a04653..96171c381 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUser.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUser.java @@ -23,11 +23,13 @@ package org.glyptodon.guacamole.net.auth.simple; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; +import java.util.Map; import java.util.Set; import org.glyptodon.guacamole.GuacamoleException; +import org.glyptodon.guacamole.GuacamoleSecurityException; import org.glyptodon.guacamole.net.auth.AbstractUser; -import org.glyptodon.guacamole.net.auth.attribute.ObjectAttributeSet; import org.glyptodon.guacamole.net.auth.permission.ObjectPermission; import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet; import org.glyptodon.guacamole.net.auth.permission.SystemPermissionSet; @@ -107,6 +109,16 @@ public class SimpleUser extends AbstractUser { } + @Override + public Map getAttributes() { + return Collections.emptyMap(); + } + + @Override + public void setAttributes(Map attributes) { + // Do nothing - there are no attributes + } + @Override public SystemPermissionSet getSystemPermissions() throws GuacamoleException { @@ -137,9 +149,4 @@ public class SimpleUser extends AbstractUser { return new SimpleObjectPermissionSet(); } - @Override - public ObjectAttributeSet getAttributes() throws GuacamoleException { - return new SimpleObjectAttributeSet(); - } - } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUserContext.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUserContext.java index fd558a668..ddbaef80f 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUserContext.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUserContext.java @@ -34,6 +34,7 @@ import org.glyptodon.guacamole.net.auth.ConnectionGroup; import org.glyptodon.guacamole.net.auth.Directory; import org.glyptodon.guacamole.net.auth.User; import org.glyptodon.guacamole.net.auth.UserContext; +import org.glyptodon.guacamole.net.auth.attribute.Attribute; import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; /** @@ -174,4 +175,19 @@ public class SimpleUserContext implements UserContext { return new SimpleDirectory(); } + @Override + public Collection getUserAttributes() { + return Collections.emptyList(); + } + + @Override + public Collection getConnectionAttributes() { + return Collections.emptyList(); + } + + @Override + public Collection getConnectionGroupAttributes() { + return Collections.emptyList(); + } + }