Search in sources :

Example 1 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)

Example 2 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 3 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 4 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 5 with MyCertificate

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

the class KeyStore4Test method testGetCertificateAlias.

public void testGetCertificateAlias() {
    try {
        String alias = keyStore.getCertificateAlias(TestKeyStoreSpi.CERT);
        assertNotNull("alias is null", alias);
        assertEquals("alias is not expected", "certalias", alias);
    } catch (KeyStoreException e) {
        fail("unexpected exception: " + e);
    }
    try {
        uninitialized.getCertificateAlias(TestKeyStoreSpi.CERT);
        fail("expected KeyStoreException");
    } catch (KeyStoreException e) {
    // ok
    }
    try {
        keyStore.getCertificateAlias(null);
        fail("expected NullPointerException");
    } catch (KeyStoreException e) {
        fail("unexpected exception: " + e);
    } catch (NullPointerException e) {
    // ok
    }
    try {
        String certificateAlias = keyStore.getCertificateAlias(new MyCertificate("dummy", null));
        assertNull("alias was not null", certificateAlias);
    } catch (KeyStoreException e) {
        fail("unexpected exception: " + e);
    }
}
Also used : MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate) KeyStoreException(java.security.KeyStoreException)

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