jdk/test/sun/security/tools/jarsigner/TsacertOptionTest.java
author iignatyev
Mon, 12 Jun 2017 12:43:26 -0700
changeset 45467 99c87a16a8e4
parent 45287 e0bb5f83e17a
permissions -rw-r--r--
8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28662
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
     1
/*
44109
df1a27b17bc2 8176320: sun/security/tools/jarsigner/TsacertOptionTest.java compilation error, all mach 5 tier 2 platforms broken.
weijun
parents: 41591
diff changeset
     2
 * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
28662
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
     4
 *
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
     7
 * published by the Free Software Foundation.
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
     8
 *
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    13
 * accompanied this code).
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    14
 *
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    18
 *
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    21
 * questions.
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    22
 */
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    23
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    24
import jdk.testlibrary.OutputAnalyzer;
45287
e0bb5f83e17a 8180888: move jdk.testlibrary.JarUtils to the top level testlibrary
iignatyev
parents: 44109
diff changeset
    25
import jdk.test.lib.util.JarUtils;
28662
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    26
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    27
/**
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    28
 * @test
44109
df1a27b17bc2 8176320: sun/security/tools/jarsigner/TsacertOptionTest.java compilation error, all mach 5 tier 2 platforms broken.
weijun
parents: 41591
diff changeset
    29
 * @bug 8024302 8026037 8176320
28662
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    30
 * @summary The test signs and verifies a jar file with -tsacert option
40262
1b3dd37cb96d 8133910: Some sun/security/tools tests failed.
weijun
parents: 40252
diff changeset
    31
 * @library /lib/testlibrary warnings
44109
df1a27b17bc2 8176320: sun/security/tools/jarsigner/TsacertOptionTest.java compilation error, all mach 5 tier 2 platforms broken.
weijun
parents: 41591
diff changeset
    32
 * @library /test/lib
36966
4209c9e19c45 8153737: Unsupported Module
chegar
parents: 34382
diff changeset
    33
 * @modules java.base/sun.security.pkcs
30820
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 28662
diff changeset
    34
 *          java.base/sun.security.timestamp
41591
86396e0674ae 8168374: TsacertOptionTest.java fails on all platforms
weijun
parents: 40262
diff changeset
    35
 *          java.base/sun.security.tools.keytool
30820
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 28662
diff changeset
    36
 *          java.base/sun.security.util
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 28662
diff changeset
    37
 *          java.base/sun.security.x509
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 28662
diff changeset
    38
 *          java.management
45467
99c87a16a8e4 8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents: 45287
diff changeset
    39
 * @build jdk.test.lib.util.JarUtils
28662
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    40
 * @run main TsacertOptionTest
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    41
 */
40262
1b3dd37cb96d 8133910: Some sun/security/tools tests failed.
weijun
parents: 40252
diff changeset
    42
