1 /* 2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /** 25 * @test 26 * @bug 8225392 27 * @summary Comparison builds are failing due to cacerts file 28 * @library /lib/testlibrary 29 */ 30 31 import jdk.testlibrary.SecurityTools; 32 33 import java.util.Random; 34 35 public class ListOrder { 36 main(String[] args)37 public static void main(String[] args) throws Throwable { 38 39 Random rand = new Random(); 40 for (int i = 0; i < 10; i++) { 41 gen(String.format("a%02d", rand.nextInt(100))); 42 } 43 44 String last = ""; 45 for (String line : SecurityTools.keytool( 46 "-keystore ks -storepass changeit -list").asLines()) { 47 if (line.contains("PrivateKeyEntry")) { 48 // This is the line starting with the alias 49 System.out.println(line); 50 if (line.compareTo(last) <= 0) { 51 throw new RuntimeException("Not ordered"); 52 } else { 53 last = line; 54 } 55 } 56 } 57 } 58 gen(String a)59 static void gen(String a) throws Exception { 60 // Do not check result, there might be duplicated alias(es). 61 SecurityTools.keytool("-keystore ks -storepass changeit " 62 + "-keyalg ec -genkeypair -alias " + a + " -dname CN=" + a); 63 } 64 } 65