Search in sources :

Example 6 with MyCertificate

use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.

the class CollectionCertStoreParametersTest method testCollectionCertStoreParametersCollection03.

/**
     * Test #3 for <code>CollectionCertStoreParameters(Collection)</code>
     * constructor<br>
     */
public final void testCollectionCertStoreParametersCollection03() {
    Vector<Certificate> certificates = new Vector<Certificate>();
    // create using empty collection
    CollectionCertStoreParameters cp = new CollectionCertStoreParameters(certificates);
    // check that the reference is used
    assertTrue("isRefUsed_1", certificates == cp.getCollection());
    // check that collection still empty
    assertTrue("isEmpty", cp.getCollection().isEmpty());
    // modify our collection
    certificates.add(new MyCertificate("TEST", new byte[] { (byte) 1 }));
    certificates.add(new MyCertificate("TEST", new byte[] { (byte) 2 }));
    // check that internal state has been changed accordingly
    assertTrue("isRefUsed_2", certificates.equals(cp.getCollection()));
}
Also used : MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate) CollectionCertStoreParameters(java.security.cert.CollectionCertStoreParameters) Vector(java.util.Vector) Certificate(java.security.cert.Certificate) MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate)

Example 7 with MyCertificate

use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.

the class KSTrustedCertificateEntryTest method testToString.

/**
     * Test for <codfe>toString()</code> method
     * Assertion: returns non null string
     */
public void testToString() {
    Certificate cert = new MyCertificate("TEST", new byte[10]);
    KeyStore.TrustedCertificateEntry ksTCE = new KeyStore.TrustedCertificateEntry(cert);
    assertNotNull("toString() returns null string", ksTCE.toString());
}
Also used : MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate) KeyStore(java.security.KeyStore) Certificate(java.security.cert.Certificate) MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate)

Example 8 with MyCertificate

use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.

the class KSTrustedCertificateEntryTest method testGetTrustedCertificate.

/**
     * Test for <codfe>getTrustedCertificate()</code> method
     * Assertion: returns trusted Certificate from goven entry
     */
public void testGetTrustedCertificate() {
    Certificate cert = new MyCertificate("TEST", new byte[10]);
    KeyStore.TrustedCertificateEntry ksTCE = new KeyStore.TrustedCertificateEntry(cert);
    assertEquals("Incorrect certificate", cert, ksTCE.getTrustedCertificate());
}
Also used : MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate) KeyStore(java.security.KeyStore) Certificate(java.security.cert.Certificate) MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate)

Example 9 with MyCertificate

use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.

the class KSPrivateKeyEntryTest method testPrivateKeyEntry01.

/**
     * Test for <code>PrivateKeyEntry(PrivateKey privateKey, Certificate[] chain)</code>
     * constructor
     * Assertion: throws NullPointerException when privateKey is null
     */
public void testPrivateKeyEntry01() {
    //new Certificate[1];
    Certificate[] certs = new MyCertificate[1];
    PrivateKey pk = null;
    try {
        new KeyStore.PrivateKeyEntry(pk, certs);
        fail("NullPointerException must be thrown when privateKey is null");
    } catch (NullPointerException e) {
    }
}
Also used : MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate) PrivateKey(java.security.PrivateKey) Certificate(java.security.cert.Certificate) MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate)

Example 10 with MyCertificate

use of org.apache.harmony.security.tests.support.cert.MyCertificate in project robovm by robovm.

the class CollectionCertStoreParametersTest method testClone01.

/**
     * Test #1 for <code>clone()</code> method<br>
     */
public final void testClone01() {
    Vector<Certificate> certificates = new Vector<Certificate>();
    certificates.add(new MyCertificate("TEST", new byte[] { (byte) 4 }));
    CollectionCertStoreParameters cp1 = new CollectionCertStoreParameters(certificates);
    CollectionCertStoreParameters cp2 = (CollectionCertStoreParameters) cp1.clone();
    // check that that we have new object
    assertTrue(cp1 != cp2);
}
Also used : MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate) CollectionCertStoreParameters(java.security.cert.CollectionCertStoreParameters) Vector(java.util.Vector) Certificate(java.security.cert.Certificate) MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate)

Aggregations

MyCertificate (org.apache.harmony.security.tests.support.cert.MyCertificate)32 Certificate (java.security.cert.Certificate)26 MyFailingCertificate (org.apache.harmony.security.tests.support.cert.MyFailingCertificate)15 Vector (java.util.Vector)6 CollectionCertStoreParameters (java.security.cert.CollectionCertStoreParameters)5 ObjectStreamException (java.io.ObjectStreamException)4 CertificateException (java.security.cert.CertificateException)4 KeyStore (java.security.KeyStore)3 CertificateFactory (java.security.cert.CertificateFactory)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 MyCertificateRep (org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ObjectOutputStream (java.io.ObjectOutputStream)1 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1 InvalidKeyException (java.security.InvalidKeyException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 NoSuchProviderException (java.security.NoSuchProviderException)1 PrivateKey (java.security.PrivateKey)1