test/jdk/java/security/KeyStore/PKCS12/KeytoolReaderP12Test.java
author igerasim
Wed, 16 Oct 2019 18:47:11 -0700
changeset 58659 4113f16d5109
parent 51687 1e39953aaed8
permissions -rw-r--r--
8231859: Extra dash after the exception name in @throws clause of javadoc Reviewed-by: weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31718
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
     1
/*
51675
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 47216
diff changeset
     2
 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
31718
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
     4
 *
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
     8
 *
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    13
 * accompanied this code).
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    14
 *
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    18
 *
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    21
 * questions.
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    22
 */
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    23
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    24
import java.io.File;
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    25
import java.io.IOException;
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    26
import java.nio.file.Files;
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    27
import java.nio.file.StandardOpenOption;
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    28
import java.util.Base64;
51675
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 47216
diff changeset
    29
import jdk.test.lib.process.OutputAnalyzer;
31718
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    30
import static java.lang.System.out;
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    31
import java.nio.file.Paths;
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    32
import java.util.List;
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    33
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    34
/**
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    35
 * @test
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    36
 * @bug 8048830
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    37
 * @summary Test for PKCS12 keystore list , export commands. Refer README for
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    38
 * keystore files information
51687
1e39953aaed8 8182404: remove jdk.testlibrary.JDKToolFinder and JDKToolLauncher
iignatyev
parents: 51675
diff changeset
    39
 * @library ../
51675
b487c1e914d0 8210112: remove jdk.testlibrary.ProcessTools
iignatyev
parents: 47216
diff changeset
    40
 * @library /test/lib
31718
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    41
 * @run main KeytoolReaderP12Test
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    42
 */
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    43
public class KeytoolReaderP12Test {
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    44
    private static final String WORKING_DIRECTORY = System.getProperty(
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    45
            "test.classes", "."+ File.separator);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    46
    //private static final String KS_PASSWD = "pass";
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    47
    private static final String KS_PASSWD = "storepass";
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    48
    private static final String CERT_CHAIN_PASSWD = "password";
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    49
    private static final String SOURCE_DIRECTORY =
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    50
            System.getProperty("test.src", "." + File.separator);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    51
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    52
    public static void main(String[] args) throws Exception {
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    53
        List<String> expectedValues = null;
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    54
        out.println("Self signed test");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    55
        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    56
                "api_private_key.p12_expected.data"));
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    57
        readTest("api_private_key.p12.data", KS_PASSWD, expectedValues);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    58
        out.println("Self signed test Passed");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    59
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    60
        out.println("private key with selfsigned cert, key pair not match");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    61
        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    62
                "api_private_key_not_match.p12_expected.data"));
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    63
        readTest("api_private_key_not_match.p12.data", KS_PASSWD,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    64
                expectedValues);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    65
        out.println("private key with selfsigned cert, key pair "
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    66
                + "not match passed");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    67
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    68
        out.println("cert chain test");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    69
        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    70
                "api_cert_chain.p12_expected.data"));
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    71
        readTest("api_cert_chain.p12.data", CERT_CHAIN_PASSWD, expectedValues);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    72
        out.println("cert chain test passed");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    73
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    74
        out.println("IE self test");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    75
        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    76
                "ie_self.pfx.pem"));
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    77
        exportTest("ie_self.pfx.data", "pkcs12testenduser1",
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    78
                KS_PASSWD, expectedValues);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    79
        out.println("IE self test passed");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    80
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    81
        out.println("IE chain test");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    82
        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    83
                "ie_chain.pfx.pem"));
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    84
        exportTest("ie_chain.pfx.data", "servercert",
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    85
                CERT_CHAIN_PASSWD, expectedValues);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    86
        out.println("IE chain test passed");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    87
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    88
        out.println("Netscape self");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    89
        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    90
                "netscape_self.p12.pem"));
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    91
        exportTest("netscape_self.p12.data", "pkcs12testenduser1",
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    92
                KS_PASSWD, expectedValues);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    93
        out.println("Netscape self passed");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    94
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    95
        out.println("Mozilla self test");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    96
        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    97
                "mozilla_self.p12.pem"));
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    98
        exportTest("mozilla_self.p12.data", "pkcs12testenduser1",
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
    99
                KS_PASSWD, expectedValues);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   100
        out.println("Mozilla self test passed");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   101
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   102
        out.println("Openssl test");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   103
        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   104
                "openssl.p12.pem"));
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   105
        exportTest("openssl.p12.data", "servercert", CERT_CHAIN_PASSWD, expectedValues);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   106
        out.println("openssl test passed");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   107
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   108
        out.println("with different keystore and entrykey password");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   109
        expectedValues = Files.readAllLines(Paths.get(SOURCE_DIRECTORY,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   110
                "api_two_pass.p12_expected.data"));
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   111
        readTest("api_two_pass.p12.data", KS_PASSWD,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   112
                expectedValues);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   113
        out.println("two pass test passed");
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   114
    }
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   115
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   116
    private static void readTest(String name, String password,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   117
            List<String> expectedValues)
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   118
            throws IOException {
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   119
        convertToPFX(name);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   120
        final String[] command = new String[]{"-debug", "-list", "-v",
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   121
            "-keystore", WORKING_DIRECTORY + File.separator + name,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   122
            "-storetype", "pkcs12", "-storepass", password};
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   123
        runAndValidate(command, expectedValues);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   124
    }
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   125
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   126
    private static void exportTest(String name, String alias,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   127
            String password, List<String> expectedValues)
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   128
            throws IOException {
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   129
        convertToPFX(name);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   130
        final String[] command = new String[]{"-debug", "-export", "-alias",
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   131
            alias, "-keystore", WORKING_DIRECTORY + File.separator + name,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   132
            "-storepass", password, "-storetype", "pkcs12", "-rfc"};
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   133
        runAndValidate(command, expectedValues);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   134
    }
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   135
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   136
    private static void runAndValidate(String[] command,
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   137
            List<String> expectedValues) throws IOException {
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   138
        OutputAnalyzer output = Utils.executeKeytoolCommand(command);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   139
        if (expectedValues != null) {
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   140
            expectedValues.stream().forEach(line -> {
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   141
                output.shouldContain(line);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   142
            });
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   143
        }
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   144
    }
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   145
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   146
    /**
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   147
     * Decodes the base64 encoded keystore and writes into new file
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   148
     * @param name base64 encoded keystore name
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   149
     */
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   150
    private static void convertToPFX(String name) throws IOException{
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   151
        File base64File = new File(SOURCE_DIRECTORY, name);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   152
        File pkcs12File = new File(WORKING_DIRECTORY, name);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   153
        byte[] input = Files.readAllBytes(base64File.toPath());
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   154
        Files.write(pkcs12File.toPath(), Base64.getMimeDecoder().
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   155
                decode(input), StandardOpenOption.CREATE);
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   156
    }
c10ac6f1e391 8048830: Implement tests for new functionality provided in JEP 166
vinnie
parents:
diff changeset
   157
}