public class TsacertOptionTest extends Test {
28662
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    43
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    44
    private static final String FILENAME = TsacertOptionTest.class.getName()
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    45
            + ".txt";
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    46
    private static final String SIGNING_KEY_ALIAS = "sign_alias";
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    47
    private static final String TSA_KEY_ALIAS = "ts";
40262
1b3dd37cb96d 8133910: Some sun/security/tools tests failed.
weijun
parents: 40252
diff changeset
    48
1b3dd37cb96d 8133910: Some sun/security/tools tests failed.
weijun
parents: 40252
diff changeset
    49
    private static final String PASSWORD = "changeit";
28662
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    50
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    51
    /**
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    52
     * The test signs and verifies a jar file with -tsacert option,
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    53
     * and checks that no warning was shown.
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    54
     * A certificate that is addressed in -tsacert option contains URL to TSA
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    55
     * in Subject Information Access extension.
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    56
     */
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    57
    public static void main(String[] args) throws Throwable {
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    58
        TsacertOptionTest test = new TsacertOptionTest();
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    59
        test.start();
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    60
    }
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    61
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    62
    void start() throws Throwable {
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    63
        // create a jar file that contains one file
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    64
        Utils.createFiles(FILENAME);
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    65
        JarUtils.createJar(UNSIGNED_JARFILE, FILENAME);
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    66
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    67
        // create key pair for jar signing
40262
1b3dd37cb96d 8133910: Some sun/security/tools tests failed.
weijun
parents: 40252
diff changeset
    68
        keytool(
28662
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    69
                "-genkey",
34382
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    70
                "-alias", CA_KEY_ALIAS,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    71
                "-keyalg", KEY_ALG,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    72
                "-keysize", Integer.toString(KEY_SIZE),
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    73
                "-keystore", KEYSTORE,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    74
                "-storepass", PASSWORD,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    75
                "-keypass", PASSWORD,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    76
                "-dname", "CN=CA",
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    77
                "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0);
40262
1b3dd37cb96d 8133910: Some sun/security/tools tests failed.
weijun
parents: 40252
diff changeset
    78
        keytool(
34382
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    79
                "-genkey",
28662
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    80
                "-alias", SIGNING_KEY_ALIAS,
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    81
                "-keyalg", KEY_ALG,
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    82
                "-keysize", Integer.toString(KEY_SIZE),
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    83
                "-keystore", KEYSTORE,
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    84
                "-storepass", PASSWORD,
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
    85
                "-keypass", PASSWORD,
34382
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    86
                "-dname", "CN=Test").shouldHaveExitValue(0);
40262
1b3dd37cb96d 8133910: Some sun/security/tools tests failed.
weijun
parents: 40252
diff changeset
    87
        keytool(
34382
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    88
                "-certreq",
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    89
                "-alias", SIGNING_KEY_ALIAS,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    90
                "-keystore", KEYSTORE,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    91
                "-storepass", PASSWORD,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    92
                "-keypass", PASSWORD,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    93
                "-file", "certreq").shouldHaveExitValue(0);
40262
1b3dd37cb96d 8133910: Some sun/security/tools tests failed.
weijun
parents: 40252
diff changeset
    94
        keytool(
34382
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    95
                "-gencert",
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    96
                "-alias", CA_KEY_ALIAS,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    97
                "-keystore", KEYSTORE,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    98
                "-storepass", PASSWORD,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
    99
                "-keypass", PASSWORD,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
   100
                "-validity", Integer.toString(VALIDITY),
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
   101
                "-infile", "certreq",
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
   102
                "-outfile", "cert").shouldHaveExitValue(0);
40262
1b3dd37cb96d 8133910: Some sun/security/tools tests failed.
weijun
parents: 40252
diff changeset
   103
        keytool(
34382
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
   104
                "-importcert",
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
   105
                "-alias", SIGNING_KEY_ALIAS,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
   106
                "-keystore", KEYSTORE,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
   107
                "-storepass", PASSWORD,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
   108
                "-keypass", PASSWORD,
5d11306d6969 8130132: jarsigner should emit warning if weak algorithms or keysizes are used
weijun
parents: 31647
diff changeset
   109
                "-file", "cert").shouldHaveExitValue(0);
28662
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   110
40252
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   111
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   112
        try (TimestampCheck.Handler tsa = TimestampCheck.Handler.init(0,
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   113
                KEYSTORE)) {
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   114
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   115
            // look for free network port for TSA service
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   116
            int port = tsa.getPort();
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   117
            String host = "127.0.0.1";
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   118
            String tsaUrl = "http://" + host + ":" + port;
28662
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   119
40252
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   120
            // create key pair for TSA service
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   121
            // SubjectInfoAccess extension contains URL to TSA service
40262
1b3dd37cb96d 8133910: Some sun/security/tools tests failed.
weijun
parents: 40252
diff changeset
   122
            keytool(
40252
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   123
                    "-genkey",
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   124
                    "-v",
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   125
                    "-alias", TSA_KEY_ALIAS,
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   126
                    "-keyalg", KEY_ALG,
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   127
                    "-keysize", Integer.toString(KEY_SIZE),
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   128
                    "-keystore", KEYSTORE,
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   129
                    "-storepass", PASSWORD,
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   130
                    "-keypass", PASSWORD,
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   131
                    "-dname", "CN=TSA",
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   132
                    "-ext", "ExtendedkeyUsage:critical=timeStamping",
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   133
                    "-ext", "SubjectInfoAccess=timeStamping:URI:" + tsaUrl,
8f320a3f83b8 8163489: Avoid using Utils.getFreePort() in TsacertOptionTest.java test
weijun
parents: 36966
diff changeset
   134
                    "-validity", Integer.toString(VALIDITY)).shouldHaveExitValue(0);
28662
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   135
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   136
            // start TSA
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   137
            tsa.start();
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   138
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   139
            // sign jar file
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   140
            // specify -tsadigestalg option because
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   141
            // TSA server uses SHA-1 digest algorithm
40262
1b3dd37cb96d 8133910: Some sun/security/tools tests failed.
weijun
parents: 40252
diff changeset
   142
             OutputAnalyzer analyzer = jarsigner(
31647
9c848765e848 8130041: TsacertOptionTest.java intermittently fails on Mac
vinnie
parents: 30820
diff changeset
   143
                    "-J-Dhttp.proxyHost=",
9c848765e848 8130041: TsacertOptionTest.java intermittently fails on Mac
vinnie
parents: 30820
diff changeset
   144
                    "-J-Dhttp.proxyPort=",
9c848765e848 8130041: TsacertOptionTest.java intermittently fails on Mac
vinnie
parents: 30820
diff changeset
   145
                    "-J-Djava.net.useSystemProxies=",
28662
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   146
                    "-verbose",
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   147
                    "-keystore", KEYSTORE,
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   148
                    "-storepass", PASSWORD,
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   149
                    "-keypass", PASSWORD,
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   150
                    "-signedjar", SIGNED_JARFILE,
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   151
                    "-tsacert", TSA_KEY_ALIAS,
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   152
                    "-tsadigestalg", "SHA-1",
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   153
                    UNSIGNED_JARFILE,
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   154
                    SIGNING_KEY_ALIAS);
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   155
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   156
            analyzer.shouldHaveExitValue(0);
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   157
            analyzer.stdoutShouldNotContain(WARNING);
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   158
            analyzer.shouldContain(JAR_SIGNED);
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   159
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   160
            // verify signed jar
40262
1b3dd37cb96d 8133910: Some sun/security/tools tests failed.
weijun
parents: 40252
diff changeset
   161
            analyzer = jarsigner(
28662
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   162
                    "-verbose",
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   163
                    "-verify",
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   164
                    "-keystore", KEYSTORE,
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   165
                    "-storepass", PASSWORD,
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   166
                    SIGNED_JARFILE);
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   167
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   168
            analyzer.shouldHaveExitValue(0);
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   169
            analyzer.stdoutShouldNotContain(WARNING);
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   170
            analyzer.shouldContain(JAR_VERIFIED);
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   171
        }
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   172
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   173
        System.out.println("Test passed");
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   174
    }
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   175
efd0203db371 8049171: Additional tests for jarsigner's warnings
asmotrak
parents:
diff changeset
   176
}