mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-14 09:53:18 +00:00
8367583: sun/security/util/AlgorithmConstraints/InvalidCryptoDisabledAlgos.java fails after JDK-8244336
Reviewed-by: weijun
This commit is contained in:
parent
e2eaa2ecf3
commit
ff538c7f56
@ -27,7 +27,6 @@
|
||||
* @modules java.base/sun.security.util
|
||||
* @summary Check that invalid property values for
|
||||
* "jdk.crypto.disabledAlgorithms" are rejected
|
||||
* @library /test/lib
|
||||
* @run main/othervm InvalidCryptoDisabledAlgos "*"
|
||||
* @run main/othervm InvalidCryptoDisabledAlgos "."
|
||||
* @run main/othervm InvalidCryptoDisabledAlgos ".AES"
|
||||
@ -38,10 +37,7 @@
|
||||
* @run main/othervm InvalidCryptoDisabledAlgos "KeyStore.MY,Cipher."
|
||||
* @run main/othervm InvalidCryptoDisabledAlgos "KeyStore.MY,A.B"
|
||||
*/
|
||||
import java.security.MessageDigest;
|
||||
import java.security.Security;
|
||||
import jdk.test.lib.Asserts;
|
||||
import jdk.test.lib.Utils;
|
||||
import sun.security.util.CryptoAlgorithmConstraints;
|
||||
|
||||
public class InvalidCryptoDisabledAlgos {
|
||||
@ -49,11 +45,19 @@ public class InvalidCryptoDisabledAlgos {
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Invalid Property Value = " + args[0]);
|
||||
Security.setProperty("jdk.crypto.disabledAlgorithms", args[0]);
|
||||
// Trigger the check to parse and validate property value
|
||||
Utils.runAndCheckException(() -> CryptoAlgorithmConstraints.permits(
|
||||
"x", "y"),
|
||||
t -> Asserts.assertTrue(
|
||||
t instanceof ExceptionInInitializerError &&
|
||||
t.getCause() instanceof IllegalArgumentException));
|
||||
try {
|
||||
// Trigger the check to parse and validate property value
|
||||
CryptoAlgorithmConstraints.permits("x", "y");
|
||||
throw new AssertionError(
|
||||
"CryptoAlgorithmConstraints.permits() did not generate expected exception");
|
||||
} catch (Throwable t) {
|
||||
if (!(t instanceof ExceptionInInitializerError)
|
||||
|| !(t.getCause() instanceof IllegalArgumentException)) {
|
||||
// unexpected exception, propagate it
|
||||
throw t;
|
||||
}
|
||||
// got expected
|
||||
System.out.println("Received expected exception: " + t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user