X509Certificate finalCert = (X509Certificate)cf.generateCertificate(new ByteArrayInputStream(finalCertBin));
//Testing CertPath generation from List
List list = new ArrayList();
list.add(interCert);
CertPath certPath1 = cf.generateCertPath(list);
//Testing CertPath encoding as PkiPath
byte[] encoded = certPath1.getEncoded("PkiPath");
//Testing CertPath generation from InputStream
ByteArrayInputStream inStream = new ByteArrayInputStream(encoded);
CertPath certPath2 = cf.generateCertPath(inStream, "PkiPath");
//Comparing both CertPathes
if (! certPath2.equals(certPath1))
{
return new SimpleTestResult(false, this.getName() + ": CertPath differ after encoding and decoding.");
}
encoded = certPath1.getEncoded("PKCS7");
//Testing CertPath generation from InputStream
inStream = new ByteArrayInputStream(encoded);
certPath2 = cf.generateCertPath(inStream, "PKCS7");
//Comparing both CertPathes
if (! certPath2.equals(certPath1))
{
return new SimpleTestResult(false, this.getName() + ": CertPath differ after encoding and decoding.");
}
encoded = certPath1.getEncoded("PEM");
//Testing CertPath generation from InputStream
inStream = new ByteArrayInputStream(encoded);
certPath2 = cf.generateCertPath(inStream, "PEM");
//Comparing both CertPathes
if (!certPath2.equals(certPath1))
{
return new SimpleTestResult(false, this.getName() + ": CertPath differ after encoding and decoding.");
}
TestResult res = testExceptions();