summaryrefslogtreecommitdiffstats
path: root/pki/base/migrate/TxtTo80
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/migrate/TxtTo80')
-rw-r--r--pki/base/migrate/TxtTo80/classes/CS80LdifParser.classbin0 -> 8187 bytes
-rw-r--r--pki/base/migrate/TxtTo80/classes/Main.classbin0 -> 1626 bytes
-rwxr-xr-xpki/base/migrate/TxtTo80/run.sh394
-rw-r--r--pki/base/migrate/TxtTo80/src/Main.java559
-rwxr-xr-xpki/base/migrate/TxtTo80/src/compile.sh345
5 files changed, 1298 insertions, 0 deletions
diff --git a/pki/base/migrate/TxtTo80/classes/CS80LdifParser.class b/pki/base/migrate/TxtTo80/classes/CS80LdifParser.class
new file mode 100644
index 000000000..22e6fe9a3
--- /dev/null
+++ b/pki/base/migrate/TxtTo80/classes/CS80LdifParser.class
Binary files differ
diff --git a/pki/base/migrate/TxtTo80/classes/Main.class b/pki/base/migrate/TxtTo80/classes/Main.class
new file mode 100644
index 000000000..0f162327d
--- /dev/null
+++ b/pki/base/migrate/TxtTo80/classes/Main.class
Binary files differ
diff --git a/pki/base/migrate/TxtTo80/run.sh b/pki/base/migrate/TxtTo80/run.sh
new file mode 100755
index 000000000..6dde55758
--- /dev/null
+++ b/pki/base/migrate/TxtTo80/run.sh
@@ -0,0 +1,394 @@
+#!/bin/sh
+
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2009 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+
+#####################################################################
+### ###
+### This script converts a normalized <Source CS Version> ldif ###
+### text file (e. g. - created via a <Source CS Version>ToTxt ###
+### script) into a CS 8.0 ldif data file. ###
+### ###
+### This CS 8.0 ldif data file can then be imported into ###
+### the internal database of the desired CS 8.0 server ###
+### using a utility such as ldif2db. ###
+### ###
+#####################################################################
+
+###
+### Provide a usage function
+###
+
+usage() {
+ echo
+ echo "Usage: $0 input [errors] > output"
+ echo
+ echo " where: input - a "normalized" CS ldif data file,"
+ echo " errors - an optional errors file containing"
+ echo " skipped attributes, and"
+ echo " output - the CS 8.0 ldif text file."
+ echo
+ echo " NOTE: If no redirection is provided to"
+ echo " 'output', then the CS 8.0 ldif text"
+ echo " file will merely be echoed to stdout."
+ echo
+ exit 255
+}
+
+
+##
+## Perform a usage check for the appropriate number of arguments:
+##
+
+if [ $# -lt 1 -o $# -gt 2 ] ; then
+ usage
+fi
+
+
+###
+### Check that the specified "input" file exists and is a regular file.
+###
+
+if [ ! -f $1 ] ; then
+ echo "ERROR: Either the specified 'input' file, '$1', does not exist, "
+ echo " or it is not a regular file!"
+ echo
+ usage
+fi
+
+
+###
+### Check that the specified "input" file exists and is not empty.
+###
+
+if [ ! -s $1 ] ; then
+ echo "ERROR: The specified 'input' file, '$1', is empty!"
+ echo
+ usage
+fi
+
+
+###
+### If an "errors" file is specified, then check that it does not already
+### exist.
+###
+
+if [ $# -eq 2 ] ; then
+ if [ -f $2 ] ; then
+ echo "ERROR: The specified 'errors' file, '$2', already exists!"
+ echo " Please specify a different file!"
+ echo
+ usage
+ fi
+fi
+
+
+###
+### Set PKI_OS
+###
+### CS 8.0 NOTE: "Linux"
+### "SunOS"
+###
+
+PKI_OS=`uname`
+export PKI_OS
+
+if [ "${PKI_OS}" != "Linux" ] &&
+ [ "${PKI_OS}" != "SunOS" ]; then
+ printf "This '$0' script is ONLY executable\n"
+ printf "on either a 'Linux' or 'Solaris' machine!\n"
+ exit 255
+fi
+
+
+###
+### Set PKI_ARCHITECTURE
+###
+### CS 8.0 NOTE: "Linux i386" - 32-bit ("i386")
+### "Linux x86_64" - 64-bit ("x86_64")
+### "SunOS sparc" - 64-bit ("sparcv9")
+###
+
+if [ "${PKI_OS}" == "Linux" ]; then
+ PKI_PLATFORM=`uname -i`
+ export PKI_PLATFORM
+ if [ "${PKI_PLATFORM}" == "i386" ] ||
+ [ "${PKI_PLATFORM}" == "x86_64" ]; then
+ PKI_ARCHITECTURE="${PKI_PLATFORM}"
+ export PKI_ARCHITECTURE
+ else
+ printf "On 'Linux', this '$0' script is ONLY executable\n"
+ printf "on either an 'i386' or 'x86_64' architecture!\n"
+ exit 255
+ fi
+elif [ "${PKI_OS}" == "SunOS" ]; then
+ PKI_PLATFORM=`uname -p`
+ export PKI_PLATFORM
+ if [ "${PKI_PLATFORM}" == "sparc" ]; then
+ PKI_ARCHITECTURE="sparcv9"
+ export PKI_ARCHITECTURE
+ else
+ printf "On 'Solaris', this '$0' script is ONLY executable\n"
+ printf "on a 'sparcv9' architecture!\n"
+ exit 255
+ fi
+fi
+
+
+###
+### Set PKI_OS_DISTRIBUTION
+###
+### CS 8.0 NOTE: "Linux Fedora 8" - "Fedora"
+### "Linux Fedora 9" - "Fedora"
+### "Linux Fedora 10" - "Fedora"
+### "Linux RHEL 5" - "Red Hat"
+### "SunOS 5.9" - "Solaris"
+###
+
+if [ "${PKI_OS}" == "Linux" ]; then
+ IS_FEDORA=`test -e /etc/fedora-release && echo 1 || echo 0`
+ if [ "${IS_FEDORA}" -eq 1 ]; then
+ PKI_DISTRIBUTION="Fedora"
+ export PKI_DISTRIBUTION
+ PKI_OS_RPM_VERSION=`rpm -qf --qf='%{VERSION}' /etc/fedora-release`
+ export PKI_OS_RPM_VERSION
+ PKI_OS_VERSION=`echo "${PKI_OS_RPM_VERSION}" | tr -d [A-Za-z]`
+ export PKI_OS_VERSION
+ else
+ IS_REDHAT=`test -e /etc/redhat-release && echo 1 || echo 0`
+ if [ "${IS_REDHAT}" -eq 1 ]; then
+ PKI_DISTRIBUTION="Red Hat"
+ export PKI_DISTRIBUTION
+ PKI_OS_RPM_VERSION=`rpm -qf --qf='%{VERSION}' /etc/redhat-release`
+ export PKI_OS_RPM_VERSION
+ PKI_OS_VERSION=`echo "${PKI_OS_RPM_VERSION}" | tr -d [A-Za-z]`
+ export PKI_OS_VERSION
+ else
+ printf "On 'Linux',this '$0' script is ONLY executable\n"
+ printf "on either a 'Fedora' or 'Red Hat' machine!\n"
+ exit 255
+ fi
+ fi
+elif [ "${PKI_OS}" == "SunOS" ]; then
+ PKI_DISTRIBUTION="Solaris"
+ export PKI_DISTRIBUTION
+ PKI_OS_VERSION=`uname -r | awk -F. '{print $2}'`
+ export PKI_OS_VERSION
+fi
+
+
+###
+### Set JAVA_HOME
+###
+### CS 8.0 NOTE: "Linux Fedora 8" - JRE 1.7.0 (IcedTea)
+### "Linux Fedora 9" - JRE 1.6.0 (OpenJDK)
+### "Linux Fedora 10" - JRE 1.6.0 (OpenJDK)
+### "Linux RHEL 5" - JRE 1.6.0 (OpenJDK)
+### "SunOS 5.9" - JRE 1.6.0 (Sun JDK)
+###
+### "Linux" - ALWAYS set specific JAVA_HOME
+### "SunOS" - ALLOW JAVA_HOME to be pre-defined
+###
+
+if [ "${PKI_OS}" == "Linux" ]; then
+ if [ "${PKI_DISTRIBUTION}" == "Fedora" ]; then
+ if [ ${PKI_OS_VERSION} -eq 8 ]; then
+ if [ "${PKI_ARCHITECTURE}" == "i386" ]; then
+ JAVA_HOME="/usr/lib/jvm/jre-1.7.0-icedtea"
+ JAVA_ARCHITECTURE="i386"
+ else # "x86_64"
+ JAVA_HOME="/usr/lib/jvm/jre-1.7.0-icedtea.${PKI_ARCHITECTURE}"
+ JAVA_ARCHITECTURE="amd64"
+ fi
+ if [ ! -x "${JAVA_HOME}/bin/java" ] &&
+ [ ! -f "${JAVA_HOME}/lib/rt.jar" ] &&
+ [ ! -d "${JAVA_HOME}/lib/${JAVA_ARCHITECTURE}" ] &&
+ [ ! -d "${JAVA_HOME}/lib/${JAVA_ARCHITECTURE}/native_threads" ]; then
+ printf "On 'Fedora 8', this '$0' script is ONLY executable\n"
+ printf "by 'JRE 1.7.0 (IcedTea)'!\n"
+ exit 255
+ fi
+ elif [ ${PKI_OS_VERSION} -gt 8 ]; then
+ if [ "${PKI_ARCHITECTURE}" == "i386" ]; then
+ JAVA_HOME="/usr/lib/jvm/jre-1.6.0-openjdk"
+ JAVA_ARCHITECTURE="i386"
+ else # "x86_64"
+ JAVA_HOME="/usr/lib/jvm/jre-1.6.0-openjdk.${PKI_ARCHITECTURE}"
+ JAVA_ARCHITECTURE="amd64"
+ fi
+ if [ ! -x "${JAVA_HOME}/bin/java" ] &&
+ [ ! -f "${JAVA_HOME}/lib/rt.jar" ] &&
+ [ ! -d "${JAVA_HOME}/lib/${JAVA_ARCHITECTURE}" ] &&
+ [ ! -d "${JAVA_HOME}/lib/${JAVA_ARCHITECTURE}/native_threads" ]; then
+ printf "On 'Fedora ${PKI_OS_VERSION}', "
+ printf "this '$0' script is ONLY executable\n"
+ printf "by 'JRE 1.6.0 (OpenJDK)'!\n"
+ exit 255
+ fi
+ else
+ printf "On 'Fedora', this '$0' script is ONLY executable\n"
+ printf "on 'Fedora 8' or later!\n"
+ exit 255
+ fi
+ elif [ "${PKI_DISTRIBUTION}" == "Red Hat" ]; then
+ if [ ${PKI_OS_VERSION} -ge 5 ]; then
+ if [ "${PKI_ARCHITECTURE}" == "i386" ]; then
+ JAVA_HOME="/usr/lib/jvm/jre-1.6.0-openjdk"
+ JAVA_ARCHITECTURE="i386"
+ else # "x86_64"
+ JAVA_HOME="/usr/lib/jvm/jre-1.6.0-openjdk.${PKI_ARCHITECTURE}"
+ JAVA_ARCHITECTURE="amd64"
+ fi
+ if [ ! -x "${JAVA_HOME}/bin/java" ] &&
+ [ ! -f "${JAVA_HOME}/lib/rt.jar" ] &&
+ [ ! -d "${JAVA_HOME}/lib/${JAVA_ARCHITECTURE}" ] &&
+ [ ! -d "${JAVA_HOME}/lib/${JAVA_ARCHITECTURE}/native_threads" ]; then
+ printf "On 'RHEL ${PKI_OS_VERSION}', "
+ printf "this '$0' script is ONLY executable\n"
+ printf "by 'JRE 1.6.0 (OpenJDK)'!\n"
+ exit 255
+ fi
+ else
+ printf "On 'Red Hat', this '$0' script is ONLY executable\n"
+ printf "on 'RHEL 5' or later!\n"
+ exit 255
+ fi
+ fi
+ JRE_EXE="${JAVA_HOME}/bin/java"
+ export JRE_EXE
+ JRE_VERSION=`${JAVA_HOME}/bin/java -version 2>&1 | cut -b15-19 | sed -n '/[0-9]\.[0-9]\.[0-9]/p'`
+ export JRE_VERSION
+elif [ "${PKI_OS}" == "SunOS" ]; then
+ if [ "${JAVA_HOME}" == "" ]; then
+ JAVA_HOME="/usr/java"
+ fi
+ JRE_EXE="${JAVA_HOME}/bin/${PKI_ARCHITECTURE}/java"
+ export JRE_EXE
+ JRE_VERSION=`${JAVA_HOME}/bin/${PKI_ARCHITECTURE}/java -version 2>&1 | cut -b15-19 | sed -n '/[0-9]\.[0-9]\.[0-9]/p'`
+ export JRE_VERSION
+ if [ ${PKI_OS_VERSION} -eq 9 ]; then
+ if [ "${JRE_VERSION}" != "1.6.0" ]; then
+ printf "On 'Solaris ${PKI_OS_VERSION}', "
+ printf "this '$0' script is ONLY executable\n"
+ printf "by 'JRE 1.6.0'!\n"
+ exit 255
+ fi
+ if [ ! -x "${JAVA_HOME}/bin/${PKI_ARCHITECTURE}/java" ] &&
+ [ ! -f "${JAVA_HOME}/jre/lib/rt.jar" ] &&
+ [ ! -d "${JAVA_HOME}/jre/lib/${PKI_ARCHITECTURE}" ] &&
+ [ ! -d "${JAVA_HOME}/jre/lib/${PKI_ARCHITECTURE}/native_threads" ]; then
+ printf "On 'Solaris ${PKI_OS_VERSION}', "
+ printf "this '$0' script is ONLY executable\n"
+ printf "by 'JRE 1.6.0 (Sun JDK)'!\n"
+ exit 255
+ fi
+ else
+ printf "On 'Solaris', this '$0' script is ONLY executable\n"
+ printf "on 'Solaris 9'!\n"
+ exit 255
+ fi
+fi
+
+
+###
+### Setup the appropriate CLASSPATH and LD_LIBRARY_PATH
+### environment variables based upon the platform
+###
+### NOTE: As of SunOS JDK 1.4.0, the required "Unicode" classes
+### have been moved from "i18n.jar" to "rt.jar".
+###
+
+if [ ! -f "/usr/share/java/pki/cmscore.jar" ] &&
+ [ ! -f "/usr/share/java/pki/certsrv.jar" ]; then
+ printf "This '$0' script must be EXECUTED against\n"
+ printf "the 'pki-common' package!\n"
+ exit 255
+fi
+if [ ! -f "/usr/share/java/pki/nsutil.jar" ]; then
+ printf "This '$0' script must be EXECUTED against\n"
+ printf "the 'pki-util' package!\n"
+ exit 255
+fi
+if [ ! -d "/usr/share/pki/migrate/TxtTo80/classes" ]; then
+ printf "This '$0' script must be EXECUTED against\n"
+ printf "the 'pki-migrate' package!\n"
+ exit 255
+fi
+
+if [ ${PKI_OS} = "Linux" ] ; then
+ if [ ! -f "/usr/lib/java/jss4.jar" ]; then
+ printf "This '$0' script must be EXECUTED against\n"
+ printf "the 'jss' package!\n"
+ exit 255
+ fi
+ CLASSPATH=${JAVA_HOME}/lib/rt.jar
+ CLASSPATH=/usr/lib/java/jss4.jar:${CLASSPATH}
+ CLASSPATH=/usr/share/java/pki/nsutil.jar:${CLASSPATH}
+ CLASSPATH=/usr/share/java/pki/cmscore.jar:${CLASSPATH}
+ CLASSPATH=/usr/share/java/pki/certsrv.jar:${CLASSPATH}
+ CLASSPATH=/usr/share/pki/migrate/TxtTo80/classes:${CLASSPATH}
+ export CLASSPATH
+ if [ ${PKI_ARCHITECTURE} = "i386" ] ; then
+ LD_LIBRARY_PATH=${JAVA_HOME}/lib/${JAVA_ARCHITECTURE}/native_threads
+ LD_LIBRARY_PATH=${JAVA_HOME}/lib/${JAVA_ARCHITECTURE}:${LD_LIBRARY_PATH}
+ LD_LIBRARY_PATH=/usr/lib:${LD_LIBRARY_PATH}
+ export LD_LIBRARY_PATH
+ else # "x86_64"
+ LD_LIBRARY_PATH=${JAVA_HOME}/lib/${JAVA_ARCHITECTURE}/native_threads
+ LD_LIBRARY_PATH=${JAVA_HOME}/lib/${JAVA_ARCHITECTURE}:${LD_LIBRARY_PATH}
+ LD_LIBRARY_PATH=/usr/lib64:${LD_LIBRARY_PATH}
+ export LD_LIBRARY_PATH
+ fi
+else # "SunOS"
+ if [ ! -f "/usr/lib/java/dirsec/jss4.jar" ]; then
+ printf "This '$0' script must be EXECUTED against\n"
+ printf "the 'dirsec-jss' package!\n"
+ exit 255
+ fi
+ CLASSPATH=${JAVA_HOME}/jre/lib/rt.jar
+ CLASSPATH=/usr/lib/java/dirsec/jss4.jar:${CLASSPATH}
+ CLASSPATH=/usr/share/java/pki/nsutil.jar:${CLASSPATH}
+ CLASSPATH=/usr/share/java/pki/cmscore.jar:${CLASSPATH}
+ CLASSPATH=/usr/share/java/pki/certsrv.jar:${CLASSPATH}
+ CLASSPATH=/usr/share/pki/migrate/TxtTo80/classes:${CLASSPATH}
+ export CLASSPATH
+ LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/${PKI_ARCHITECTURE}/native_threads
+ LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/${PKI_ARCHITECTURE}:${LD_LIBRARY_PATH}
+ LD_LIBRARY_PATH=/usr/lib/${PKI_ARCHITECTURE}:${LD_LIBRARY_PATH}
+ LD_LIBRARY_PATH=/usr/lib/${PKI_ARCHITECTURE}/dirsec:${LD_LIBRARY_PATH}
+ export LD_LIBRARY_PATH
+fi
+
+
+###
+### Execute TxtTo80 to convert the "normalized" CS ldif data file in to
+### a CS 8.0 ldif text file suitable for import in to a CS 8.0 LDAP DB.
+###
+
+# printf "================================================================\n"
+# printf "PKI_OS='${PKI_OS}'\n"
+# printf "PKI_DISTRIBUTION='${PKI_DISTRIBUTION}'\n"
+# printf "PKI_OS_VERSION='${PKI_OS_VERSION}'\n"
+# printf "PKI_ARCHITECTURE='${PKI_ARCHITECTURE}'\n"
+# printf "JAVA_HOME='${JAVA_HOME}'\n"
+# printf "JRE_EXE='${JRE_EXE}'\n"
+# printf "JRE_VERSION='${JRE_VERSION}'\n"
+# printf "================================================================\n\n"
+
+${JRE_EXE} -classpath ${CLASSPATH} Main $1 $2
+
diff --git a/pki/base/migrate/TxtTo80/src/Main.java b/pki/base/migrate/TxtTo80/src/Main.java
new file mode 100644
index 000000000..f2734bfa3
--- /dev/null
+++ b/pki/base/migrate/TxtTo80/src/Main.java
@@ -0,0 +1,559 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2009 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+//
+// "TxtTo80/src/Main.java" is based upon a copy "TxtTo80/src/Main.java".
+//
+// Always comment any new code sections with a "CS 8.0" header, and
+// apply these changes forward to all other "TxtTo*/src/Main.java" files
+// (including this comment header) so that these differences will only
+// appear when this file is diffed against an earlier "TxtTo*" version.
+//
+// This file should always be maintained by executing the following command:
+//
+// diff TxtTo73/src/Main.java TxtTo80/src/Main.java
+//
+
+import java.math.*;
+import java.io.*;
+import java.util.*;
+import org.mozilla.jss.*; // CMS 4.5 and later
+import org.mozilla.jss.crypto.*; // CMS 4.5 and later
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.authentication.*;
+import netscape.security.util.*;
+import java.lang.reflect.*;
+
+public class Main
+{
+ public static void main(String args[])
+ {
+ try {
+ // initialize CryptoManager in CMS 4.5 and later
+ CryptoManager.initialize(".");
+ // load JSS provider in CMS 4.5 and later
+ java.security.Security.removeProvider("SUN version 1.2");
+ // The following call to "java.security.Security.insertProviderAt()"
+ // is no longer commented out in CMS 4.5 and later
+ java.security.Security.insertProviderAt(
+ new netscape.security.provider.CMS(), 0);
+ java.security.Provider ps[] =
+ java.security.Security.getProviders();
+ if (ps == null || ps.length <= 0) {
+ System.err.println("Java Security Provider NONE");
+ } else {
+ for (int x = 0; x < ps.length; x++) {
+ System.err.println("Java Security Provider " + x + " class=" + ps[x]);
+ }
+ }
+
+ // Parse the File
+ CS80LdifParser parser = null;
+ if (args.length == 1) {
+ parser = new CS80LdifParser(args[0]);
+ } else if (args.length == 2) {
+ parser = new CS80LdifParser(args[0], args[1]);
+ } else {
+ throw new IOException("Invalid Parameters");
+ }
+ parser.parse();
+ } catch (Exception e) {
+ System.err.println("ERROR: " + e.toString());
+ e.printStackTrace();
+ }
+ }
+}
+
+class CS80LdifParser
+{
+ // constants
+ private static final String DN =
+ "dn:";
+ // Directory Servers in CS 8.0 and later use "extdata-"
+ private static final String extAttrPrefix =
+ "extdata-";
+ private static final String BEGIN =
+ "--- BEGIN ATTRIBUTES ---";
+ private static final String END =
+ "--- END ATTRIBUTES ---";
+
+ // variables
+ private String mFilename = null;
+ private String mErrorFilename = null;
+ private PrintWriter mErrorPrintWriter = null;
+
+ public CS80LdifParser(String filename)
+ {
+ mFilename = filename;
+ }
+
+ public CS80LdifParser(String filename, String errorFilename)
+ {
+ mFilename = filename;
+ mErrorFilename = errorFilename;
+ }
+
+ public void parse() throws Exception
+ {
+ if (mErrorFilename != null) {
+ mErrorPrintWriter = new PrintWriter(new FileOutputStream(mErrorFilename));
+ }
+ BufferedReader reader = new BufferedReader(
+ new FileReader(mFilename));
+ String line = null;
+ String dn = null;
+ Vector requestAttributes = null;
+ while ((line = reader.readLine()) != null) {
+ if (line.startsWith(DN)) {
+ dn = line;
+ }
+ if (line.equals(BEGIN)) {
+ requestAttributes = new Vector();
+ continue;
+ }
+ if (requestAttributes == null) {
+ // Since we are not in the midst of a Request Attribute,
+ // simply print out the line.
+ System.out.println(line);
+
+ // New in CS 8.0:
+ if( line.equals( "objectClass: request" ) ) {
+ // Since Request Objects now contain individual undefined
+ // schema attributes (rather than a single serialized blob),
+ // we disable schema checking to allow them to be stored as
+ // Multi-Value strings by adding an "extensibleObject"
+ // objectclass to each Request Object entry.
+ System.out.println( "objectClass: extensibleObject" );
+ }
+ continue;
+ }
+ if (line.equals(END)) {
+ parseAttributes(dn, requestAttributes);
+ requestAttributes = null;
+ continue;
+ }
+ if (line.startsWith(" ")) { // beginning of attr
+ requestAttributes.addElement(
+ line.substring(1, line.length()));
+ } else {
+ requestAttributes.setElementAt(
+ (String)
+ requestAttributes.lastElement() +
+ "\n" +
+ line,
+ requestAttributes.size() - 1);
+ }
+ }
+ }
+
+ public String getKey( String dn, String attr )
+ {
+ String key = null;
+
+ int colon = attr.indexOf( ':' );
+ if (colon == -1) {
+ return key;
+ }
+
+ int equal = attr.indexOf( '=' );
+ if( equal == -1 ) {
+ return key;
+ }
+
+ key = attr.substring( 0, colon );
+ if( key.startsWith( "serviceErrors" ) ) {
+ // #56953 - skip serviceErrors
+ return key;
+ }
+
+ if( key.startsWith( "Error" ) ) {
+ // #56953 - skip Error
+ return key;
+ }
+
+ return key;
+ }
+
+ public void parseAttributes(String dn, Vector attrs) throws Exception
+ {
+ for( int i = 0; i < attrs.size(); i++ ) {
+ String attr = ( String ) attrs.elementAt( i );
+ try {
+ translateAttributes( dn, attr );
+ } catch( Exception e ) {
+ if( mErrorPrintWriter != null ) {
+ mErrorPrintWriter.println( dn );
+ }
+ String key = getKey( dn, attr );
+ if( key != null ) {
+ mErrorPrintWriter.println( "Skipped " + key );
+ }
+ }
+ }
+ }
+
+ /*************************************************************************/
+ /* The following two functions: */
+ /* */
+ /* protected boolean isAlphaNum(char in) {} */
+ /* */
+ /* public String encodeKey(String key) {} */
+ /* */
+ /* were copied from the private class called: */
+ /* */
+ /* class ExtAttrDynMapper implements IDBDynAttrMapper {} */
+ /* */
+ /* in the file called: */
+ /* */
+ /* pki/base/common/src/com/netscape/cmscore/request/RequestRecord.java */
+ /* */
+ /*************************************************************************/
+
+ protected boolean isAlphaNum(char in) {
+ if ((in >= 'a') && (in <= 'z')) {
+ return true;
+ }
+ if ((in >= 'A') && (in <= 'Z')) {
+ return true;
+ }
+ if ((in >= '0') && (in <= '9')) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Encoded extdata keys for storage in LDAP.
+ *
+ * The rules for encoding are trickier than decoding. We want to allow
+ * '-' by itself to be stored in the database (for the common case of keys
+ * like 'Foo-Bar'. Therefore we are using '--' as the encoding character.
+ * The rules are:
+ * 1) All characters [^-a-zA-Z0-9] are encoded as --XXXX where XXXX is the
+ * hex representation of the digit.
+ * 2) [a-zA-Z0-9] are always passed through unencoded
+ * 3) [-] is passed through as long as it is preceded and followed
+ * by [a-zA-Z0-9] (or if it's at the beginning/end of the string)
+ * 4) If [-] is preceded or followed by [^a-zA-Z0-9] then
+ * the - as well as all following [^a-zA-Z0-9] characters are encoded
+ * as --XXXX.
+ *
+ * This routine tries to be as efficient as possible with StringBuffer and
+ * large copies. However, the encoding unfortunately requires several
+ * objects to be allocated.
+ *
+ * @param key The key to encode
+ * @return The encoded key
+ */
+ public String encodeKey(String key) {
+ StringBuffer output = null;
+ char[] input = key.toCharArray();
+ int startCopyIndex = 0;
+
+ int index = 0;
+ while (index < input.length) {
+ if (! isAlphaNum(input[index])) {
+ if ((input[index] == '-') &&
+ ((index + 1) < input.length) &&
+ (isAlphaNum(input[index + 1]))) {
+ index += 2;
+ } else if ((input[index] == '-') &&
+ ((index + 1) == input.length)) {
+ index += 1;
+ } else {
+ if (output == null) {
+ output = new StringBuffer(input.length + 5);
+ }
+ output.append(input, startCopyIndex, index - startCopyIndex);
+ while ( (index < input.length) &&
+ (! isAlphaNum(input[index])) ) {
+ output.append("--");
+ String hexString = Integer.toHexString(input[index]);
+ int padding = 4 - hexString.length();
+ while (padding > 0) {
+ output.append('0');
+ padding--;
+ }
+ output.append(hexString);
+ index++;
+ }
+ startCopyIndex = index;
+ }
+ } else {
+ index++;
+ }
+ }
+
+ if (output == null) {
+ return key;
+ } else {
+ output.append(input, startCopyIndex, index - startCopyIndex);
+ return output.toString();
+ }
+ }
+
+ public String formatData( String data ) {
+ StringBuffer output = null;
+ char[] input = data.toCharArray();
+ int startCopyIndex = 0;
+
+ // Every string buffer has a capacity. As long as the length of the
+ // character sequence contained in the string buffer does not exceed
+ // the capacity, it is not necessary to allocate a new internal buffer
+ // array. If the internal buffer overflows, it is automatically made
+ // larger.
+ //
+ // Start out with an output buffer at least as big as the input buffer.
+ output = new StringBuffer( input.length );
+
+ int index = 0;
+ while( index < input.length ) {
+ if( input[index] != '\n' ) {
+ output.append( input[index] );
+ } else {
+ output.append( input[index] );
+ if( index != ( input.length - 1 ) ) {
+ // Place an initial space after each carriage return
+ // with the exception of the last one
+ output.append( ' ' );
+ }
+ }
+
+ index++;
+ }
+
+ return( output.toString() );
+ }
+
+ public void translateAttributes( String dn, String attr )
+ throws Exception
+ {
+ // attribute format [key]:[type]=[data]
+
+ int colon = attr.indexOf( ':' );
+ if( colon == -1 ) {
+ if( mErrorPrintWriter != null ) {
+ if( dn != null ) {
+ mErrorPrintWriter.println( dn );
+ }
+ mErrorPrintWriter.println( "Skipped " + attr );
+ }
+ return;
+ }
+ int equal = attr.indexOf( '=' );
+ if( equal == -1 ) {
+ if( mErrorPrintWriter != null ) {
+ if( dn != null ) {
+ mErrorPrintWriter.println( dn );
+ }
+ mErrorPrintWriter.println( "Skipped " + attr );
+ }
+ return;
+ }
+
+ String key = attr.substring( 0, colon );
+ String type = attr.substring( colon + 1, equal );
+ String data = attr.substring( equal + 1 );
+
+ if( key.startsWith( "serviceErrors" ) ) {
+ // #56953 - skip serviceErrors
+ if( mErrorPrintWriter != null ) {
+ if( dn != null ) {
+ mErrorPrintWriter.println( dn );
+ }
+ mErrorPrintWriter.println( "Skipped " + attr );
+ }
+ return;
+ }
+
+ if( key.startsWith( "Error" ) ) {
+ // #56953 - skip serviceErrors
+ if( mErrorPrintWriter != null ) {
+ if( dn != null ) {
+ mErrorPrintWriter.println( dn );
+ }
+ mErrorPrintWriter.println( "Skipped " + attr );
+ }
+ return;
+ }
+
+ // To account for '47ToTxt' data files that have previously
+ // been generated, ALWAYS convert 'iplanet' to 'netscape'.
+ //
+ // Bugzilla Bug #224801 (a.k.a - Raidzilla Bug #56981)
+ // Bugzilla Bug #483519
+ //
+ String translation = null;
+ if( type.startsWith( "iplanet" ) ) {
+ translation = "netscape"
+ + type.substring( 7 );
+ type = translation;
+ } else if( type.startsWith( "com.iplanet" ) ) {
+ translation = "com.netscape"
+ + type.substring( 11 );
+ type = translation;
+ }
+
+ if( type.startsWith( "com.netscape.certsrv.request.AgentApprovals" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "com.netscape.certsrv.base.ArgBlock" )
+ || type.startsWith( "com.netscape.cmscore.base.ArgBlock" ) ) {
+ // CMS 6.1: created new "com.netscape.certsrv.base.IArgBlock" and
+ // moved old "com.netscape.certsrv.base.ArgBlock"
+ // to "com.netscape.cmscore.base.ArgBlock"
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "com.netscape.certsrv.authentication.AuthToken" ) ) {
+ // Processes 'java.math.BigInteger[]':
+ //
+ // Bugzilla Bug #225031 (a.k.a - Raidzilla Bug #58356)
+ //
+ // Processes 'java.lang.String[]':
+ //
+ // Bugzilla Bug #224763 (a.k.a - Raidzilla Bug #57949)
+ // Bugzilla Bug #252240
+ //
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "java.math.BigInteger[" ) ) {
+ // Bugzilla Bug #238779
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "java.math.BigInteger" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "byte[]" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "byte[" ) ) {
+ // byte array
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "netscape.security.x509.CertificateAlgorithmId" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.equals( "netscape.security.x509.CertificateChain" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.equals( "netscape.security.x509.CertificateExtensions" ) ) {
+ // XXX - "db2ldif" appears dumps these as ":" values, but they
+ // always appear as "::" base-64 encoded values?
+ // CMS 6.2: revised method of decoding objects of type
+ // "netscape.security.x509.CertificateExtensions"
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.equals( "netscape.security.x509.CertificateSubjectName" ) ) {
+ // CMS 6.2: revised method of decoding objects of type
+ // "netscape.security.x509.CertificateSubjectName"
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "netscape.security.x509.CertificateValidity" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.equals( "netscape.security.x509.CertificateX509Key" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "com.netscape.certsrv.cert.CertInfo" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if (type.startsWith("java.util.Hashtable")) {
+ // Bugzilla Bug #224800 (a.k.a - Raidzilla Bug #56953)
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "Integer[" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "java.lang.Integer" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "org.mozilla.jss.asn1.INTEGER" ) ) {
+ // CS 7.1 stores bodyPartId as INTEGER
+ // CS 7.2 fixed the problem by storing it as String
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "com.netscape.certsrv.dbs.keydb.KeyRecord" )
+ || type.startsWith( "com.netscape.cmscore.dbs.KeyRecord" ) ) {
+ // Bugzilla Bug #508191 - These only apply to KRA; and in CS 8.0,
+ // since KRA requests only need to refer
+ // to the actual "keyRecord" referenced
+ // by the "keySerialNumber" data,
+ // all other "KeyRecord" request data is
+ // ignored, since it is already stored
+ // in the actual "keyRecord".
+ if( data.startsWith( "keySerialNumber" ) ) {
+ String keySerialNumber = data.substring( data.indexOf( "=" ) + 1 );
+ System.out.println( extAttrPrefix +
+ encodeKey( key.toLowerCase() ) + ": " +
+ formatData( keySerialNumber ) );
+ }
+ } else if( type.startsWith( "java.util.Locale" ) ) {
+ // CMS 6.2: begin checking for new type
+ // "java.util.Locale"
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "com.netscape.certsrv.kra.ProofOfArchival" )
+ || type.startsWith( "com.netscape.cmscore.kra.ProofOfArchival" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "netscape.security.x509.RevokedCertImpl" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "java.lang.String[" ) ) {
+ // Bugzilla Bug #223360 (a.k.a - Raidzilla Bug #58086)
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if (type.startsWith("java.lang.String")) {
+ // Examples:
+ //
+ // key.equals( "publickey" )
+ // key.equals( "cert_request" )
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "java.util.Vector" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "netscape.security.x509.X509CertImpl[" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.equals( "netscape.security.x509.X509CertImpl" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.startsWith( "netscape.security.x509.X509CertInfo[" )
+ || type.startsWith( "netscape.security.extensions.CertInfo[" ) )
+ {
+ // CMS 6.2: begin checking for additional new type
+ // "netscape.security.extensions.CertInfo["
+ //
+ // CMS 6.1: "netscape.security.x509.X509CertInfo"
+ // now always utilizes arrays such as
+ // "netscape.security.x509.X509CertInfo["
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.equals( "netscape.security.x509.X509CertInfo" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else if( type.endsWith( "Exception" ) ) {
+ System.out.println( extAttrPrefix + encodeKey( key ) + ": " +
+ formatData( data ) );
+ } else {
+ System.err.println( "ERROR type - " + type + " - "+ attr );
+ System.exit( 0 );
+ }
+ }
+}
+
diff --git a/pki/base/migrate/TxtTo80/src/compile.sh b/pki/base/migrate/TxtTo80/src/compile.sh
new file mode 100755
index 000000000..c8dd848e0
--- /dev/null
+++ b/pki/base/migrate/TxtTo80/src/compile.sh
@@ -0,0 +1,345 @@
+#!/bin/bash
+
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2009 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+
+#####################################################################
+### ###
+### This script creates: ###
+### ###
+### "TxtTo80/classes/CS80LdifParser.class", ###
+### "TxtTo80/classes/DummyAuthManager.class", and ###
+### "TxtTo80/classes/Main.class", ###
+### ###
+### which may be used to convert a "normalized" ldif data file ###
+### exported from a version of CS prior to 8.0 into a CS 8.0 ###
+### ldif data file suitable for import into a CS 8.0 LDAP DB. ###
+### ###
+#####################################################################
+
+###
+### Provide a usage function
+###
+
+usage() {
+ echo
+ echo "Usage: $0"
+ echo
+ echo " NOTE: No arguments are required to build the"
+ echo " CS 8.0 ldif data classes."
+ echo
+ exit 255
+}
+
+###
+### Perform a usage check for the appropriate number of arguments:
+###
+
+if [ $# -gt 0 ] ; then
+ usage
+fi
+
+
+###
+### Set PKI_OS
+###
+### CS 8.0 NOTE: "Linux"
+### "SunOS"
+###
+
+PKI_OS=`uname`
+export PKI_OS
+
+if [ "${PKI_OS}" != "Linux" ] &&
+ [ "${PKI_OS}" != "SunOS" ]; then
+ printf "This '$0' script is ONLY executable\n"
+ printf "on either a 'Linux' or 'Solaris' machine!\n"
+ exit 255
+fi
+
+
+###
+### Set PKI_ARCHITECTURE
+###
+### CS 8.0 NOTE: "Linux i386" - 32-bit ("i386")
+### "Linux x86_64" - 64-bit ("x86_64")
+### "SunOS sparc" - 64-bit ("sparcv9")
+###
+
+if [ "${PKI_OS}" == "Linux" ]; then
+ PKI_PLATFORM=`uname -i`
+ export PKI_PLATFORM
+ if [ "${PKI_PLATFORM}" == "i386" ] ||
+ [ "${PKI_PLATFORM}" == "x86_64" ]; then
+ PKI_ARCHITECTURE="${PKI_PLATFORM}"
+ export PKI_ARCHITECTURE
+ else
+ printf "On 'Linux', this '$0' script is ONLY executable\n"
+ printf "on either an 'i386' or 'x86_64' architecture!\n"
+ exit 255
+ fi
+elif [ "${PKI_OS}" == "SunOS" ]; then
+ PKI_PLATFORM=`uname -p`
+ export PKI_PLATFORM
+ if [ "${PKI_PLATFORM}" == "sparc" ]; then
+ PKI_ARCHITECTURE="sparcv9"
+ export PKI_ARCHITECTURE
+ else
+ printf "On 'Solaris', this '$0' script is ONLY executable\n"
+ printf "on a 'sparcv9' architecture!\n"
+ exit 255
+ fi
+fi
+
+
+###
+### Set PKI_OS_DISTRIBUTION
+###
+### CS 8.0 NOTE: "Linux Fedora 8" - "Fedora"
+### "Linux Fedora 9" - "Fedora"
+### "Linux Fedora 10" - "Fedora"
+### "Linux RHEL 5" - "Red Hat"
+### "SunOS 5.9" - "Solaris"
+###
+
+if [ "${PKI_OS}" == "Linux" ]; then
+ IS_FEDORA=`test -e /etc/fedora-release && echo 1 || echo 0`
+ if [ "${IS_FEDORA}" -eq 1 ]; then
+ PKI_DISTRIBUTION="Fedora"
+ export PKI_DISTRIBUTION
+ PKI_OS_RPM_VERSION=`rpm -qf --qf='%{VERSION}' /etc/fedora-release`
+ export PKI_OS_RPM_VERSION
+ PKI_OS_VERSION=`echo "${PKI_OS_RPM_VERSION}" | tr -d [A-Za-z]`
+ export PKI_OS_VERSION
+ else
+ IS_REDHAT=`test -e /etc/redhat-release && echo 1 || echo 0`
+ if [ "${IS_REDHAT}" -eq 1 ]; then
+ PKI_DISTRIBUTION="Red Hat"
+ export PKI_DISTRIBUTION
+ PKI_OS_RPM_VERSION=`rpm -qf --qf='%{VERSION}' /etc/redhat-release`
+ export PKI_OS_RPM_VERSION
+ PKI_OS_VERSION=`echo "${PKI_OS_RPM_VERSION}" | tr -d [A-Za-z]`
+ export PKI_OS_VERSION
+ else
+ printf "On 'Linux',this '$0' script is ONLY executable\n"
+ printf "on either a 'Fedora' or 'Red Hat' machine!\n"
+ exit 255
+ fi
+ fi
+elif [ "${PKI_OS}" == "SunOS" ]; then
+ PKI_DISTRIBUTION="Solaris"
+ export PKI_DISTRIBUTION
+ PKI_OS_VERSION=`uname -r | awk -F. '{print $2}'`
+ export PKI_OS_VERSION
+fi
+
+
+###
+### Set JAVA_HOME
+###
+### CS 8.0 NOTE: "Linux Fedora 8" - JDK 1.7.0 (IcedTea)
+### "Linux Fedora 9" - JDK 1.6.0 (OpenJDK)
+### "Linux Fedora 10" - JDK 1.6.0 (OpenJDK)
+### "Linux RHEL 5" - JDK 1.6.0 (OpenJDK)
+### "SunOS 5.9" - JDK 1.6.0 (Sun JDK)
+###
+### "Linux" - ALWAYS set specific JAVA_HOME
+### "SunOS" - ALLOW JAVA_HOME to be pre-defined
+###
+
+if [ "${PKI_OS}" == "Linux" ]; then
+ if [ "${PKI_DISTRIBUTION}" == "Fedora" ]; then
+ if [ ${PKI_OS_VERSION} -eq 8 ]; then
+ if [ "${PKI_ARCHITECTURE}" == "i386" ]; then
+ JAVA_HOME="/usr/lib/jvm/java-1.7.0-icedtea"
+ JAVA_ARCHITECTURE="i386"
+ else # "x86_64"
+ JAVA_HOME="/usr/lib/jvm/java-1.7.0-icedtea.${PKI_ARCHITECTURE}"
+ JAVA_ARCHITECTURE="amd64"
+ fi
+ if [ ! -x "${JAVA_HOME}/bin/javac" ] &&
+ [ ! -f "${JAVA_HOME}/jre/lib/rt.jar" ] &&
+ [ ! -d "${JAVA_HOME}/jre/lib/${JAVA_ARCHITECTURE}" ] &&
+ [ ! -d "${JAVA_HOME}/jre/lib/${JAVA_ARCHITECTURE}/native_threads" ]; then
+ printf "On 'Fedora 8', this '$0' script is ONLY executable\n"
+ printf "by 'JDK 1.7.0 (IcedTea)'!\n"
+ exit 255
+ fi
+ elif [ ${PKI_OS_VERSION} -gt 8 ]; then
+ if [ "${PKI_ARCHITECTURE}" == "i386" ]; then
+ JAVA_HOME="/usr/lib/jvm/java-1.6.0-openjdk"
+ JAVA_ARCHITECTURE="i386"
+ else # "x86_64"
+ JAVA_HOME="/usr/lib/jvm/java-1.6.0-openjdk.${PKI_ARCHITECTURE}"
+ JAVA_ARCHITECTURE="amd64"
+ fi
+ if [ ! -x "${JAVA_HOME}/bin/javac" ] &&
+ [ ! -f "${JAVA_HOME}/jre/lib/rt.jar" ] &&
+ [ ! -d "${JAVA_HOME}/jre/lib/${JAVA_ARCHITECTURE}" ] &&
+ [ ! -d "${JAVA_HOME}/jre/lib/${JAVA_ARCHITECTURE}/native_threads" ]; then
+ printf "On 'Fedora ${PKI_OS_VERSION}', "
+ printf "this '$0' script is ONLY executable\n"
+ printf "by 'JDK 1.6.0 (OpenJDK)'!\n"
+ exit 255
+ fi
+ else
+ printf "On 'Fedora', this '$0' script is ONLY executable\n"
+ printf "on 'Fedora 8' or later!\n"
+ exit 255
+ fi
+ elif [ "${PKI_DISTRIBUTION}" == "Red Hat" ]; then
+ if [ ${PKI_OS_VERSION} -ge 5 ]; then
+ if [ "${PKI_ARCHITECTURE}" == "i386" ]; then
+ JAVA_HOME="/usr/lib/jvm/java-1.6.0-openjdk"
+ JAVA_ARCHITECTURE="i386"
+ else # "x86_64"
+ JAVA_HOME="/usr/lib/jvm/java-1.6.0-openjdk.${PKI_ARCHITECTURE}"
+ JAVA_ARCHITECTURE="amd64"
+ fi
+ if [ ! -x "${JAVA_HOME}/bin/javac" ] &&
+ [ ! -f "${JAVA_HOME}/jre/lib/rt.jar" ] &&
+ [ ! -d "${JAVA_HOME}/jre/lib/${JAVA_ARCHITECTURE}" ] &&
+ [ ! -d "${JAVA_HOME}/jre/lib/${JAVA_ARCHITECTURE}/native_threads" ]; then
+ printf "On 'RHEL ${PKI_OS_VERSION}', "
+ printf "this '$0' script is ONLY executable\n"
+ printf "by 'JDK 1.6.0 (OpenJDK)'!\n"
+ exit 255
+ fi
+ else
+ printf "On 'Red Hat', this '$0' script is ONLY executable\n"
+ printf "on 'RHEL 5' or later!\n"
+ exit 255
+ fi
+ fi
+ JDK_EXE="${JAVA_HOME}/bin/javac"
+ export JDK_EXE
+ JDK_VERSION=`${JAVA_HOME}/bin/javac -version 2>&1 | cut -b7-11`
+ export JDK_VERSION
+elif [ "${PKI_OS}" == "SunOS" ]; then
+ if [ "${JAVA_HOME}" == "" ]; then
+ JAVA_HOME="/usr/java"
+ fi
+ JDK_EXE="${JAVA_HOME}/bin/${PKI_ARCHITECTURE}/javac"
+ export JDK_EXE
+ JDK_VERSION=`${JAVA_HOME}/bin/${PKI_ARCHITECTURE}/javac -version 2>&1 | cut -b7-11`
+ export JDK_VERSION
+ if [ ${PKI_OS_VERSION} -eq 9 ]; then
+ if [ "${JDK_VERSION}" != "1.6.0" ]; then
+ printf "On 'Solaris ${PKI_OS_VERSION}', "
+ printf "this '$0' script is ONLY executable\n"
+ printf "by 'JDK 1.6.0'!\n"
+ exit 255
+ fi
+ if [ ! -x "${JAVA_HOME}/bin/${PKI_ARCHITECTURE}/javac" ] &&
+ [ ! -f "${JAVA_HOME}/jre/lib/rt.jar" ] &&
+ [ ! -d "${JAVA_HOME}/jre/lib/${PKI_ARCHITECTURE}" ] &&
+ [ ! -d "${JAVA_HOME}/jre/lib/${PKI_ARCHITECTURE}/native_threads" ]; then
+ printf "On 'Solaris ${PKI_OS_VERSION}', "
+ printf "this '$0' script is ONLY executable\n"
+ printf "by 'JDK 1.6.0 (Sun JDK)'!\n"
+ exit 255
+ fi
+ else
+ printf "On 'Solaris', this '$0' script is ONLY executable\n"
+ printf "on 'Solaris 9'!\n"
+ exit 255
+ fi
+fi
+
+
+###
+### Setup the appropriate CLASSPATH and LD_LIBRARY_PATH
+### environment variables based upon the platform
+###
+
+if [ ! -f "/usr/share/java/pki/cmscore.jar" ] &&
+ [ ! -f "/usr/share/java/pki/certsrv.jar" ]; then
+ printf "This '$0' script must be COMPILED against\n"
+ printf "the 'pki-common' package!\n"
+ exit 255
+fi
+if [ ! -f "/usr/share/java/pki/nsutil.jar" ]; then
+ printf "This '$0' script must be COMPILED against\n"
+ printf "the 'pki-util' package!\n"
+ exit 255
+fi
+
+if [ ${PKI_OS} = "Linux" ] ; then
+ if [ ! -f "/usr/lib/java/jss4.jar" ]; then
+ printf "This '$0' script must be COMPILED against\n"
+ printf "the 'jss' package!\n"
+ exit 255
+ fi
+ CLASSPATH=${JAVA_HOME}/jre/lib/rt.jar
+ CLASSPATH=/usr/lib/java/jss4.jar:${CLASSPATH}
+ CLASSPATH=/usr/share/java/pki/nsutil.jar:${CLASSPATH}
+ CLASSPATH=/usr/share/java/pki/cmscore.jar:${CLASSPATH}
+ CLASSPATH=/usr/share/java/pki/certsrv.jar:${CLASSPATH}
+ export CLASSPATH
+ if [ ${PKI_ARCHITECTURE} = "i386" ] ; then
+ LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/${JAVA_ARCHITECTURE}/native_threads
+ LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/${JAVA_ARCHITECTURE}:${LD_LIBRARY_PATH}
+ LD_LIBRARY_PATH=/usr/lib:${LD_LIBRARY_PATH}
+ export LD_LIBRARY_PATH
+ else # "x86_64"
+ LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/${JAVA_ARCHITECTURE}/native_threads
+ LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/${JAVA_ARCHITECTURE}:${LD_LIBRARY_PATH}
+ LD_LIBRARY_PATH=/usr/lib64:${LD_LIBRARY_PATH}
+ export LD_LIBRARY_PATH
+ fi
+else # "SunOS"
+ if [ ! -f "/usr/lib/java/dirsec/jss4.jar" ]; then
+ printf "This '$0' script must be COMPILED against\n"
+ printf "the 'dirsec-jss' package!\n"
+ exit 255
+ fi
+ CLASSPATH=${JAVA_HOME}/jre/lib/rt.jar
+ CLASSPATH=/usr/lib/java/dirsec/jss4.jar:${CLASSPATH}
+ CLASSPATH=/usr/share/java/pki/nsutil.jar:${CLASSPATH}
+ CLASSPATH=/usr/share/java/pki/cmscore.jar:${CLASSPATH}
+ CLASSPATH=/usr/share/java/pki/certsrv.jar:${CLASSPATH}
+ export CLASSPATH
+ LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/${PKI_ARCHITECTURE}/native_threads
+ LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/${PKI_ARCHITECTURE}:${LD_LIBRARY_PATH}
+ LD_LIBRARY_PATH=/usr/lib/${PKI_ARCHITECTURE}:${LD_LIBRARY_PATH}
+ LD_LIBRARY_PATH=/usr/lib/${PKI_ARCHITECTURE}/dirsec:${LD_LIBRARY_PATH}
+ export LD_LIBRARY_PATH
+fi
+
+
+###
+### Set TARGET - identify the complete path to the new classes target directory
+###
+
+TARGET=../classes
+export TARGET
+
+
+###
+### Create the new classes target directory (if it does not already exist)
+###
+
+if [ ! -d ${TARGET} ]; then
+ mkdir -p ${TARGET}
+fi
+
+
+###
+### Compile TxtTo80 - create "CS80LdifParser.class", "DummyAuthManager.class",
+### and "Main.class"
+###
+
+printf "================================================================\n"
+printf "PKI_OS='${PKI_OS}'\n"
+printf "PKI_DISTRIBUTION='${PKI_DISTRIBUTION}'\n"
+printf "PKI_OS_VERSION='${PKI_OS_VERSION}'\n"
+printf "PKI_ARCHITECTURE='${PKI_ARCHITECTURE}'\n"
+printf "JAVA_HOME='${JAVA_HOME}'\n"
+printf "JDK_EXE='${JDK_EXE}'\n"
+printf "JDK_VERSION='${JDK_VERSION}'\n"
+printf "================================================================\n\n"
+
+${JDK_EXE} -d ${TARGET} -classpath ${CLASSPATH} Main.java
+