From ea655cf71148756ab541381d017f782f95bbd5d2 Mon Sep 17 00:00:00 2001 From: phansson Date: Mon, 18 Sep 2017 17:28:33 +0200 Subject: [PATCH 1/2] Improve Javadoc --- o.n.core/src/org/netbeans/core/NbAuthenticator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/o.n.core/src/org/netbeans/core/NbAuthenticator.java b/o.n.core/src/org/netbeans/core/NbAuthenticator.java index 7c165882e3a4..fb1a823ca4d8 100644 --- a/o.n.core/src/org/netbeans/core/NbAuthenticator.java +++ b/o.n.core/src/org/netbeans/core/NbAuthenticator.java @@ -54,7 +54,8 @@ import org.openide.util.NbPreferences; import org.openide.util.NetworkSettings; -/** Global password protected sites Authenticator for IDE +/** Global password protected sites/proxies Authenticator for IDE + * or Platform apps. * * @author Jiri Rechtacek */ From a9c77fde22821733bc7f74aa4f3f5fb35678b61d Mon Sep 17 00:00:00 2001 From: phansson Date: Mon, 18 Sep 2017 18:32:20 +0200 Subject: [PATCH 2/2] Allow custom Authenticator --- .../src/org/netbeans/core/NbAuthenticator.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/o.n.core/src/org/netbeans/core/NbAuthenticator.java b/o.n.core/src/org/netbeans/core/NbAuthenticator.java index fb1a823ca4d8..66cf965a270a 100644 --- a/o.n.core/src/org/netbeans/core/NbAuthenticator.java +++ b/o.n.core/src/org/netbeans/core/NbAuthenticator.java @@ -43,6 +43,7 @@ */ package org.netbeans.core; +import java.net.Authenticator; import java.net.PasswordAuthentication; import java.net.URL; import java.util.logging.Level; @@ -50,6 +51,7 @@ import java.util.prefs.Preferences; import org.openide.DialogDescriptor; import org.openide.DialogDisplayer; +import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.openide.util.NbPreferences; import org.openide.util.NetworkSettings; @@ -61,6 +63,7 @@ */ final class NbAuthenticator extends java.net.Authenticator { + private static final Logger LOGGER = Logger.getLogger(NbAuthenticator.class.getName()); private static final long TIMEOUT = 3000; private static long lastTry = 0; @@ -71,7 +74,19 @@ private NbAuthenticator() { static void install() { if (Boolean.valueOf(NbBundle.getMessage(GuiRunLevel.class, "USE_Authentication"))) { - setDefault(new NbAuthenticator()); + // Look for custom authenticator + Authenticator authenticator = Lookup.getDefault().lookup(Authenticator.class); + if (authenticator == null) { + authenticator = new NbAuthenticator(); + } + if (authenticator.getClass().equals(NbAuthenticator.class)) { + LOGGER.log(Level.FINE, "Standard Authenticator, {0}, will be used as Authenticator.", + authenticator.getClass().getName()); + } else { + LOGGER.log(Level.FINE, "Custom Authenticator, {0}, was found in Global Lookup and will be used as Authenticator.", + authenticator.getClass().getName()); + } + setDefault(authenticator); } }