7

I would like to connect to an REST Web Service through a VPN. Is there a way in Java to establish an pptp, l2tp ipsec connection to the VPN gateway an tunnel the HTTP request, without using the Operation System functions? This is important because I will connected to several rest services from a servlet. This Services could be behind different VPNs and I do not want to connect the network of the server with this VPNs.

Do anyone know about an API for that?

3 Answers 3

7

If you want to connect to a server behind a private VPN, from the outside, nothing you can do on you app can/will allow you to do connect. Unless you launch a VPN client and programmatically connect your network, to that VPN server, your java app will just sit there waiting for a socket on http connect.

Your question is technically incorrect (not from the SO point of view).

Look for a VPN client library that will pop up a dialog and take username/pwd.

Sign up to request clarification or add additional context in comments.

3 Comments

Is there any way to let the java app to just work? It is very inconvenient since my app is not working when I am in the company's network even though I setup proxy
Not really. VPN's main use is for that purpose. Prevent unauthorised access.
@mschenk74 answer below is also relevant.
3

A VPN has the purpose of connecting networks. If you want to reach another system via a VPN you will have to establish a network connection.

a Java API for all of this protocols will be (nearly) impossible, since VPN is handled by OS drivers and not on the application level (where java has its place) in most cases.

If you don't want to have your physical server being connected with those VPNs, you could perhaps set up a virtual system with virtualbox or vmware (or others) which handles all those connections and use it as a proxy. But this is no java issue than.

6 Comments

Yes thanks i see the problem, this is on the network layer not in the application. What is about an ssl vpn connection? this should be possible to establich form inside of an application. Do you something about that?
I know that there have been some ssl-vpn clients implemented as java applets - this could be a starting point for a search but I don't know if the use of applets is a good idea after the latest security changes by oracle. Those clients often had issues when using the latest jdk/jre versions.
So, nothing I can do to execute a http request with Java app in a computer in a vpn network?
@Jaskey If the vpn is set up properly on the operating system level, then the http request should work if the target ip can be accessed via the vpn.
@mschenk74 , how to confirm if my vpn is set up on the os level? Neither of the below case work :1. connect the network in my company. 2, connect to the vpn using any connect to my company's network at home. Thank you!
|
0

Here is a simple Java API that allows you to use Nord. I've made several bash scripts that also allow me to start, end and cycle NordIKE-VPN sessions. I have not used this yet, but I am intending on repurposing it for use with Android.

https://github.com/yaniferhaoui/NordVPN-Public-Java-API

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.