Class TokenInjectingUserContext

  • All Implemented Interfaces:
    UserContext

    public class TokenInjectingUserContext
    extends DelegatingUserContext
    UserContext implementation which decorates a given UserContext, automatically applying additional parameter tokens during the connection process of any retrieved Connections and ConnectionGroups.
    • Constructor Detail

      • TokenInjectingUserContext

        public TokenInjectingUserContext​(UserContext userContext,
                                         Map<String,​String> tokens)
        Wraps the given UserContext, overriding the connect() function of each retrieved Connection and ConnectionGroup such that the given additional parameter tokens are included. Any additional tokens which have the same name as existing tokens will override the existing values. If tokens specific to a particular connection or connection group need to be included, getTokens() may be overridden to provide a different set of tokens.
        Parameters:
        userContext - The UserContext to wrap.
        tokens - The additional tokens to include with each call to connect().
      • TokenInjectingUserContext

        public TokenInjectingUserContext​(UserContext userContext)
        Wraps the given UserContext, overriding the connect() function of each retrieved Connection and ConnectionGroup such that the additional parameter tokens returned by getTokens() are included. Any additional tokens which have the same name as existing tokens will override the existing values.
        Parameters:
        userContext - The UserContext to wrap.
    • Method Detail

      • getTokens

        protected Map<String,​String> getTokens​(Connection connection)
        Returns the tokens which should be added to an in-progress call to connect() for the given Connection. If not overridden, this function will return the tokens provided when this instance of TokenInjectingUserContext was created.
        Parameters:
        connection - The Connection on which connect() has been called.
        Returns:
        The tokens which should be added to the in-progress call to connect().
      • getTokens

        protected Map<String,​String> getTokens​(ConnectionGroup connectionGroup)
        Returns the tokens which should be added to an in-progress call to connect() for the given ConnectionGroup. If not overridden, this function will return the tokens provided when this instance of TokenInjectingUserContext was created.
        Parameters:
        connectionGroup - The ConnectionGroup on which connect() has been called.
        Returns:
        The tokens which should be added to the in-progress call to connect().
      • getConnectionGroupDirectory

        public Directory<ConnectionGroup> getConnectionGroupDirectory()
                                                               throws org.apache.guacamole.GuacamoleException
        Description copied from interface: UserContext
        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.
        Specified by:
        getConnectionGroupDirectory in interface UserContext
        Overrides:
        getConnectionGroupDirectory in class DelegatingUserContext
        Returns:
        A Directory whose operations are bound by the permissions of the user.
        Throws:
        org.apache.guacamole.GuacamoleException - If an error occurs while creating the Directory.
      • getConnectionDirectory

        public Directory<Connection> getConnectionDirectory()
                                                     throws org.apache.guacamole.GuacamoleException
        Description copied from interface: UserContext
        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.
        Specified by:
        getConnectionDirectory in interface UserContext
        Overrides:
        getConnectionDirectory in class DelegatingUserContext
        Returns:
        A Directory whose operations are bound by the permissions of the user.
        Throws:
        org.apache.guacamole.GuacamoleException - If an error occurs while creating the Directory.