Class TokenInjectingUserContext

java.lang.Object
org.apache.guacamole.net.auth.DelegatingUserContext
org.apache.guacamole.net.auth.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 Details

    • 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() or addTokens() 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 added by addTokens() or 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 Details

    • getTokens

      protected Map<String,String> getTokens(Connection connection) throws org.apache.guacamole.GuacamoleException
      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. If the values of existing tokens need to be considered, implementations should override addTokens(org.apache.guacamole.net.auth.Connection, java.util.Map) instead.
      Parameters:
      connection - The Connection on which connect() has been called.
      Returns:
      The tokens which should be added to the in-progress call to connect().
      Throws:
      org.apache.guacamole.GuacamoleException - If the tokens applicable to the given connection cannot be generated.
    • addTokens

      protected void addTokens(Connection connection, Map<String,String> tokens) throws org.apache.guacamole.GuacamoleException
      Adds tokens to an in-progress call to connect() for the given Connection. If not overridden, this function will add the tokens returned by getTokens(org.apache.guacamole.net.auth.Connection).
      Parameters:
      connection - The Connection on which connect() has been called.
      tokens - A modifiable Map containing the tokens already supplied to connect().
      Throws:
      org.apache.guacamole.GuacamoleException - If the tokens applicable to the given connection cannot be generated.
    • getTokens

      protected Map<String,String> getTokens(ConnectionGroup connectionGroup) throws org.apache.guacamole.GuacamoleException
      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. If the values of existing tokens need to be considered, implementations should override addTokens(org.apache.guacamole.net.auth.ConnectionGroup, java.util.Map) instead.
      Parameters:
      connectionGroup - The ConnectionGroup on which connect() has been called.
      Returns:
      The tokens which should be added to the in-progress call to connect().
      Throws:
      org.apache.guacamole.GuacamoleException - If the tokens applicable to the given connection group cannot be generated.
    • addTokens

      protected void addTokens(ConnectionGroup connectionGroup, Map<String,String> tokens) throws org.apache.guacamole.GuacamoleException
      Adds tokens to an in-progress call to connect() for the given ConnectionGroup. If not overridden, this function will add the tokens returned by getTokens(org.apache.guacamole.net.auth.ConnectionGroup).
      Parameters:
      connectionGroup - The ConnectionGroup on which connect() has been called.
      tokens - A modifiable Map containing the tokens already supplied to connect().
      Throws:
      org.apache.guacamole.GuacamoleException - If the tokens applicable to the given connection cannot be generated.
    • 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.