Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Authenticator on a per connection basis?
    text
    copied!<p>I'm building an Eclipse plugin that talks to a REST interface which uses Basic Authentication. When the authentication fails I would like to popup my plugin's settings dialog and retry. Normally I could use the static <code>Authenticator.setDefault()</code> to setup an authenticator for all <code>HttpURLConnection</code>'s for this, but since I am writing a plugin I don't want to overwrite Eclipse's default <code>Authenticator</code> (<code>org.eclipse.ui.internal.net.auth</code>);</p> <p>I thought of setting my custom <code>Authenticator</code> before loading and putting Eclipse's default back afterwards, but I imagine this will cause all sorts of race issues with multithreading so I quickly lost that notion.</p> <p>Google searches yield all sorts of results basically telling me it's not possible:</p> <blockquote> <p>The Java URLConnection API should have a setAuthenticator(Authenticator) method for making it easier to use this class in multi-threaded context where authentication is required.</p> </blockquote> <p><a href="http://blog.taragana.com/index.php/archive/java-tip-basic-authentication-with-httpurlconnection/" rel="noreferrer">Source</a></p> <blockquote> <p>If applications contains few third party plugins and each plugin use its own Authenticator what we should do? Each invocation of "Authenticator.setDefault()" method rewrite previously defined Authenticator...</p> </blockquote> <p><a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4941958" rel="noreferrer">Source</a></p> <p>Are there any different approaches that might help me overcome this issue?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload