Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 5th, 2004, 03:56 PM
MattSidesinger's Avatar
MattSidesinger MattSidesinger is offline
Java PHP Oracle Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: C-Bus OH-IO
Posts: 204 MattSidesinger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 26 sec
Reputation Power: 10
Send a message via AIM to MattSidesinger
Connecting through a proxy WSAD / BorderManager / JSSE

I am trying to get the InputStream from a URLConnection object. The connection must be established with the Internet through a proxy.

My code stops at the following line: line = reader.readLine();

I already asked my security guys if I could tunnel through and they change the setting on the proxy server to allow for HTTP tunelling and they said no because it is a security risk.


Here is my environment:
IBM WebSphere Application Developer 4.03 w/ JDK 1.3.1
Proxy Server: Novell Border Manager
I have jecert.jar, jnet.jar and jsse.jar in my classpath and they are located here: C:\Program Files\IBM\Application Developer\jre\lib\ext
(I was told I need to use the SUN classes and not the IBM ones)


From my java.security file:
security.provider.1=sun.security.provider.Sun
security.provider.2=com.sun.net.ssl.internal.ssl.Provider
security.provider.3=com.ibm.crypto.provider.IBMJCA


Here is my code:
Code:
package com.MattSidesinger.test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.security.Security;

import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;

public class ProxyConnectionTester
{

	public static void main(String[] args)
	{
		try
		{
			// Set the system and security properties
			System.setProperty("javax.net.ssl.trustStore", "C:\\cacerts1");
		    	System.setProperty("javax.net.ssl.trustStorePassword", "password");

		    	// Keystore location and password	
	     		System.setProperty("javax.net.ssl.keyStore", "C:\\cacerts1");
		    	System.setProperty("javax.net.ssl.keyStorePassword", "password");
		    	
			System.setProperty("proxyHost","bmserver");
			System.setProperty("proxyPort","8080");
			System.setProperty("proxyUserName","username");
			System.setProperty("proxyPassword","password");
			System.setProperty("proxySet","true");
			System.setProperty("http.proxyHost","bmserver");
			System.setProperty("http.proxyPort","8080");
			System.setProperty("http.proxyUserName","username");
			System.setProperty("http.proxyPassword","password");
			System.setProperty("http.proxySet","true");
			System.setProperty("https.proxyHost","bmserver");
			System.setProperty("https.proxyPort","8080");
			System.setProperty("https.proxyUserName","username");
			System.setProperty("https.proxyPassword","password");
			System.setProperty("https.proxySet","true");
   		    	System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
		    	
			Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
			
			// connect to get the web page
			URL url = new URL("http://www.google.com");
			URLConnection connection = url.openConnection();
						
			// get the contents of the web page
			InputStream stream = connection.getInputStream();
			BufferedReader reader = new BufferedReader(new InputStreamReader(stream));

			// read in the entire web page
			StringBuffer webPage = new StringBuffer();
			String line = null;
			
			while(true)
			{
				line = reader.readLine(); // STOPS HERE
				if (line == null)
				{
					break;
				}
				webPage = webPage.append(line);
			}
								
			// close all resources that we do not need
			// now that the web page has been obtained			
			stream.close();
			reader.close();
			
		}
		catch (MalformedURLException e)
		{
			System.out.println("MalformedURLException");
		}
		catch (IOException e)
		{
			System.out.println(e.toString());		
		}
	}
}




There were no errors when I installed the certificates to the keystore using the keytool.



I will keep you updated if I have any further advances.

Reply With Quote
  #2  
Old February 6th, 2004, 09:31 AM
MattSidesinger's Avatar
MattSidesinger MattSidesinger is offline
Java PHP Oracle Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: C-Bus OH-IO
Posts: 204 MattSidesinger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 26 sec
Reputation Power: 10
Send a message via AIM to MattSidesinger
I get the following when trying to connect when using the SSLSocketClientWithTunneling class that Sun wrote. This may offer some insight.

Code:
java.io.IOException: Unable to tunnel through bmserver:8080.  Proxy returns "HTTP/1.0 302 Moved Temporarily"
	at com.MattSidesinger.test.SSLSocketClientWithTunneling.doTunnelHandshake(SSLSocketClientWithTunneling.  java:348)
	at com.MattSidesinger.test.SSLSocketClientWithTunneling.doIt(SSLSocketClientWithTunneling.java:140)
	at com.MattSidesinger.test.SSLSocketClientWithTunneling.main(SSLSocketClientWithTunneling.java:110)
javax.net.ssl.SSLException: Unrecognized SSL handshake.
	at com.sun.net.ssl.internal.ssl.InputRecord.read(DashoA6275)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
	at com.sun.net.ssl.internal.ssl.AppOutputStream.write(DashoA6275)
	at java.io.OutputStream.write(OutputStream.java:67)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(DashoA6275)
	at com.MattSidesinger.test.SSLSocketClientWithTunneling.doIt(SSLSocketClientWithTunneling.java:238)
	at com.MattSidesinger.test.SSLSocketClientWithTunneling.main(SSLSocketClientWithTunneling.java:110)

Last edited by MattSidesinger : February 6th, 2004 at 09:44 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Connecting through a proxy WSAD / BorderManager / JSSE

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap