use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.
the class KSPrivateKeyEntryTest method createParams.
private void createParams(boolean diffCerts, boolean diffKeys) {
byte[] encoded = { (byte) 0, (byte) 1, (byte) 2, (byte) 3 };
testChain = new Certificate[5];
for (int i = 0; i < testChain.length; i++) {
String s = (diffCerts ? Integer.toString(i) : "NEW");
testChain[i] = new MyCertificate("MY_TEST_CERTIFICATE_".concat(s), encoded);
}
testPrivateKey = (diffKeys ? (PrivateKey) new tmpPrivateKey() : (PrivateKey) new tmpPrivateKey(testChain[0].getPublicKey().getAlgorithm()));
}
use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.
the class KSTrustedCertificateEntryTest method testTrustedCertificateEntry.
/**
* Test for <codfe>KeyStore.TrustedCertificateEntry(Certificate trustCert)</code>
* constructor
* Assertion: throws NullPointerException when trustCert is null
*/
public void testTrustedCertificateEntry() {
Certificate cert = null;
try {
new KeyStore.TrustedCertificateEntry(cert);
fail("NullPointerException must be thrown when trustCert is null");
} catch (NullPointerException e) {
}
cert = new MyCertificate("TEST", new byte[10]);
try {
KeyStore.TrustedCertificateEntry ksTCE = new KeyStore.TrustedCertificateEntry(cert);
assertNotNull(ksTCE);
assertTrue(ksTCE instanceof KeyStore.TrustedCertificateEntry);
} catch (Exception e) {
fail("Unexpected exception was thrown when trustCert is not null");
}
}
use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.
the class PKIXCertPathCheckerTest method testCheck.
public final void testCheck() throws CertPathValidatorException {
PKIXCertPathChecker pc = TestUtils.getTestCertPathChecker();
pc.check(new MyCertificate("", null), new HashSet<String>());
}
use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.
the class myCertificateFactory method testCertificateFactory16.
/**
* Test for <code>generateCertPath(List certificates)</code> method
* Assertion: throws CertificateException when certificates contains
* incorrect Certificate
*/
public void testCertificateFactory16() {
if (!X509Support) {
fail(NotSupportMsg);
return;
}
CertificateFactory[] certFs = initCertFs();
assertNotNull("CertificateFactory objects were not created", certFs);
MyCertificate ms = createMC();
List<Certificate> list = new Vector<Certificate>();
list.add(ms);
for (int i = 0; i < certFs.length; i++) {
try {
certFs[i].generateCertPath(list);
fail("CertificateException must be thrown");
} catch (CertificateException e) {
}
}
}
use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.
the class myCertificateFactory method testCertificateFactory11.
/*
* Test for <code> generateCertificate(InputStream inStream) </code><code>
* generateCertificates(InputStream inStream) </code><code>
* generateCRL(InputStream inStream) </code><code>
* generateCRLs(InputStream inStream) </code>
* methods
* Assertion: throw CertificateException and CRLException when inStream
* contains incompatible datas
*/
public void testCertificateFactory11() throws IOException {
if (!X509Support) {
fail(NotSupportMsg);
return;
}
CertificateFactory[] certFs = initCertFs();
assertNotNull("CertificateFactory objects were not created", certFs);
MyCertificate mc = createMC();
ByteArrayOutputStream os = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(mc);
oos.flush();
oos.close();
Certificate cer;
Collection<?> colCer;
CRL crl;
Collection<?> colCrl;
byte[] arr = os.toByteArray();
ByteArrayInputStream is;
for (int i = 0; i < certFs.length; i++) {
is = new ByteArrayInputStream(arr);
try {
cer = certFs[i].generateCertificate(is);
assertNull("Not null certificate was created", cer);
} catch (CertificateException e) {
}
is = new ByteArrayInputStream(arr);
try {
colCer = certFs[i].generateCertificates(is);
if (colCer != null) {
assertTrue("Not empty certificate Collection was created", colCer.isEmpty());
}
} catch (CertificateException e) {
}
is = new ByteArrayInputStream(arr);
try {
crl = certFs[i].generateCRL(is);
assertNull("Not null CRL was created", crl);
} catch (CRLException e) {
}
is = new ByteArrayInputStream(arr);
try {
colCrl = certFs[i].generateCRLs(is);
if (colCrl != null) {
assertTrue("Not empty CRL Collection was created", colCrl.isEmpty());
}
} catch (CRLException e) {
}
}
}
Aggregations