-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
None
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
java.net.Socket supports using proxies, but, unlike java.net.HttpURLConnection, there is no setAuthenticator method. Considering that this method was added to HttpURLConnection in Java 9, I think that it would be appropriate to do the same for the Socket class. Minimal changes are required for this to be possible:
1. Add a private field named authenticator to java.net.Socket and a public setAuthenticator(Authenticator) method
2. Modify HttpConnectSocketImpl, the socket implementation for a socket using an http(s) proxy, by setting in the doTunnel method the authenticator of the HttpURLConnection to the one of the delegating socket(this is a one line of code change as HttpURLConnection already has support for setAuthenticator from Java 9)
3. Modify SocksSocketImpl, the socket implementation for a socket using a socks4/5 proxy, to use the authenticator of the delegating socket in the authenticate method instead of calling Authenticator.requestPasswordAuthentication, which uses the default socket.
This change is not breaking as the default authenticator of a Socket would still be the default authenticator, which is the current behaviour.
java.net.Socket supports using proxies, but, unlike java.net.HttpURLConnection, there is no setAuthenticator method. Considering that this method was added to HttpURLConnection in Java 9, I think that it would be appropriate to do the same for the Socket class. Minimal changes are required for this to be possible:
1. Add a private field named authenticator to java.net.Socket and a public setAuthenticator(Authenticator) method
2. Modify HttpConnectSocketImpl, the socket implementation for a socket using an http(s) proxy, by setting in the doTunnel method the authenticator of the HttpURLConnection to the one of the delegating socket(this is a one line of code change as HttpURLConnection already has support for setAuthenticator from Java 9)
3. Modify SocksSocketImpl, the socket implementation for a socket using a socks4/5 proxy, to use the authenticator of the delegating socket in the authenticate method instead of calling Authenticator.requestPasswordAuthentication, which uses the default socket.
This change is not breaking as the default authenticator of a Socket would still be the default authenticator, which is the current behaviour.