8171423: Relocate /test/lib/security/SecurityTools.java
Reviewed-by: weijun, xuelei
--- a/jdk/test/lib/security/SecurityTools.java Thu Jan 12 16:41:08 2017 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code 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
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
-
-public class SecurityTools {
-
- public static final String NO_ALIAS = null;
-
- // keytool
-
- public static OutputAnalyzer keytool(List<String> options)
- throws Throwable {
-
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("keytool")
- .addVMArg("-Duser.language=en")
- .addVMArg("-Duser.country=US");
- for (String option : options) {
- if (option.startsWith("-J")) {
- launcher.addVMArg(option.substring(2));
- } else {
- launcher.addToolArg(option);
- }
- }
- return ProcessTools.executeCommand(launcher.getCommand());
- }
-
- public static OutputAnalyzer keytool(String options) throws Throwable {
- return keytool(options.split("\\s+"));
- }
-
- public static OutputAnalyzer keytool(String... options) throws Throwable {
- return keytool(List.of(options));
- }
-
- // jarsigner
-
- public static OutputAnalyzer jarsigner(String jar, String alias,
- List<String> options) throws Throwable {
- JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jarsigner")
- .addVMArg("-Duser.language=en")
- .addVMArg("-Duser.country=US");
- for (String option : options) {
- if (option.startsWith("-J")) {
- launcher.addVMArg(option.substring(2));
- } else {
- launcher.addToolArg(option);
- }
- }
- launcher.addToolArg(jar);
- if (alias != null) {
- launcher.addToolArg(alias);
- }
- return ProcessTools.executeCommand(launcher.getCommand());
- }
-
- public static OutputAnalyzer jarsigner(String jar, String alias,
- String options) throws Throwable {
-
- return jarsigner(jar, alias, options.split("\\s+"));
- }
-
- public static OutputAnalyzer jarsigner(String jar, String alias,
- String... options) throws Throwable {
-
- return jarsigner(jar, alias, List.of(options));
- }
-
- public static OutputAnalyzer sign(String jar, String alias, String... options)
- throws Throwable {
-
- return jarsigner(jar, alias,
- mergeOptions("-J-Djava.security.egd=file:/dev/./urandom", options));
- }
-
- public static OutputAnalyzer verify(String jar, String... options)
- throws Throwable {
-
- return jarsigner(jar, NO_ALIAS, mergeOptions("-verify", options));
- }
-
- // helper methods
-
- private static List<String> mergeOptions(
- String firstOption, String... secondPart) {
-
- return mergeOptions(List.of(firstOption), secondPart);
- }
-
- private static List<String> mergeOptions(
- List<String> firstPart, String... secondPart) {
-
- List<String> options = new ArrayList<>(firstPart);
- Collections.addAll(options, secondPart);
- return options;
- }
-}
--- a/jdk/test/sun/security/tools/keytool/PrintSSL.java Thu Jan 12 16:41:08 2017 -0800
+++ b/jdk/test/sun/security/tools/keytool/PrintSSL.java Thu Jan 12 17:10:41 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,7 @@
* @test
* @bug 6480981 8160624
* @summary keytool should be able to import certificates from remote SSL server
- * @library /lib/security
- * @library /lib/testlibrary
+ * @library /test/lib
* @run main/othervm PrintSSL
*/
@@ -36,7 +35,8 @@
import java.util.concurrent.CountDownLatch;
import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.SSLSocket;
-import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
public class PrintSSL {
--- a/jdk/test/sun/security/tools/keytool/ReadJar.java Thu Jan 12 16:41:08 2017 -0800
+++ b/jdk/test/sun/security/tools/keytool/ReadJar.java Thu Jan 12 17:10:41 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,14 +25,15 @@
* @test
* @bug 6890872 8168882
* @summary keytool -printcert to recognize signed jar files
- * @library /lib/security
+ * @library /test/lib
* @library /lib/testlibrary
*/
import java.nio.file.Files;
import java.nio.file.Paths;
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
import jdk.testlibrary.JarUtils;
-import jdk.testlibrary.OutputAnalyzer;
public class ReadJar {