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

Ludovic Poitou
26.47.2013 294679b2e8e0d7e53a43c446738ed7b9d4479df8
Fix for OPENDJ-1142, OpenDJ setup does not work in Java8 EA - A security class cannot be found in this JVM.
CertAndKeyGen class was moved from sun.security.x509 to sun.security.tools.keytool in openjdk8.
Now checking JVM version to figure out the path.
CR-2376.
1 files modified
16 ■■■■ changed files
opends/src/server/org/opends/server/util/Platform.java 16 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/util/Platform.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013 ForgeRock AS.
 */
package org.opends.server.util;
@@ -57,7 +58,7 @@
{
  // Prefix that determines which security package to use.
  private static String pkgPrefix;
  private static final String pkgPrefix;
  // The two security package prefixes (IBM and SUN).
  private static final String IBM_SEC = "com.ibm.security";
@@ -103,7 +104,7 @@
      "getSelfCertificate";
    // Classes needed to manage certificates.
    private static Class<?> certKeyGenClass, X500NameClass;
    private static final Class<?> certKeyGenClass, X500NameClass;
    // Constructors for each of the above classes.
    private static Constructor<?> certKeyGenCons, X500NameCons;
@@ -111,7 +112,16 @@
    static
    {
      String x509pkg = pkgPrefix + ".x509";
      String certAndKeyGen = x509pkg + ".CertAndKeyGen";
      String certAndKeyGen;
      if (pkgPrefix.equals(IBM_SEC)
          || System.getProperty("java.version").matches("^1\\.[67]\\..*"))
      {
        certAndKeyGen = x509pkg + ".CertAndKeyGen";
      }
      else
      { // Java 8 moved the CertAndKeyGen class to sun.security.tools.keytool
        certAndKeyGen = pkgPrefix + ".tools.keytool" + ".CertAndKeyGen";
      }
      String X500Name = x509pkg + ".X500Name";
      try
      {