test/jdk/sun/security/tools/keytool/NssTest.java
author jjiang
Fri, 03 May 2019 15:57:41 +0800
changeset 54697 251090f84412
parent 51944 28085dba5d9a
permissions -rw-r--r--
8204203: Many pkcs11 tests failed in Provider initialization, after compiler on Windows changed Summary: Build NSS 3.41 with VS2017 and also upgrade to this NSS for macosx Reviewed-by: valeriep
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51944
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
     1
/*
54697
251090f84412 8204203: Many pkcs11 tests failed in Provider initialization, after compiler on Windows changed
jjiang
parents: 51944
diff changeset
     2
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
51944
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
     4
 *
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
     7
 * published by the Free Software Foundation.
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
     8
 *
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    13
 * accompanied this code).
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    14
 *
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    18
 *
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    21
 * questions.
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    22
 */
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    23
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    24
import java.io.IOException;
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    25
import java.nio.file.Files;
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    26
import java.nio.file.Path;
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    27
import java.nio.file.Paths;
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    28
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    29
/*
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    30
 * @test
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    31
 * @summary It tests (almost) all keytool behaviors with NSS.
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    32
 * @library /test/lib /test/jdk/sun/security/pkcs11
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    33
 * @modules java.base/sun.security.tools.keytool
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    34
 *          java.base/sun.security.util
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    35
 *          java.base/sun.security.x509
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    36
 * @run main/othervm/timeout=600 NssTest
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    37
 */
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    38
public class NssTest {
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    39
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    40
    public static void main(String[] args) throws Exception {
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    41
        Path libPath = PKCS11Test.getNSSLibPath("softokn3");
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    42
        if (libPath == null) {
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    43
            return;
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    44
        }
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    45
        System.out.println("Using NSS lib at " + libPath);
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    46
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    47
        copyFiles();
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    48
        System.setProperty("nss", "");
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    49
        System.setProperty("nss.lib", String.valueOf(libPath));
54697
251090f84412 8204203: Many pkcs11 tests failed in Provider initialization, after compiler on Windows changed
jjiang
parents: 51944
diff changeset
    50
251090f84412 8204203: Many pkcs11 tests failed in Provider initialization, after compiler on Windows changed
jjiang
parents: 51944
diff changeset
    51
        PKCS11Test.loadNSPR(libPath.getParent().toString());
51944
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    52
        KeyToolTest.main(args);
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    53
    }
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    54
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    55
    private static void copyFiles() throws IOException {
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    56
        Path srcPath = Paths.get(System.getProperty("test.src"));
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    57
        Files.copy(srcPath.resolve("p11-nss.txt"), Paths.get("p11-nss.txt"));
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    58
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    59
        Path dbPath = srcPath.getParent().getParent()
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    60
                .resolve("pkcs11").resolve("nss").resolve("db");
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    61
        Files.copy(dbPath.resolve("cert8.db"), Paths.get("cert8.db"));
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    62
        Files.copy(dbPath.resolve("key3.db"), Paths.get("key3.db"));
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    63
        Files.copy(dbPath.resolve("secmod.db"), Paths.get("secmod.db"));
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    64
    }
28085dba5d9a 8209546: Make sun/security/tools/keytool/autotest.sh to support macosx
jjiang
parents:
diff changeset
    65
}