benratti / javapns

Automatically exported from code.google.com/p/javapns
0 stars 0 forks source link

Adding Proxy-Authorization #104

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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 reported on code.google.com by i42lo...@gmail.com on 2 Feb 2012 at 8:32

GoogleCodeExporter commented 9 years ago

Original comment by sype...@gmail.com on 3 Feb 2012 at 3:32

GoogleCodeExporter commented 9 years ago

Original comment by sype...@gmail.com on 21 Feb 2012 at 3:42

GoogleCodeExporter commented 9 years ago
Fixed in r361.

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

Original comment by sype...@gmail.com on 24 Feb 2012 at 4:19

GoogleCodeExporter commented 9 years ago
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.

Original comment by cox1...@gmail.com on 23 Aug 2012 at 11:39

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I found the bugs related to this feature. The fixes from issue 142 and issue 
143 make the HTTP 407 disappear.

Original comment by cox1...@gmail.com on 27 Aug 2012 at 2:29