GUACAMOLE-96: Extract Attributes interface from objects which provide getAttributes() / setAttributes().

This commit is contained in:
Michael Jumper
2017-10-29 15:33:10 -07:00
parent 79936c4c41
commit fff1411768
5 changed files with 63 additions and 127 deletions

View File

@@ -0,0 +1,59 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.guacamole.net.auth;
import java.util.Map;
/**
* An object which is associated with a set of arbitrary attributes, defined
* as name/value pairs.
*/
public interface Attributes {
/**
* Returns all attributes associated with this object. The returned map
* may not be modifiable.
*
* @return
* A map of all attribute identifiers to their corresponding values,
* for all attributes associated with this object, which may not be
* modifiable.
*/
Map<String, String> getAttributes();
/**
* Sets the given attributes. If an attribute within the map is not
* supported, it will simply be dropped. Any attributes not within the given
* map will be left untouched. Attributes which are not declared within the
* associated UserContext MUST NOT be submitted, but other extensions may
* manipulate the declared attributes through decorate() and redecorate().
*
* Implementations may optionally allow storage of unsupported attributes.
* Extensions which rely on other extensions to store their attribute
* values should verify that such storage is supported by first testing
* that the attribute value is retrievable via getAttributes() after being
* set.
*
* @param attributes
* A map of all attribute identifiers to their corresponding values.
*/
void setAttributes(Map<String, String> attributes);
}

View File

