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

Jean-Noël Rouvignac
20.42.2016 61b9eb1be03fc03a9f4bb0013a08ff44a1059503
opendj-server-legacy/src/main/java/org/opends/server/tools/PromptTrustManager.java
@@ -12,25 +12,23 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2008-2010 Sun Microsystems, Inc.
 * Portions Copyright 2014-2015 ForgeRock AS.
 * Portions Copyright 2014-2016 ForgeRock AS.
 */
package org.opends.server.tools;
import org.forgerock.i18n.LocalizableMessage;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Date;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import static org.opends.messages.ToolMessages.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Date;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.forgerock.i18n.LocalizableMessage;
/**
 * This class provides an implementation of an X.509 trust manager which will
@@ -44,25 +42,16 @@
public class PromptTrustManager
       implements X509TrustManager
{
  /** The singleton trust manager array for this class. */
  private static TrustManager[] trustManagerArray =
       new TrustManager[] { new PromptTrustManager() };
  /**
   * Creates a new instance of this prompt trust manager.
   */
  /** Creates a new instance of this prompt trust manager. */
  private PromptTrustManager()
  {
    // No implementation is required.
  }
  /**
   * Retrieves the trust manager array that should be used to initialize an SSL
   * context in cases where the user should be interactively prompted about
@@ -77,8 +66,6 @@
    return trustManagerArray;
  }
  /**
   * Determines whether an SSL client with the provided certificate chain should
   * be trusted.  This implementation is not intended for server-side use, and
@@ -90,6 +77,7 @@
   * @throws  CertificateException  To indicate that the provided client
   *                                certificate is not trusted.
   */
  @Override
  public void checkClientTrusted(X509Certificate[] chain, String authType)
         throws CertificateException
  {
@@ -97,8 +85,6 @@
    throw new CertificateException(message.toString());
  }
  /**
   * Determines whether an SSL server with the provided certificate chain should
   * be trusted.  In this case, the user will be interactively prompted as to
@@ -109,6 +95,7 @@
   *
   * @throws  CertificateException  If the user rejects the certificate.
   */
  @Override
  public void checkServerTrusted(X509Certificate[] chain, String authType)
         throws CertificateException
  {
@@ -138,7 +125,6 @@
              notAfterDate));
    }
    LocalizableMessage prompt = INFO_PROMPTTM_YESNO_PROMPT.get();
    BufferedReader reader =
         new BufferedReader(new InputStreamReader(System.in));
@@ -171,8 +157,6 @@
    }
  }
  /**
   * Retrieves the set of certificate authority certificates which are trusted
   * for authenticating peers.
@@ -180,9 +164,9 @@
   * @return  An empty array, since we don't care what certificates are
   *          presented because we will always prompt the user.
   */
  @Override
  public X509Certificate[] getAcceptedIssuers()
  {
    return new X509Certificate[0];
  }
}