Is there a way to connect and disconnect a VPN in Forticlient programmatically?
I see that with the Cisco VPN Client there are options such as using the APIs that they provide or executing the connection commands from my Java code. Opinions and opinions on these methods of connecting to a VPN are also welcome.
I am looking for such options or whatever else is possible with Forticlient software.
Any directions from here will be very helpful.
My trial version:
private static final String COMMAND = "C:/Program Files/Cisco/Cisco AnyConnect Secure Mobility Client/vpncli";
private ExpectJ exp = new ExpectJ(10);
public void connectToVPNViaCLI(String server, String uname, String pwd)
{
try {
String command = COMMAND + " connect " + server;
Spawn sp = exp.spawn(command);
sp.expect("Username: ");
sp.send(uname + "\n");
sp.expect("Password: ");
sp.send(pwd + "\n");
sp.expect("accept? [y/n]: ");
sp.send("y" + "\n");
} catch(Exception e) {
LOGGER.severe(e.getMessage());
}
}
source
share