mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 17:13:21 +00:00 
			
		
		
		
	GUACAMOLE-524: Remove Attributes interface from AuthenticatedUser. Rely instead on tokens injected via decoration of connections.
This commit is contained in:
		| @@ -20,7 +20,6 @@ | ||||
| package org.apache.guacamole.net.auth; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
|  | ||||
| /** | ||||
| @@ -42,14 +41,4 @@ public abstract class AbstractAuthenticatedUser extends AbstractIdentifiable | ||||
|         // Nothing to invalidate | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Map<String, String> getAttributes() { | ||||
|         return Collections.<String, String>emptyMap(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void setAttributes(Map<String, String> attributes) { | ||||
|         //do nothing | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -25,7 +25,7 @@ import java.util.Set; | ||||
|  * A user of the Guacamole web application who has been authenticated by an | ||||
|  * AuthenticationProvider. | ||||
|  */ | ||||
| public interface AuthenticatedUser extends Identifiable, Attributes { | ||||
| public interface AuthenticatedUser extends Identifiable { | ||||
|  | ||||
|     /** | ||||
|      * The identifier reserved for representing a user that has authenticated | ||||
|   | ||||
| @@ -21,8 +21,6 @@ package org.apache.guacamole.token; | ||||
|  | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.Date; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| import org.apache.guacamole.net.auth.AuthenticatedUser; | ||||
| import org.apache.guacamole.net.auth.Credentials; | ||||
|  | ||||
| @@ -81,11 +79,6 @@ public class StandardTokens { | ||||
|      */ | ||||
|     private static final String TIME_FORMAT = "HHmmss"; | ||||
|  | ||||
|     /** | ||||
|      * The prefix of the arbitrary attribute tokens. | ||||
|      */ | ||||
|     public static final String ATTR_TOKEN_PREFIX = "GUAC_ATTR_"; | ||||
|  | ||||
|     /** | ||||
|      * This utility class should not be instantiated. | ||||
|      */ | ||||
| @@ -155,11 +148,10 @@ public class StandardTokens { | ||||
|      * Adds tokens which are standardized by guacamole-ext to the given | ||||
|      * TokenFilter using the values from the given AuthenticatedUser object, | ||||
|      * including any associated credentials. These standardized tokens include | ||||
|      * the current username (GUAC_USERNAME), password (GUAC_PASSWORD), the | ||||
|      * server date and time (GUAC_DATE and GUAC_TIME respectively), and custom | ||||
|      * user attributes. If either the username or password are not set within | ||||
|      * the given user or their provided credentials, the corresponding token(s) | ||||
|      * will remain unset. | ||||
|      * the current username (GUAC_USERNAME), password (GUAC_PASSWORD), and the | ||||
|      * server date and time (GUAC_DATE and GUAC_TIME respectively). If either | ||||
|      * the username or password are not set within the given user or their | ||||
|      * provided credentials, the corresponding token(s) will remain unset. | ||||
|      * | ||||
|      * @param filter | ||||
|      *     The TokenFilter to add standard tokens to. | ||||
| @@ -177,33 +169,6 @@ public class StandardTokens { | ||||
|         // Add tokens specific to credentials | ||||
|         addStandardTokens(filter, user.getCredentials()); | ||||
|  | ||||
|         // Add custom attribute tokens | ||||
|         addAttributeTokens(filter, user.getAttributes()); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Add attribute tokens to StandardTokens.  These are arbitrary | ||||
|      * key/value pairs that may be configured by the various authentication | ||||
|      * extensions. | ||||
|      * | ||||
|      * @param filter | ||||
|      *     The TokenFilter to add attribute tokens to. | ||||
|      * | ||||
|      * @param attributes | ||||
|      *     The map of key/value pairs to add tokens for. | ||||
|      */ | ||||
|     public static void addAttributeTokens(TokenFilter filter, | ||||
|             Map<String, String> attributes) { | ||||
|  | ||||
|         if (attributes != null) { | ||||
|             for (Map.Entry entry : attributes.entrySet()) { | ||||
|                 String key = entry.getKey().toString(); | ||||
|                 String tokenName = ATTR_TOKEN_PREFIX + key.toUpperCase(); | ||||
|                 String tokenValue = entry.getValue().toString(); | ||||
|                 filter.setToken(tokenName, tokenValue); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user