test/jdk/sun/security/tools/keytool/RemoveKeyAlgDefault.java
author weijun
Fri, 15 Nov 2019 09:06:58 +0800
changeset 59104 046e4024e55a
parent 52791 test/jdk/sun/security/tools/keytool/DeprecateKeyalg.java@a6ede2dabe20
permissions -rw-r--r--
8214024: Remove the default keytool -keyalg value Reviewed-by: mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52598
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
     1
/*
59104
046e4024e55a 8214024: Remove the default keytool -keyalg value
weijun
parents: 52791
diff changeset
     2
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
52598
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
     4
 *
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
     7
 * published by the Free Software Foundation.
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
     8
 *
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    13
 * accompanied this code).
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    14
 *
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    18
 *
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    21
 * questions.
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    22
 */
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    23
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    24
import jdk.test.lib.SecurityTools;
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    25
import jdk.test.lib.process.OutputAnalyzer;
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    26
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    27
/**
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    28
 * @test
59104
046e4024e55a 8214024: Remove the default keytool -keyalg value
weijun
parents: 52791
diff changeset
    29
 * @bug 8212003 8214024
52598
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    30
 * @summary Deprecating the default keytool -keyalg option
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    31
 * @library /test/lib
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    32
 */
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    33
59104
046e4024e55a 8214024: Remove the default keytool -keyalg value
weijun
parents: 52791
diff changeset
    34
public class RemoveKeyAlgDefault {
52598
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    35
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    36
    private static final String COMMON = "-keystore ks -storetype jceks "
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    37
            + "-storepass changeit -keypass changeit";
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    38
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    39
    public static void main(String[] args) throws Throwable {
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    40
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    41
        kt("-genkeypair -keyalg DSA -alias a -dname CN=A")
59104
046e4024e55a 8214024: Remove the default keytool -keyalg value
weijun
parents: 52791
diff changeset
    42
                .shouldHaveExitValue(0)
52598
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    43
                .shouldContain("Generating")
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    44
                .shouldNotContain("-keyalg option must be specified");
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    45
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    46
        kt("-genkeypair -alias b -dname CN=B")
59104
046e4024e55a 8214024: Remove the default keytool -keyalg value
weijun
parents: 52791
diff changeset
    47
                .shouldHaveExitValue(1)
52598
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    48
                .shouldContain("-keyalg option must be specified");
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    49
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    50
        kt("-genseckey -keyalg DES -alias c")
59104
046e4024e55a 8214024: Remove the default keytool -keyalg value
weijun
parents: 52791
diff changeset
    51
                .shouldHaveExitValue(0)
52598
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    52
                .shouldContain("Generated")
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    53
                .shouldNotContain("-keyalg option must be specified");
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    54
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    55
        kt("-genseckey -alias d")
59104
046e4024e55a 8214024: Remove the default keytool -keyalg value
weijun
parents: 52791
diff changeset
    56
                .shouldHaveExitValue(1)
52598
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    57
                .shouldContain("-keyalg option must be specified");
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    58
    }
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    59
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    60
    private static OutputAnalyzer kt(String cmd) throws Throwable {
59104
046e4024e55a 8214024: Remove the default keytool -keyalg value
weijun
parents: 52791
diff changeset
    61
        return SecurityTools.keytool(COMMON + " " + cmd);
52598
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    62
    }
0379b618ec46 8212003: Deprecating the default keytool -keyalg option
weijun
parents:
diff changeset
    63
}