5757 * @modules java.base/sun.security.x509
5858 * java.base/sun.security.util
5959 * @library /test/lib
60- * @run main/othervm AlgorithmConstraintsCheck false SunX509 SHA256withRSA
61- * @run main/othervm AlgorithmConstraintsCheck true SunX509 SHA256withRSA
62- * @run main/othervm AlgorithmConstraintsCheck false PKIX SHA256withRSA
63- * @run main/othervm AlgorithmConstraintsCheck true PKIX SHA256withRSA
60+ * @run main/othervm AlgorithmConstraintsCheck false SunX509
61+ * @run main/othervm AlgorithmConstraintsCheck true SunX509
62+ * @run main/othervm AlgorithmConstraintsCheck false PKIX
63+ * @run main/othervm AlgorithmConstraintsCheck true PKIX
6464 */
6565
6666public class AlgorithmConstraintsCheck {
6767
68- private static final String CERT_ALIAS = "testalias" ;
69- private static final String KEY_TYPE = "RSA" ;
68+ protected static final String CERT_ALIAS = "testalias" ;
69+ protected static final String KEY_TYPE = "EC" ;
70+ protected static final String CERT_SIG_ALG = "SHA256withECDSA" ;
7071
7172 public static void main (String [] args ) throws Exception {
72- if (args .length != 3 ) {
73+ if (args .length != 2 ) {
7374 throw new RuntimeException ("Wrong number of arguments" );
7475 }
7576
7677 String enabled = args [0 ];
7778 String kmAlg = args [1 ];
78- String certSignatureAlg = args [2 ];
7979
8080 System .setProperty ("jdk.tls.SunX509KeyManager.certChecking" , enabled );
81- SecurityUtils .addToDisabledTlsAlgs (certSignatureAlg );
81+ SecurityUtils .addToDisabledTlsAlgs (CERT_SIG_ALG );
8282
8383 X509ExtendedKeyManager km = (X509ExtendedKeyManager ) getKeyManager (
84- kmAlg , certSignatureAlg );
84+ kmAlg , KEY_TYPE , CERT_SIG_ALG );
8585 String serverAlias = km .chooseServerAlias (KEY_TYPE , null , null );
8686 String engineServerAlias = km .chooseEngineServerAlias (
8787 KEY_TYPE , null , null );
@@ -108,13 +108,13 @@ public static void main(String[] args) throws Exception {
108108 }
109109
110110 // PKIX KeyManager adds a cache prefix to an alias.
111- private static String normalizeAlias (String alias ) {
111+ protected static String normalizeAlias (String alias ) {
112112 return alias .substring (alias .lastIndexOf ("." ) + 1 );
113113 }
114114
115- private static X509KeyManager getKeyManager (String kmAlg ,
116- String certSignatureAlg ) throws Exception {
117- KeyPairGenerator kpg = KeyPairGenerator .getInstance (KEY_TYPE );
115+ protected static X509KeyManager getKeyManager (String kmAlg ,
116+ String keyAlg , String certSignatureAlg ) throws Exception {
117+ KeyPairGenerator kpg = KeyPairGenerator .getInstance (keyAlg );
118118 KeyPair caKeys = kpg .generateKeyPair ();
119119 KeyPair endpointKeys = kpg .generateKeyPair ();
120120
0 commit comments