use of java.security.cert.CertPathValidatorException in project jdk8u_jdk by JetBrains.
the class PKIXExtendedTM method main.
public static void main(String[] args) throws Exception {
if (args.length != 1) {
throw new Exception("Incorrect number of arguments");
}
Test test = tests[Integer.parseInt(args[0])];
Security.setProperty("jdk.tls.disabledAlgorithms", test.tlsDisAlgs);
Security.setProperty("jdk.certpath.disabledAlgorithms", test.certPathDisAlgs);
if (debug) {
System.setProperty("javax.net.debug", "all");
}
/*
* Start the tests.
*/
try {
new PKIXExtendedTM();
if (test.fail) {
throw new Exception("Expected MD5 certificate to be blocked");
}
} catch (Exception e) {
if (test.fail) {
// find expected cause
boolean correctReason = false;
Throwable cause = e.getCause();
while (cause != null) {
if (cause instanceof CertPathValidatorException) {
CertPathValidatorException cpve = (CertPathValidatorException) cause;
if (cpve.getReason() == CertPathValidatorException.BasicReason.ALGORITHM_CONSTRAINED) {
correctReason = true;
break;
}
}
cause = cause.getCause();
}
if (!correctReason) {
throw new Exception("Unexpected exception", e);
}
} else {
throw e;
}
}
}
use of java.security.cert.CertPathValidatorException in project jdk8u_jdk by JetBrains.
the class CPValidatorEndEntity method main.
public static void main(String[] args) throws Exception {
// reset the security property to make sure that the algorithms
// and keys used in this test are not disabled.
Security.setProperty("jdk.certpath.disabledAlgorithms", "MD2");
try {
validate(endentiry_SHA1withRSA_1024_1024, intermediate_SHA1withRSA_1024_1024);
validate(endentiry_SHA1withRSA_1024_512, intermediate_SHA1withRSA_512_1024);
validate(endentiry_SHA1withRSA_512_1024, intermediate_SHA1withRSA_1024_1024);
validate(endentiry_SHA1withRSA_512_512, intermediate_SHA1withRSA_512_1024);
} catch (CertPathValidatorException cpve) {
throw new Exception("unexpect exception, it is valid cert", cpve);
}
try {
validate(endentiry_MD2withRSA_1024_1024, intermediate_SHA1withRSA_1024_1024);
throw new Exception("expected algorithm disabled exception");
} catch (CertPathValidatorException cpve) {
// we may get ClassCastException here
BasicReason reason = (BasicReason) cpve.getReason();
if (reason != BasicReason.ALGORITHM_CONSTRAINED) {
throw new Exception("Expect to get ALGORITHM_CONSTRAINED CPVE", cpve);
}
System.out.println("Get the expected exception " + cpve);
}
try {
validate(endentiry_MD2withRSA_1024_512, intermediate_SHA1withRSA_512_1024);
throw new Exception("expected algorithm disabled exception");
} catch (CertPathValidatorException cpve) {
// we may get ClassCastException here
BasicReason reason = (BasicReason) cpve.getReason();
if (reason != BasicReason.ALGORITHM_CONSTRAINED) {
throw new Exception("Expect to get ALGORITHM_CONSTRAINED CPVE", cpve);
}
System.out.println("Get the expected exception " + cpve);
}
}
Aggregations