code: protected Connection openConnection() throws IOException {
          // Perhaps this can just be done once?
          CallbackHandler callbackHandler = null;
          SSLContext sslContext = null;
          if (realm != null) {
              sslContext = realm.getSSLContext();
              CallbackHandlerFactory handlerFactory = realm.getSecretCallbackHandlerFactory();
              if (handlerFactory != null) {
                  String username = this.username != null ? this.username : localHostName;
                  callbackHandler = handlerFactory.getCallbackHandler(username);
              }
          }
          final ProtocolConnectionConfiguration config = ProtocolConnectionConfiguration.copy(configuration);
          config.setCallbackHandler(callbackHandler);
          config.setSslContext(sslContext);
          config.setUri(uri);
  
          AuthenticationContext authenticationContext = this.authenticationContext != null ? this.authenticationContext : AuthenticationContext.captureCurrent();
  
          // Connect
          try {
              return authenticationContext.run((PrivilegedExceptionAction<Connection>) () -> ProtocolConnectionUtils.connectSync(config));
          } catch (PrivilegedActionException e) {
              if (e.getCause() instanceof IOException) {
                  throw (IOException) e.getCause();
              }
              throw new IOException(e);
          }
      }
docs: Connect and register at the remote domain controller.
  
  @return connection the established connection
  @throws IOException