To handle basic, digest or NTLM authentication you can use the NetworkDelegate.onAuthRequired(AuthRequiredParams params) handler.


To display authentication dialog where user can enter valid user name and password you must register default Swing/JavaFX implementation of the NetworkDelegate or your own implementation of the NetworkDelegate interface.


The following example demonstrates how to register and override default Swing implementation of the NetworkDelegate interface in order to provide user name and password without displaying authorization dialog:

browser.getContext().getNetworkService().setNetworkDelegate(new DefaultNetworkDelegate() {
    @Override
    public boolean onAuthRequired(AuthRequiredParams params) {
        if (!params.isProxy()) {
            params.setUsername("proxy-username");
            params.setPassword("proxy-password");
            // Don't cancel authentication
            return false;
        }
        // Cancel authentication
        return true;
    }
});