Package org.apache.guacamole.net.auth
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 Summary
Constructors Constructor Description 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.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addTokens(ConnectionGroup connectionGroup, Map<String,String> tokens)
Adds tokens to an in-progress call to connect() for the given ConnectionGroup.protected void
addTokens(Connection connection, Map<String,String> tokens)
Adds tokens to an in-progress call to connect() for the given Connection.Directory<Connection>
getConnectionDirectory()
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.Directory<ConnectionGroup>
getConnectionGroupDirectory()
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.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.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.-
Methods inherited from class org.apache.guacamole.net.auth.DelegatingUserContext
getActiveConnectionDirectory, getAuthenticationProvider, getConnectionAttributes, getConnectionGroupAttributes, getConnectionHistory, getDelegateUserContext, getPrivileged, getResource, getRootConnectionGroup, getSharingProfileAttributes, getSharingProfileDirectory, getUserAttributes, getUserDirectory, getUserGroupAttributes, getUserGroupDirectory, getUserHistory, invalidate, self
-
-
-
-
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() 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 Detail
-
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 overrideaddTokens(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 bygetTokens(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 overrideaddTokens(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 bygetTokens(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 interfaceUserContext
- Overrides:
getConnectionGroupDirectory
in classDelegatingUserContext
- 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 interfaceUserContext
- Overrides:
getConnectionDirectory
in classDelegatingUserContext
- 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.
-
-