author | weijun |
Fri, 15 Nov 2019 09:06:58 +0800 | |
changeset 59104 | 046e4024e55a |
parent 54521 | 8de62c4af8c7 |
permissions | -rw-r--r-- |
54521
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
1 |
/* |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
4 |
* |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
8 |
* |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
13 |
* accompanied this code). |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
14 |
* |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
18 |
* |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
21 |
* questions. |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
22 |
*/ |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
23 |
|
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
24 |
/* |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
25 |
* @test |
59104 | 26 |
* @bug 8029659 8214179 |
54521
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
27 |
* @summary Keytool, print key algorithm of certificate or key entry |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
28 |
* @library /test/lib |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
29 |
*/ |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
30 |
|
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
31 |
import jdk.test.lib.SecurityTools; |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
32 |
import jdk.test.lib.process.OutputAnalyzer; |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
33 |
|
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
34 |
public class KeyAlg { |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
35 |
public static void main(String[] args) throws Exception { |
59104 | 36 |
keytool("-genkeypair -alias ca -dname CN=CA -keyalg EC"); |
37 |
keytool("-genkeypair -alias user -dname CN=User -keyalg RSA -keysize 1024"); |
|
38 |
keytool("-certreq -alias user -file user.req"); |
|
54521
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
39 |
keytool("-gencert -alias ca -rfc -sigalg SHA1withECDSA" |
59104 | 40 |
+ " -infile user.req -outfile user.crt"); |
54521
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
41 |
keytool("-printcert -file user.crt") |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
42 |
.shouldMatch("Signature algorithm name:.*SHA1withECDSA") |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
43 |
.shouldMatch("Subject Public Key Algorithm:.*1024.*RSA"); |
59104 | 44 |
keytool("-genkeypair -alias e -dname CN=e -keyalg EC -groupname brainpoolP256r1") |
45 |
.shouldContain("Generating 256 bit EC (brainpoolP256r1) key pair"); |
|
46 |
keytool("-genkeypair -alias f -dname CN=f -keyalg EC") |
|
47 |
.shouldContain("Generating 256 bit EC (secp256r1) key pair"); |
|
48 |
keytool("-genkeypair -alias g -dname CN=g -keyalg EC -keysize 384") |
|
49 |
.shouldContain("Generating 384 bit EC (secp384r1) key pair"); |
|
54521
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
50 |
} |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
51 |
|
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
52 |
static OutputAnalyzer keytool(String s) throws Exception { |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
53 |
return SecurityTools.keytool( |
59104 | 54 |
"-keystore ks -storepass changeit -keypass changeit " + s) |
55 |
.shouldHaveExitValue(0); |
|
54521
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
56 |
} |
8de62c4af8c7
8180573: Refactor sun/security/tools shell tests to plain java tests
weijun
parents:
diff
changeset
|
57 |
} |