@@ -21,7 +21,6 @@ package org.apache.guacamole.net.auth;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.protocol.GuacamoleConfiguration; import org.apache.guacamole.protocol.GuacamoleConfiguration;
@@ -32,7 +31,7 @@ import org.apache.guacamole.protocol.GuacamoleConfiguration;
* backing GuacamoleConfiguration may be intentionally obfuscated or tokenized * backing GuacamoleConfiguration may be intentionally obfuscated or tokenized
* to protect sensitive configuration information. * to protect sensitive configuration information.
*/ */
public interface Connection extends Identifiable, Connectable { public interface Connection extends Identifiable, Connectable, Attributes {
/** /**
* Returns the name assigned to this Connection. * Returns the name assigned to this Connection.
@@ -82,36 +81,6 @@ public interface Connection extends Identifiable, Connectable {
*/ */
public void setConfiguration(GuacamoleConfiguration config); public void setConfiguration(GuacamoleConfiguration config);
/**
* Returns all attributes associated with this connection. The returned map
* may not be modifiable.
*
* @return
* A map of all attribute identifiers to their corresponding values,
* for all attributes associated with this connection, which may not be
* modifiable.
*/
Map<String, String> getAttributes();
/**
* Sets the given attributes. If an attribute within the map is not
* supported, it will simply be dropped. Any attributes not within the given
* map will be left untouched. Attributes which are not declared within
* getConnectionAttributes() of the associated UserContext MUST NOT be
* submitted, but other extensions may manipulate the declared attributes
* through decorate() and redecorate().
*
* Implementations may optionally allow storage of unsupported attributes.
* Extensions which rely on other extensions to store their attribute
* values should verify that such storage is supported by first testing
* that the attribute value is retrievable via getAttributes() after being
* set.
*
* @param attributes
* A map of all attribute identifiers to their corresponding values.
*/
void setAttributes(Map<String, String> attributes);
/** /**
* Returns the date and time that this connection was last used. If the * Returns the date and time that this connection was last used. If the
* connection was never used, the time that the connection was last used is * connection was never used, the time that the connection was last used is

View File

@@ -19,7 +19,6 @@
package org.apache.guacamole.net.auth; package org.apache.guacamole.net.auth;
import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleException;
@@ -27,7 +26,7 @@ import org.apache.guacamole.GuacamoleException;
* Represents a connection group, which can contain both other connection groups * Represents a connection group, which can contain both other connection groups
* as well as connections. * as well as connections.
*/ */
public interface ConnectionGroup extends Identifiable, Connectable { public interface ConnectionGroup extends Identifiable, Connectable, Attributes {
/** /**
* All legal types of connection group. * All legal types of connection group.
@@ -124,34 +123,4 @@ public interface ConnectionGroup extends Identifiable, Connectable {
public Set<String> getConnectionGroupIdentifiers() public Set<String> getConnectionGroupIdentifiers()
throws GuacamoleException; throws GuacamoleException;
/**
* Returns all attributes associated with this connection group. The
* returned map may not be modifiable.
*
* @return
* A map of all attribute identifiers to their corresponding values,
* for all attributes associated with this connection group, which may
* not be modifiable.
*/
Map<String, String> getAttributes();
/**
* Sets the given attributes. If an attribute within the map is not
* supported, it will simply be dropped. Any attributes not within the given
* map will be left untouched. Attributes which are not declared within
* getConnectionGroupAttributes() of the associated UserContext MUST NOT be
* submitted, but other extensions may manipulate the declared attributes
* through decorate() and redecorate().
*
* Implementations may optionally allow storage of unsupported attributes.
* Extensions which rely on other extensions to store their attribute
* values should verify that such storage is supported by first testing
* that the attribute value is retrievable via getAttributes() after being
* set.
*
* @param attributes
* A map of all attribute identifiers to their corresponding values.
*/
void setAttributes(Map<String, String> attributes);
} }

View File

@@ -25,7 +25,7 @@ import java.util.Map;
* Represents the semantics which apply to an existing connection when shared, * Represents the semantics which apply to an existing connection when shared,
* along with a human-readable name and unique identifier. * along with a human-readable name and unique identifier.
*/ */
public interface SharingProfile extends Identifiable { public interface SharingProfile extends Identifiable, Attributes {
/** /**
* Returns the human-readable name assigned to this SharingProfile. * Returns the human-readable name assigned to this SharingProfile.
@@ -93,34 +93,4 @@ public interface SharingProfile extends Identifiable {
*/ */
public void setParameters(Map<String, String> parameters); public void setParameters(Map<String, String> parameters);
/**
* Returns all attributes associated with this sharing profile. The returned
* map may not be modifiable.
*
* @return
* A map of all attribute identifiers to their corresponding values,
* for all attributes associated with this sharing profile, which may
* not be modifiable.
*/
Map<String, String> getAttributes();
/**
* Sets the given attributes. If an attribute within the map is not
* supported, it will simply be dropped. Any attributes not within the
* given map will be left untouched. Attributes which are not declared
* within getSharingProfileAttributes() of the associated UserContext MUST
* NOT be submitted, but other extensions may manipulate the declared
* attributes through decorate() and redecorate().
*
* Implementations may optionally allow storage of unsupported attributes.
* Extensions which rely on other extensions to store their attribute
* values should verify that such storage is supported by first testing
* that the attribute value is retrievable via getAttributes() after being
* set.
*
* @param attributes
* A map of all attribute identifiers to their corresponding values.
*/
void setAttributes(Map<String, String> attributes);
} }

View File

@@ -21,7 +21,6 @@ package org.apache.guacamole.net.auth;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet; import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
import org.apache.guacamole.net.auth.permission.SystemPermissionSet; import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
@@ -30,7 +29,7 @@ import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
/** /**
* A user of the Guacamole web application. * A user of the Guacamole web application.
*/ */
public interface User extends Identifiable { public interface User extends Identifiable, Attributes {
/** /**
* All standard attribute names with semantics defined by the Guacamole web * All standard attribute names with semantics defined by the Guacamole web
@@ -81,36 +80,6 @@ public interface User extends Identifiable {
*/ */
public void setPassword(String password); public void setPassword(String password);
/**
* Returns all attributes associated with this user. The returned map may
* not be modifiable.
*
* @return
* A map of all attribute identifiers to their corresponding values,
* for all attributes associated with this user, which may not be
* modifiable.
*/
Map<String, String> getAttributes();
/**
* Sets the given attributes. If an attribute within the map is not
* supported, it will simply be dropped. Any attributes not within the given
* map will be left untouched. Attributes which are not declared within
* getUserAttributes() of the associated UserContext MUST NOT be submitted,
* but other extensions may manipulate the declared attributes through
* decorate() and redecorate().
*
* Implementations may optionally allow storage of unsupported attributes.
* Extensions which rely on other extensions to store their attribute
* values should verify that such storage is supported by first testing
* that the attribute value is retrievable via getAttributes() after being
* set.
*
* @param attributes
* A map of all attribute identifiers to their corresponding values.
*/
void setAttributes(Map<String, String> attributes);
/** /**
* Returns the date and time that this user was last active. If the user * Returns the date and time that this user was last active. If the user
* was never active, the time that the user was last active is unknown, or * was never active, the time that the user was last active is unknown, or