CheckManifestForRelease.java revision 5434
0N/A/*
1949N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * @test
0N/A * @bug 7195931 7197071
0N/A * @summary UnsatisfiedLinkError on PKCS11.C_GetOperationState while
0N/A * using NSS from jre7u6+
0N/A */
0N/Aimport java.net.*;
0N/Aimport java.io.*;
0N/Aimport java.security.*;
0N/A
0N/A/**
0N/A * When the Java specification version is incremented, all of the providers
0N/A * must be recompiled with the proper implementation version to match.
0N/A */
0N/Apublic class CheckManifestForRelease {
0N/A
1010N/A /**
1010N/A * @param args the command line arguments
1010N/A */
1010N/A public static void main(String[] args) throws Exception {
1010N/A checkP11MessageDigestClone();
1010N/A checkManifest();
1010N/A }
1010N/A
1010N/A /*
1010N/A * Check the root cause, no manifest values.
1010N/A */
0N/A static private void checkManifest() throws Exception {
0N/A System.out.println("=============");
0N/A String specVersion = System.getProperty("java.specification.version");
0N/A String extDirName = System.getProperty("java.home", ".") + "/"
0N/A + "lib/ext";
0N/A
0N/A // Current list of JCE providers. Add if more are created.
0N/A String[] files = new String[]{
0N/A "sunjce_provider.jar",
0N/A "sunec.jar",
0N/A "sunmscapi.jar",
0N/A "sunpkcs11.jar",
0N/A "ucrypto.jar"
0N/A };
0N/A
0N/A System.out.println("Checking in " + extDirName);
0N/A
0N/A for (String file : files) {
0N/A System.out.println("Checking: " + file);
0N/A String urlString = "jar:file:" + extDirName + "/" + file + "!/";
0N/A JarURLConnection urlc =
0N/A (JarURLConnection) (new URL(urlString).openConnection());
0N/A
0N/A String implVersion;
0N/A try {
0N/A /*
0N/A * If the file doesn't exist (e.g. mscapi on solaris),
0N/A * skip it. If there are other problems, fail out.
0N/A */
0N/A implVersion = urlc.getManifest().getMainAttributes().getValue(
0N/A "Implementation-Version");
0N/A } catch (FileNotFoundException e) {
0N/A System.out.println(" " + file + " not found, skipping...");
0N/A continue;
0N/A }
0N/A
0N/A if (implVersion == null) {
0N/A throw new Exception(
0N/A "Implementation-Version not found in Manifest");
0N/A }
0N/A
0N/A if (!implVersion.startsWith(specVersion)) {
0N/A throw new Exception(
0N/A "Implementation-Version does not match " +
0N/A "Specification-Version");
0N/A }
0N/A }
0N/A }
0N/A
0N/A /*
1601N/A * Check the symptom, an UnsatisfiedLinkError
1601N/A */
1601N/A static private void checkP11MessageDigestClone() throws Exception {
1601N/A System.out.println("=============");
1601N/A System.out.println("Checking for UnsatisfiedLinkError");
1601N/A String os = System.getProperty("os.name");
1601N/A // Only run on Solaris
1601N/A if (!os.equals("SunOS")) {
1601N/A return;
1601N/A }
1601N/A
1601N/A /*
1601N/A * We have to do some gyrations here, since the code to exercise
1601N/A * this is in the P11 MessageDigests, and most of mechanisms are
1601N/A * disabled by default.
1601N/A */
0N/A String customP11File =
0N/A System.getProperty("TESTSRC", ".") + "/p11-solaris.txt";
0N/A
0N/A try {
0N/A Provider provider =
0N/A new sun.security.pkcs11.SunPKCS11(customP11File);
1015N/A
1015N/A MessageDigest md = MessageDigest.getInstance("SHA1", provider);
1015N/A md.update((byte) 0x01);
1601N/A System.out.println(md.getProvider());
1015N/A
1601N/A md.clone();
0N/A } catch (Exception e) {
0N/A // These kinds of failure is ok. We're testing the
1601N/A // UnsatisfiedLinkError here.
1601N/A return;
1010N/A }
1010N/A }
1010N/A}
1010N/A