I'm working on a project where I have to send HTTP requests through multiple servers, encrypt and decrypt them, encrypt and decrypt responses.
Here is the idea:
- I send requests from a web browser on which I configure proxy settings (via SwitchyOmega because I can't modify my connection proxy settings) to connect to "Server 1"
- "Server 1" receive the request as a byte array
- "Server 1" encrypt the request
- "Server 1" send the encrypted request to "Server 2" via "Proxy"
- "Server 2" decrypt request
- "Server 2" execute request
- "Server 2" get response
- "Server 2" encrypt the response
- "Server 2" send the encrypted response to "Server 1" 10."Server 1" decrypt the response and send it to the web browser.
here is a little diagram:
I don't have access to "proxy", but everything is on my hand for "Server 1" and "Server 2". They preferably have to be little portable java applications.
I found a lot of things about making a proxy with java but as my "Server 1" receive request as a byte array, i would like to find an API that can execute it correctly. I tries by converting the bytes to String, get host and port and using things like URLConnection yc = oracle.openConnection(); or HttpURLConnection con = (HttpURLConnection) obj.openConnection(); but I had to parse the byte[] to retrieve informations such as methodes (get, post,...), host, port, protocol,... and rebuild the query. As the request is already build, it seems a lot for nothing.
I have read a lot about Apache Commons HttpClient which seems great, but I did not find a way to execute correctly the queries.
Is there a way for Apache Commons HttpClient to execute raw bytes queries? Or do you have another suggetion to execute raw bytes queries?