From dd8d873edd65b0b41722f56e57abea04d00d3346 Mon Sep 17 00:00:00 2001 From: "sandeep.konchady%sun.com" Date: Tue, 17 May 2005 21:15:12 +0000 Subject: [PATCH] Modified build_java.pl to create a MANIFEST.MF file with JSS product version information. This is then added to xpclass(_dbg).jar using jar -tvf in place of zip -R. Modified all.pl to execute a new test that checks for product package version information in jss4.jar as well as compare this to the version of library (libjss4.so or jss4.dll) being used. This helps in consistency check for jss jar and associated lib. Added a new test JSSPackaeTest.java that reads MANIFEST.MF from jss jar to fetch product version information. --- security/jss/build_java.pl | 20 ++++- .../org/mozilla/jss/tests/JSSPackageTest.java | 88 +++++++++++++++++++ security/jss/org/mozilla/jss/tests/all.pl | 22 +++++ 3 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 security/jss/org/mozilla/jss/tests/JSSPackageTest.java diff --git a/security/jss/build_java.pl b/security/jss/build_java.pl index 7d852b346412..dc86df8050b7 100644 --- a/security/jss/build_java.pl +++ b/security/jss/build_java.pl @@ -159,6 +159,23 @@ sub build { copy($debug_source_file, $debug_target_file) or die "Copying file: $!"; } + # + # generate manifest.mf file in lib dir + # + my $manifest_file = "MANIFEST.MF"; + my $jss_revision = `grep JSS_VERSION org/mozilla/jss/util/jssver.h`; + chop($jss_revision); + $jss_revision = substr($jss_revision, 22, 3); + my $build_revision = $jss_revision; + system("echo \"Manifest-Version: 1.0\" > $manifest_file"); + system("echo \"\" >> $manifest_file"); + system("echo \"Name: org/mozilla/jss/\" >> $manifest_file"); + system("echo \"Specification-Title: Network Security Services for Java (JSS)\" >> $manifest_file"); + system("echo \"Specification-Version: $jss_revision\" >> $manifest_file"); + system("echo \"Specification-Vendor: Mozilla Foundation\" >> $manifest_file"); + system("echo \"Implementation-Title: org.mozilla.jss\" >> $manifest_file"); + system("echo \"Implementation-Version: $build_revision\" >> $manifest_file"); + system("echo \"Implementation-Vendor: Mozilla Foundation\" >> $manifest_file"); # # recursively find *.java @@ -195,7 +212,8 @@ sub build { ensure_dir_exists($class_dir); print_do("$javac $javac_opt_flag -sourcepath . -d $class_dir " . "$classpath " . join(" ",@source_list)); - print_do("sh -c 'pwd && cd $class_dir && pwd && rm -f $class_jar && pwd && ls -al && ls -al ../../dist && zip -r $class_jar *'"); + print_do("sh -c 'pwd && cd $class_dir && pwd && rm -f $class_jar && pwd && ls -al && ls -al ../../dist && jar -cvmf ../../security/jss/$manifest_file $class_jar *'"); + print_do("rm -f $manifest_file"); print "Exit status was " . ($?>>8) . "\n"; } diff --git a/security/jss/org/mozilla/jss/tests/JSSPackageTest.java b/security/jss/org/mozilla/jss/tests/JSSPackageTest.java new file mode 100644 index 000000000000..fc6078a95ba4 --- /dev/null +++ b/security/jss/org/mozilla/jss/tests/JSSPackageTest.java @@ -0,0 +1,88 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Netscape Security Services for Java. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +package org.mozilla.jss.tests; + +import org.mozilla.jss.ssl.*; +import org.mozilla.jss.CryptoManager; +import org.mozilla.jss.crypto.*; +import org.mozilla.jss.asn1.*; +import org.mozilla.jss.pkix.primitive.*; +import org.mozilla.jss.pkix.cert.*; +import org.mozilla.jss.pkix.cert.Certificate; +import org.mozilla.jss.util.PasswordCallback; + +public class JSSPackageTest { + + private static CryptoManager cm = null; + + public static void main(String[] args) { + try { + try { + CryptoManager.initialize("."); + } catch (Exception e) { } + + Package pkg = Package.getPackage("org.mozilla.jss"); + + System.out.println("\n---------------------------------------------------------"); + System.out.println("Checking jss jar and library version"); + System.out.println("---------------------------------------------------------"); + System.out.println(" Introspecting jss jar file"); + System.out.println("Package name:\t" + pkg.getName()); + + System.out.println("Spec title :\t" + pkg.getSpecificationTitle()); + System.out.println("Spec vendor :\t" + pkg.getSpecificationVendor()); + System.out.println("Spec version:\t" + pkg.getSpecificationVersion()); + + System.out.println("Impl title :\t" + pkg.getImplementationTitle()); + System.out.println("Impl vendor :\t" + pkg.getImplementationVendor()); + System.out.println("Impl version:\t" + pkg.getImplementationVersion()); + + System.out.println("\n Fetching version information from CryptoManager"); + System.out.println(CryptoManager.JAR_JSS_VERSION); + System.out.println(CryptoManager.JAR_NSS_VERSION); + System.out.println(CryptoManager.JAR_NSPR_VERSION); + + System.out.println("\n Checking for header information in jss library"); + System.exit(0); + + } catch (Exception e) { + System.out.println("Exception caught : " + e.getMessage()); + e.printStackTrace(); + System.exit(1); + } + } +} diff --git a/security/jss/org/mozilla/jss/tests/all.pl b/security/jss/org/mozilla/jss/tests/all.pl index faacbaacff17..c83f1f559daf 100644 --- a/security/jss/org/mozilla/jss/tests/all.pl +++ b/security/jss/org/mozilla/jss/tests/all.pl @@ -53,6 +53,8 @@ my $dist_dir; my $pathsep = ":"; my $scriptext = "sh"; my $exe_suffix = ""; +my $lib_suffix = ".so"; +my $lib_jss = "libjss"; my $jss_rel_dir = ""; my $jss_classpath = ""; @@ -70,6 +72,8 @@ sub setup_vars { $truncate_lib_path = 0; $pathsep = ";"; $exe_suffix = ".exe"; + $lib_suffix = ".dll"; + $lib_jss = "jss"; } else { $ld_lib_path = "LD_LIBRARY_PATH"; $scriptext = "sh"; @@ -270,3 +274,21 @@ $result = system("$java org.mozilla.jss.tests.JSSE_SSLClient"); $result >>=8; $result and die "JSSE client returned $result"; +# +# Test for JSS jar and library revision +# +print STDERR "============= Check JSS jar version\n"; +$result = system("$java org.mozilla.jss.tests.JSSPackageTest"); +$result >>=8; +my $LIB = "$lib_jss"."4"."$lib_suffix"; +my $strings_exist = `which strings`; +chop($strings_exist); +if ($strings_exist ne "") { + my $jsslibver = `strings $nss_lib_dir/$LIB | grep Header`; + chop($jsslibver); + print "$LIB = $jsslibver\n"; +} else { + print "Could not fetch Header information from $LIB\n"; +} +$result and die "JSS jar package information test $result"; +