mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
18.48.2007 cfb153c8e985ad6f2192d56747fcba8af4df3428
Fix for issue 2465: New - dsreplication -q -X : Java exception

Check for the trust manager not to be null. Appart from that the code has been updated to display a message informing of the log file that is generated when a critical error occurs reading the ADS contents.
4 files modified
108 ■■■■ changed files
opends/src/ads/org/opends/admin/ads/TopologyCache.java 2 ●●● patch | view | raw | blame | history
opends/src/ads/org/opends/admin/ads/util/ServerLoader.java 10 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java 80 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java 16 ●●●● patch | view | raw | blame | history
opends/src/ads/org/opends/admin/ads/TopologyCache.java
@@ -240,7 +240,7 @@
      Map<ServerProperty,Object> serverProperties)
  {
    return new ServerLoader(serverProperties, dn, pwd,
        trustManager.createCopy());
        trustManager == null ? null : trustManager.createCopy());
  }
  /**
opends/src/ads/org/opends/admin/ads/util/ServerLoader.java
@@ -236,9 +236,13 @@
  public InitialLdapContext createContext() throws NamingException
  {
    InitialLdapContext ctx = null;
    trustManager.resetLastRefusedItems();
    String host = (String)serverProperties.get(ServerProperty.HOST_NAME);
    trustManager.setHost(host);
    if (trustManager != null)
    {
      trustManager.resetLastRefusedItems();
      String host = (String)serverProperties.get(ServerProperty.HOST_NAME);
      trustManager.setHost(host);
    }
    lastLdapUrl = getLdapsUrl(serverProperties);
    if (lastLdapUrl == null)
opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java
@@ -365,13 +365,22 @@
    EnableReplicationUserData uData = new EnableReplicationUserData();
    if (argParser.isInteractive())
    {
      if (promptIfRequired(uData))
      try
      {
        returnValue = enableReplication(uData);
        if (promptIfRequired(uData))
        {
          returnValue = enableReplication(uData);
        }
        else
        {
          returnValue = USER_CANCELLED;
        }
      }
      else
      catch (ReplicationCliException rce)
      {
        returnValue = USER_CANCELLED;
        returnValue = rce.getErrorCode();
        printLineBreak();
        printErrorMessage(getCriticalExceptionMessage(rce));
      }
    }
    else
@@ -394,13 +403,22 @@
    DisableReplicationUserData uData = new DisableReplicationUserData();
    if (argParser.isInteractive())
    {
      if (promptIfRequired(uData))
      try
      {
        returnValue = disableReplication(uData);
        if (promptIfRequired(uData))
        {
          returnValue = disableReplication(uData);
        }
        else
        {
          returnValue = USER_CANCELLED;
        }
      }
      else
      catch (ReplicationCliException rce)
      {
        returnValue = USER_CANCELLED;
        returnValue = rce.getErrorCode();
        printLineBreak();
        printErrorMessage(getCriticalExceptionMessage(rce));
      }
    }
    else
@@ -453,13 +471,22 @@
    StatusReplicationUserData uData = new StatusReplicationUserData();
    if (argParser.isInteractive())
    {
      if (promptIfRequired(uData))
      try
      {
        returnValue = statusReplication(uData);
        if (promptIfRequired(uData))
        {
          returnValue = statusReplication(uData);
        }
        else
        {
          returnValue = USER_CANCELLED;
        }
      }
      else
      catch (ReplicationCliException rce)
      {
        returnValue = USER_CANCELLED;
        returnValue = rce.getErrorCode();
        printLineBreak();
        printErrorMessage(getCriticalExceptionMessage(rce));
      }
    }
    else
@@ -507,8 +534,11 @@
   * @param uData the object to be updated.
   * @return <CODE>true</CODE> if the object was successfully updated and
   * <CODE>false</CODE> if the user cancelled the operation.
   * @throws ReplicationCliException if a critical error occurs reading the
   * ADS.
   */
  private boolean promptIfRequired(EnableReplicationUserData uData)
  throws ReplicationCliException
  {
    boolean cancelled = false;
@@ -1025,8 +1055,11 @@
   * @param uData the object to be updated.
   * @return <CODE>true</CODE> if the object was successfully updated and
   * <CODE>false</CODE> if the user cancelled the operation.
   * @throws ReplicationCliException if there is a critical error reading the
   * ADS.
   */
  private boolean promptIfRequired(DisableReplicationUserData uData)
  throws ReplicationCliException
  {
    boolean cancelled = false;
@@ -1392,8 +1425,11 @@
   * @param uData the object to be updated.
   * @return <CODE>true</CODE> if the object was successfully updated and
   * <CODE>false</CODE> if the user cancelled the operation.
   * @throws ReplicationCliException if a critical error occurs reading the
   * ADS.
   */
  private boolean promptIfRequired(StatusReplicationUserData uData)
  throws ReplicationCliException
  {
    boolean cancelled = false;
@@ -2167,13 +2203,15 @@
   * @param isFirstOrSourceServer whether this is the first server in the
   * enable replication subcommand or the source server in the initialize server
   * subcommand.
   * @throws ReplicationCliException if a critical error occurred.
   * @return <CODE>true</CODE> if everything went fine and the user accepted
   * all the certificates and confirmed everything.  Returns <CODE>false</CODE>
   * if a critical error occurred or the user did not accept a certificate or
   * any of the confirmation messages.
   * if the user did not accept a certificate or any of the confirmation
   * messages.
   */
  private boolean loadADSAndAcceptCertificates(InitialLdapContext[] ctx,
      ReplicationUserData uData, boolean isFirstOrSourceServer)
  throws ReplicationCliException
  {
    boolean cancelled = false;
    boolean triedWithUserProvidedAdmin = false;
@@ -2339,19 +2377,17 @@
    }
    catch (ADSContextException ace)
    {
      printLineBreak();
      printErrorMessage(Utils.getThrowableMsg(INFO_BUG_MSG.get(), ace));
      LOG.log(Level.SEVERE, "Complete error stack:", ace);
      cancelled = true;
      throw new ReplicationCliException(
          ERR_REPLICATION_READING_ADS.get(ace.getMessage()),
          ERROR_READING_ADS, ace);
    }
    catch (TopologyCacheException tce)
    {
      printLineBreak();
      printErrorMessage(Utils.getMessage(tce));
      LOG.log(Level.SEVERE, "Complete error stack:", tce);
      cancelled = true;
      throw new ReplicationCliException(
          ERR_REPLICATION_READING_ADS.get(tce.getMessage()),
          ERROR_READING_TOPOLOGY_CACHE, tce);
    }
    return !cancelled;
  }
opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java
@@ -798,8 +798,15 @@
      ApplicationTrustManager trustManager)
  {
    boolean returnValue = false;
    ApplicationTrustManager.Cause cause =
      usedTrustManager.getLastRefusedCause();
    ApplicationTrustManager.Cause cause;
    if (usedTrustManager != null)
    {
      cause = usedTrustManager.getLastRefusedCause();
    }
    else
    {
      cause = null;
    }
    LOG.log(Level.INFO, "Certificate exception cause: "+cause);
    UserDataCertificateException.Type excType = null;
@@ -948,7 +955,10 @@
      if ((chain != null) && (authType != null) && (host != null))
      {
        LOG.log(Level.INFO, "Accepting certificate presented by host "+host);
        trustManager.acceptCertificate(chain, authType, host);
        if (trustManager != null)
        {
          trustManager.acceptCertificate(chain, authType, host);
        }
        accepted = true;
      }
      else