I have a library that wants me to use java.net.Authenticator.setDefault() if I want it to send its HTTP/HTTPS requests through a proxy that requires a username and a password. However, that library will be used to implement a small feature in a huge application (that I did not write myself) that may use Authenticators for its own needs already. I can ensure that my Authenticator is set last but I do not want the previous Authenticators to cease functionality - they might be needed still. So naturally I try to do the following: set my Auth; when asked for PasswordAuthentication decide whether I should handle the request; if yes, give my credentials; if no, forward the request to whatever the previous authenticator was.
So I hacked this together:
I suppose that the code is terrible but I cannot see why yet. Please explain to me why this is not the way to do it.
What's gotten into you? Could it be this tiny ad?
global solutions you can do in your home or backyard