use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.
the class CertificateTest method testGetEncoded.
// the following tests just call methods
// that are abstract in <code>Certificate</code>
// (So they just like signature tests)
/**
* This test just calls <code>getEncoded()</code> method<br>
* @throws CertificateException
*/
public final void testGetEncoded() throws CertificateException {
Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
assertNotNull(c1.getEncoded());
assertTrue(Arrays.equals(testEncoding, c1.getEncoded()));
CertificateFactory cf = CertificateFactory.getInstance("X.509");
byte[] expectedEncoding = cert.getEncoded();
Certificate actual = cf.generateCertificate(new ByteArrayInputStream(expectedEncoding));
byte[] actualEncoding = actual.getEncoded();
assertTrue(Arrays.equals(expectedEncoding, actualEncoding));
assertFalse(expectedEncoding[4] == 200);
expectedEncoding[4] = (byte) 200;
try {
cf.generateCertificate(new ByteArrayInputStream(expectedEncoding));
fail();
} catch (CertificateException expected) {
}
}
use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.
the class CertificateTest method testVerifyPublicKey2.
/**
* This test just calls <code>verify(PublicKey)</code> method<br>
*
* @throws InvalidKeyException
* @throws CertificateException
* @throws NoSuchAlgorithmException
* @throws NoSuchProviderException
* @throws SignatureException
* @throws IOException
* @throws InvalidAlgorithmParameterException
*/
public final void testVerifyPublicKey2() throws InvalidKeyException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException, SignatureException, InvalidAlgorithmParameterException, IOException {
Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
c1.verify(null);
cert.verify(cert.getPublicKey());
PublicKey k = cert.getPublicKey();
MyModifiablePublicKey changedEncoding = new MyModifiablePublicKey(k);
changedEncoding.setEncoding(new byte[cert.getEncoded().length - 1]);
try {
cert.verify(c1.getPublicKey());
fail();
} catch (InvalidKeyException expected) {
}
try {
cert.verify(changedEncoding);
fail();
} catch (Exception expected) {
}
}
use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.
the class CertificateTest method testCertificate.
/**
* Test for <code>Certificate(String type)</code> method<br>
*/
public final void testCertificate() throws Exception {
Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
assertTrue(Arrays.equals(testEncoding, c1.getEncoded()));
assertEquals("TEST", c1.getPublicKey().getAlgorithm());
assertTrue(Arrays.equals(new byte[] { (byte) 1, (byte) 2, (byte) 3 }, c1.getPublicKey().getEncoded()));
assertEquals("TEST_FORMAT", c1.getPublicKey().getFormat());
assertEquals("TEST_TYPE", c1.getType());
}
use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.
the class CertificateTest method testGetType.
/**
* Test for <code>getType()</code> method<br>
* Assertion: returns this certificate type
*/
public final void testGetType() {
Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
assertEquals("TEST_TYPE", c1.getType());
}
use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.
the class CertificateTest method testGetPublicKey.
/**
* This test just calls <code>testGetPublicKey()</code> method<br>
*/
public final void testGetPublicKey() {
Certificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
c1.getPublicKey();
}
Aggregations