import java.net.Authenticator; //... // hooking up your custom Authenticator Authenticator.setDefault( new MyAuthenticator() );