On Tue, Jun 20, 2023 at 4:32 PM Gabriel Huerta Araujo <[email protected]> wrote: > > Hi > > I am trying to create a REST Service call where organization is passed as > parameter and all tokens associated to this organization can be filtered. > > public Map<String, String> getAllTokens(String organization) throws > GuacamoleException { > final Map<String, String> tokens = new HashMap<String, > String>(); > for (Map.Entry<String, GuacamoleSession> entry : > this.sessionMap.entrySet()) { > // Here I want to make a decision > where organization passed as parameter is equal to user organization, can be > inserted into map, but I do not know how I can accomplish it. > tokens.put(entry.getKey(), > entry.getValue().getAuthenticatedUser() > .getCredentials().getUsername()); > } > return tokens; > } > > Is there some link which explains all classes related to this subject?
You can view the guacamole-ext documentation here: https://guacamole.apache.org/doc/guacamole-ext/ The user's organization is an Attribute, so it'd be something like: GuacamoleSession session = entry.getValue(); tokens.put(entry.getKey(), session.getUserContext(session.getAuthenticatedUser().getAuthenticationProvider().getIdentifier()).self().getAttributes(User.Attribute.ORGANIZATION)); That's just a quick stab at it based on the class documentation, and without factoring in where you're running your getAllTokens() method, what permissions it is running with, and that there may be an easier way to get the information you're wanting. That said, I'm not sure why you're wanting to do what the code looks like you're doing - it looks to me like you'd end up with a set of Guacamole parameter tokens where the name is the session identifier (entry.getKey()) and the value is the organization the user belongs to. Since session identifiers are going to be random, this wouldn't be a very useful token for any configuration purposes - it'll be different for every single user, and different every time a user logs in.. Maybe you could describe, at a higher level, what you're trying to accomplish? -Nick --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
