code: public synchronized static Authenticator registerAuthenticator() {
          if (sAuthenticator != null) {
              return sAuthenticator;
          }
  
          // Get the system property
          String authenticatorName = System.getProperty("java.net.Authenticator");
  
          // Try to get the Authenticator from the system property
          if (authenticatorName != null) {
              try {
                  Class authenticatorClass = Class.forName(authenticatorName);
  
                  sAuthenticator = (Authenticator) authenticatorClass.newInstance();
              }
              catch (ClassNotFoundException cnfe) {
                  // We should maybe rethrow this?
              }
              catch (InstantiationException ie) {
                  // Ignore
              }
              catch (IllegalAccessException iae) {
                  // Ignore
              }
          }
  
          // Get the default authenticator
          if (sAuthenticator == null) {
              sAuthenticator = SimpleAuthenticator.getInstance();
          }
  
          // Register authenticator as default
          Authenticator.setDefault(sAuthenticator);
          return sAuthenticator;
      }
docs: Registers the Authenticator given in the system property
  {@code java.net.Authenticator}, or the default implementation
  ({@code com.twelvemonkeys.net.SimpleAuthenticator}).
  <P/>
  BUG: What if authenticator has allready been set outside this class?
  
  @return The Authenticator created and set as default, or null, if it
  was not set as the default. However, there is no (clean) way to
  be sure the authenticator was set (the SimpleAuthenticator uses
  a hack to get around this), so it might be possible that the
  returned authenticator was not set as default...
  @see Authenticator#setDefault(Authenticator)
  @see SimpleAuthenticator