public class WebClientSpawner extends ClientSpawner
This class is tricky to understand because the main part of it runs on the server while the
TemporaryClientTask inner class is serialized and sent down to execute on the
client side. That client side code then calls methods which are implemented as a remote
object with the Spawner interface, which the server portions of this class implement.
In the interactive login mode, the spawned process first tries to authenticate the userid and password at the OS level. On success a new process (client) is spawned with those credentials.
In trusted mode, the spawner process will connect to the server using a secure socket and temporary credentials to establish a secure session. If that works, it will lookup the credentials to use for spawning the client based on a unique UUID for this spawning session. Using those credentials it will start the client and notify the server about success or failure.
In both modes, the spawned process will call a remote object method to get the server's KeyStore which is used to start the client's embedded web server. Finally, the client will call a remote object method to notify this (server side) instance about the URI on which the client's embedded web server is listening. If a notification does not occur within a specific amount of time, a failure in spawning is asserted.
| Modifier and Type | Class and Description |
|---|---|
private static class |
WebClientSpawner.TemporaryClientTask
On P2J client side, it will do custom work after authenticating using the temporary
credentials.
|
| Modifier and Type | Field and Description |
|---|---|
private WebClientBuilderParameters |
buildParams
The configuration for this spawner.
|
private WebClientBuilder |
cb
The
WebClientBuilder used to spawn the P2J client process. |
private boolean |
gui
Flag that denotes client type (
true for GUI, false for ChUI). |
private static CentralLogger |
LOG
Logger.
|
static java.lang.String |
PARAM_TOKEN
Authorization token query parameter name
|
private java.lang.String |
remoteUri
Remote server URI
|
private ServerKeyStore |
serverKeyStore
Server key store
|
private WebClientsManager |
webClientsManager
The web clients manager
|
CLIENT_STARTUP_TIMEOUT_SEC| Constructor and Description |
|---|
WebClientSpawner(WebClientBuilderParameters cfg,
WebClientsManager webClientsManager)
Create a new web client spawner.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
add(java.util.List<java.lang.String> cmd,
ConfigItem clientConfig,
java.util.Map<java.lang.String,java.lang.String> webClientOptions)
Convenience method to shorten the syntax of adding new options to the list of client params.
|
void |
clientIsReady(java.lang.String data)
Notify when the client has started.
|
protected WebClientBuilder |
getBuilder()
Get a
WebClientBuilder used to spawn P2J clients. |
WebClientBuilderParameters |
getBuildParams()
Get
WebClientBuilderParameters used to spawn P2J clients. |
java.util.List<java.lang.String> |
getClientConfig(java.lang.String uuid,
java.lang.String projectToken)
Returns a list of client configs in the option format "category:group:key=value".
|
private static java.lang.String |
getForwardedUri(java.lang.String forwardedProto,
java.lang.String forwardedHost,
java.lang.String webRoot)
Get the external web client uri assigned by the reverse proxy server.
|
java.lang.String |
getRemoteUri()
Get the remote server URI to which the browser will be redirected.
|
private ServerKeyStore |
getServerData()
Get the server key store.
|
TemporaryClient |
getTemporaryClient(java.lang.String uuid,
java.lang.String projectToken)
Get a
TemporaryClient worker which will do the work after authenticating on the P2J
server using the temporary credentials. |
private java.util.List<java.lang.String> |
prepareBootstrapValues(java.util.Map<java.lang.String,java.lang.String> options,
boolean isGui,
boolean isRemote,
java.util.List<java.lang.String> cfgOverrides,
java.util.List<java.lang.String> webOverrides) |
void |
releaseClient()
Releases the system resources for this spawned client.
|
spawn, spawnpublic static final java.lang.String PARAM_TOKEN
private static final CentralLogger LOG
private final WebClientBuilderParameters buildParams
private volatile java.lang.String remoteUri
private boolean gui
true for GUI, false for ChUI).private final WebClientsManager webClientsManager
private final ServerKeyStore serverKeyStore
private final WebClientBuilder cb
WebClientBuilder used to spawn the P2J client process.public WebClientSpawner(WebClientBuilderParameters cfg, WebClientsManager webClientsManager)
cfg - The web client builder parameterswebClientsManager - The web clients managerpublic WebClientBuilderParameters getBuildParams()
WebClientBuilderParameters used to spawn P2J clients.getBuildParams in class ClientSpawnerpublic void clientIsReady(java.lang.String data)
clientIsReady in interface SpawnerListenerclientIsReady in class ClientSpawnerdata - Custom data sent by the P2J client back to the server. For web clients, this is
the remote URI to which it will redirect the browser.protected WebClientBuilder getBuilder()
WebClientBuilder used to spawn P2J clients.getBuilder in class ClientSpawnerpublic java.lang.String getRemoteUri()
throws java.net.URISyntaxException
null.java.net.URISyntaxExceptionpublic TemporaryClient getTemporaryClient(java.lang.String uuid, java.lang.String projectToken)
TemporaryClient worker which will do the work after authenticating on the P2J
server using the temporary credentials.uuid - The client identifier uuid.projectToken - The project token to be set for the temporary session.private ServerKeyStore getServerData()
public void releaseClient()
public java.util.List<java.lang.String> getClientConfig(java.lang.String uuid,
java.lang.String projectToken)
uuid - Remote client identifier uuid.projectToken - The project token.private static java.lang.String getForwardedUri(java.lang.String forwardedProto,
java.lang.String forwardedHost,
java.lang.String webRoot)
private java.util.List<java.lang.String> prepareBootstrapValues(java.util.Map<java.lang.String,java.lang.String> options,
boolean isGui,
boolean isRemote,
java.util.List<java.lang.String> cfgOverrides,
java.util.List<java.lang.String> webOverrides)
options - Base options.isGui - Flag to indicate if it's a gui web driver.isRemote - Flag to indicate if it's a remote spawn.cfgOverrides - clientConfig/cfgOverrides resolved with the project token.webOverrides - webClient/webOverrides + runtime. Default startup procedure (for embedded). Forked session
cfgOverrides. client:web:embedded. Selected UI theme. webRoot, login / logout url.private void add(java.util.List<java.lang.String> cmd,
ConfigItem clientConfig,
java.util.Map<java.lang.String,java.lang.String> webClientOptions)
cmd - The list of entries comprising the command.clientConfig - The config to add to the command.webClientOptions - The options to get the value from.