4.2.2 – Handshake plug-in
Handshake plug-in is invoked before establishing a RDP connection. It’s a good place to verify, modify or refuse the connection.
You can put any parameter you want when you create a connection on the client side. For example, you can put user’s session id (session on your portal) into a RDP connection:
var rdp = new svGlobal.Rdp(‘ws://myGateway/RDP?server=myServer&token=mySessionId&…’);
Then in the handshake plug-in, you can get the parameter and verify it through a web server on your portal.
class SimpleHandshakePlugin implements HandshakeInterface{
@Override
public Map<String, String> onHandshake(Map<String, String> parameters) throws ClientException{
String token = parameters.get("token");
if (isInvalidSession(token)){
throw new ClientException("Invalid sessioin");
}
return parameters;
}
You can also encrypt the token from your portal (encrypted on server side), then decrypt it in the plug-in:
public Map<String, String> onHandshake(Map<String, String> parameters) throws ClientException{
String token = decryptToken(token);//throw ClientException if not valid
Map<String, String> paramsFromToken = parseToken(token);
parameters.put(RdpParameter.server, paramsFromToken.get("server"));
parameters.put(RdpParameter.user, paramsFromToken.get("user"));
parameters.put(RdpParameter.pwd, paramsFromToken.get("pwd"));
String userIp = parameters.get(RdpParameter.ARG_CLIENT_IP);
//enable recording
parameters.put(RdpParameter.sessionRecord, "1"); //enable session recording
//specify the recording file name (optional)
parameters.put(RdpParameter.RECRODING_FILE_NAME, "myFileName");
return parameters;
}
Best practices:
- Make sure your plug-in code is thread-safe.
- Make sure your code can be executed in 3-5 seconds, otherwise, please consider running it in a thread.
- You can also use the HTTP API instead if possible.
- Please check the plug-in example on our web site for more details.