Path: blob/master/test/jdk/sun/security/tools/keytool/NssTest.java
41152 views
/*1* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.io.IOException;24import java.nio.file.Files;25import java.nio.file.Path;26import java.nio.file.Paths;2728/*29* @test30* @summary It tests (almost) all keytool behaviors with NSS.31* @library /test/lib /test/jdk/sun/security/pkcs1132* @modules java.base/sun.security.tools.keytool33* java.base/sun.security.util34* java.base/sun.security.x50935* @run main/othervm/timeout=600 NssTest36*/37public class NssTest {3839public static void main(String[] args) throws Exception {40Path libPath = PKCS11Test.getNSSLibPath("softokn3");41if (libPath == null) {42return;43}44System.out.println("Using NSS lib at " + libPath);4546copyFiles();47System.setProperty("nss", "");48System.setProperty("nss.lib", String.valueOf(libPath));4950PKCS11Test.loadNSPR(libPath.getParent().toString());51KeyToolTest.main(args);52}5354private static void copyFiles() throws IOException {55Path srcPath = Paths.get(System.getProperty("test.src"));56Files.copy(srcPath.resolve("p11-nss.txt"), Paths.get("p11-nss.txt"));5758Path dbPath = srcPath.getParent().getParent()59.resolve("pkcs11").resolve("nss").resolve("db");60Files.copy(dbPath.resolve("cert8.db"), Paths.get("cert8.db"));61Files.copy(dbPath.resolve("key3.db"), Paths.get("key3.db"));62Files.copy(dbPath.resolve("secmod.db"), Paths.get("secmod.db"));63}64}656667