Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

TOR java implementation

843790Dec 13 2009 — edited Dec 13 2009
i need to write the simplest TOR(the onion routing) implementation in java. now i need core of this whole thing which should looks as follows:

Suppose that client send via browser request from machine A to machine B. Request is redirected to java server proxy (P). P encodes each request and sends it to machine C. Machine C after decrypting it, sends orginal request to destination machine B which waits for response and sends it back to request source (A).

Any idea how to do it(procedure from above) in simplest way ?
If no, maybe you can try help me with this:

I found example of proxy in java: http://uncc.dyndns.info/2007/11/27/a-simple-multi-threaded-java-http-proxy-server/ , but it doesn't work properly for all sites. For example google.com ain't working (i guess all sites containing ajax, flash, non-text content won't work correctly). So i would like to improve this example to be able to recive all kinds of content.
I think that i will understand why thic code don't work properly when someone explains to me why 2 pieces of code below behaves diffrently. First one produces what i expekt (entire response), second one only beginning.


//first
		URL url = new URL("http://www.google.com/");
		BufferedReader in = new BufferedReader(
					new InputStreamReader(
					url.openStream()));

		String inputLine;

		while ((inputLine = in.readLine()) != null)
		    System.out.println(inputLine);
		in.close();


		//second
		URL url2 = new URL("http://www.google.com/"); 
    	URLConnection conn2 = url2.openConnection();
    	HttpURLConnection conn22 = (HttpURLConnection)conn2;
		InputStream in2 = conn22.getInputStream();

		byte by[] = new byte[ BUFFER_SIZE ];
        int index = in2.read( by, 0, BUFFER_SIZE );
        for(int i = 0; i < by.length; i++) {
        	System.out.print("" + (char)by);
}
Edited by: azedor on Dec 13, 2009 3:16 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 10 2010
Added on Dec 13 2009
1 comment
702 views