Search in sources :

Example 26 with MyCertificate

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

the class CollectionCertStoreParametersTest method testClone02.

/**
     * Test #2 for <code>clone()</code> method<br>
     */
public final void testClone02() {
    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 both objects hold the same reference
    assertTrue(cp1.getCollection() == cp2.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 27 with MyCertificate

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

the class CertificateCertificateRepTest method testCertificateCertificateRep.

/**
     * Test for
     * <code>Certificate.CertificateRep(String type, byte[] data)</code>
     * method<br>
     */
public final void testCertificateCertificateRep() {
    MyCertificate c1 = new MyCertificate("TEST_TYPE", testEncoding);
    MyCertificateRep rep = c1.new MyCertificateRep("TEST_TYPE", new byte[] { (byte) 1, (byte) 2, (byte) 3 });
    assertTrue(Arrays.equals(new byte[] { (byte) 1, (byte) 2, (byte) 3 }, rep.getData()));
    assertEquals("TEST_TYPE", rep.getType());
    try {
        c1.new MyCertificateRep(null, null);
    } catch (Exception e) {
        fail("Unexpected exeption " + e.getMessage());
    }
    try {
        MyCertificate.MyCertificateRep rep1 = c1.new MyCertificateRep("X509", TestUtils.getX509Certificate_v3());
        assertEquals("X509", rep1.getType());
        assertTrue(Arrays.equals(TestUtils.getX509Certificate_v3(), rep1.getData()));
    } catch (Exception e) {
        fail("Unexpected exeption " + e.getMessage());
    }
}
Also used : MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate) MyCertificateRep(org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep) MyCertificateRep(org.apache.harmony.security.tests.support.cert.MyCertificate.MyCertificateRep) ObjectStreamException(java.io.ObjectStreamException)

Example 28 with MyCertificate

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

the class CollectionCertStoreParametersTest method testToString02.

/**
     * Test #2 for <code>toString()</code> method<br>
     */
public final void testToString02() {
    Vector<Certificate> certificates = new Vector<Certificate>();
    certificates.add(new MyCertificate("TEST", new byte[] { (byte) 4 }));
    CollectionCertStoreParameters cp = new CollectionCertStoreParameters(certificates);
    assertNotNull(cp.toString());
}
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 29 with MyCertificate

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

the class CollectionCertStoreParametersTest method testCollectionCertStoreParametersCollection01.

/**
     * Test #1 for <code>CollectionCertStoreParameters(Collection)</code>
     * constructor<br>
     */
public final void testCollectionCertStoreParametersCollection01() {
    Vector<Certificate> certificates = new Vector<Certificate>();
    certificates.add(new MyCertificate("TEST", new byte[] {}));
    new CollectionCertStoreParameters(certificates);
}
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 30 with MyCertificate

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()));
}
Also used : 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