mwkirk / javapns

Test import of svn javapns repo from Google Code
3 stars 0 forks source link

Adding Proxy-Authorization #104

Closed mwkirk closed 11 years ago

mwkirk commented 11 years ago

Original author: i42lo...@gmail.com (February 02, 2012 08:32:29)

If we want to use a proxy authentification, we should modify the next code in function doTunnelHandshake(Socket tunnel, String host, int port):

OutputStream out = tunnel.getOutputStream();

String msg = "CONNECT " + host + ":" + port + " HTTP/1.0\n" + "User-Agent: BoardPad Server\n";

sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder(); String pwd = "USER" + ":" + "PASSWORD"; String encodedUserPwd = encoder.encode(pwd.getBytes()); msg += "Proxy-Authorization: " + "Basic " + encodedUserPwd + "\r\n\r\n";

Bye!

Original issue: http://code.google.com/p/javapns/issues/detail?id=104

mwkirk commented 11 years ago

From sype...@gmail.com on February 24, 2012 04:19:49 Fixed in r361.

Invoke ProxyManager.setProxyBasicAuthorization(username, password), or ProxyManager.setProxyAuthorization(encodedAuthorization) to configure the proxy authorization header.

mwkirk commented 11 years ago

From cox1...@gmail.com on August 23, 2012 11:39:04 Is this tested? I just tried and got a CommunicationException: Communication exception: java.io.IOException: Unable to tunnel through. Proxy returns "HTTP/1.1 407 Proxy Authentication Required"

I did some Java tests about how to pass the proxy. I know that it works using Apache HTTP components (HttpClient). Check their code, they have probably the right way to do it.

mwkirk commented 11 years ago

From cox1...@gmail.com on August 27, 2012 14:29:50 I found the bugs related to this feature. The fixes from issue 142 and issue 143 make the HTTP 407 disappear.