code: public static synchronized SimpleAuthenticator getInstance() {
          if (!sInitialized) {
              // Create an instance
              sInstance = new SimpleAuthenticator();
  
              // Try to set default (this may quietly fail...)
              Authenticator.setDefault(sInstance);
  
              // A hack to figure out if we really did set the authenticator
              PasswordAuthentication pa = Authenticator.requestPasswordAuthentication(null, FOURTYTWO, null, null, MAGIC);
  
              // If this test returns false, we didn't succeed, so we set the
              // instance back to null.
              if (pa == null || !MAGIC.equals(pa.getUserName()) || !("" + FOURTYTWO).equals(new String(pa.getPassword()))) {
                  sInstance = null;
              }
  
              // Done
              sInitialized = true;
          }
  
          return sInstance;
      }
docs: Gets the SimpleAuthenticator instance and registers it through the
  Authenticator.setDefault(). If there is no current instance
  of the SimpleAuthenticator in the VM, one is created. This method will
  try to figure out if the setDefault() succeeded (a hack), and will
  return null if it was not able to register the instance as default.
  
  @return The single instance of this class, or null, if another
  Authenticator is allready registered as default.