
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.Authenticator;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;

public class JI9051583 {

	static final String HOSTNAME = "http://www.oracle.com";

	public static void main(String[] args) throws Exception {
		// Create a SOCKS V4 proxy
		SocksServer srvr = new SocksServer(8888, true);
		srvr.addUser("pallavi","abc");
		srvr.start();


		Authenticator.setDefault(new Authenticator() {
			@Override
			protected java.net.PasswordAuthentication getPasswordAuthentication() {
				return new java.net.PasswordAuthentication(
						"pallavi", "abc".toCharArray());
			}
		}); 

		Proxy sp = new Proxy(Proxy.Type.SOCKS,
				new InetSocketAddress("localhost", 8888));
		try { 
			URL url = new URL(HOSTNAME); 
			URLConnection conn = url.openConnection(sp); 
			BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); 
			String inputLine; 
			while ((inputLine = in.readLine()) != null) 
				System.out.println(inputLine); 
			in.close(); 
		} catch (Exception e) { 
			e.printStackTrace(); 
		} 
	}

}
