jdk/test/lib/security/SecurityTools.java
changeset 43097 69b209a7a0a4
parent 43060 ed4f16888e12
parent 43096 22875dc4eec5
child 43098 124d24e7988c
--- a/jdk/test/lib/security/SecurityTools.java	Thu Jan 12 23:41:17 2017 +0000
+++ /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;
-    }
-}