Package org.bouncycastle.x509

Examples of org.bouncycastle.x509.X509CertificatePair


        X509Certificate finalCert = (X509Certificate)cf
                .generateCertificate(new ByteArrayInputStream(
                        CertPathTest.finalCertBin));

        // Testing CollectionCertStore generation from List
        X509CertificatePair pair1 = new X509CertificatePair(rootCert, interCert);
        List certList = new ArrayList();

        certList.add(pair1);
        certList.add(new X509CertificatePair(interCert, finalCert));

        X509CollectionStoreParameters ccsp = new X509CollectionStoreParameters(certList);

        X509Store certStore = X509Store.getInstance("CertificatePair/Collection", ccsp, "BC");
        X509CertPairStoreSelector selector = new X509CertPairStoreSelector();
View Full Code Here


        //
        // cross certificate pairs
        //
        parser = X509StreamParser.getInstance("CertificatePair", "BC");

        parser.init(new X509CertificatePair(rootCert, rootCert).getEncoded());

        res = parser.readAll();

        if (res.size() != 1)
        {
View Full Code Here

                                         new ByteArrayInputStream(CertPathTest.interCertBin));
        X509Certificate finalCert = (X509Certificate)cf.generateCertificate(
                                          new ByteArrayInputStream(CertPathTest.finalCertBin));


        X509CertificatePair pair1 = new X509CertificatePair(rootCert, interCert);
        X509CertificatePair pair2 = new X509CertificatePair(rootCert, interCert);
        X509CertificatePair pair3 = new X509CertificatePair(interCert, finalCert);
        X509CertificatePair pair4 = new X509CertificatePair(rootCert, finalCert);
        X509CertificatePair pair5 = new X509CertificatePair(rootCert, null);
        X509CertificatePair pair6 = new X509CertificatePair(rootCert, null);
        X509CertificatePair pair7 = new X509CertificatePair(null, rootCert);
        X509CertificatePair pair8 = new X509CertificatePair(null, rootCert);

        if (!pair1.equals(pair2))
        {
            fail("pair1 pair2 equality test");
        }

        if (!pair5.equals(pair6))
        {
            fail("pair1 pair2 equality test");
        }

        if (!pair7.equals(pair8))
        {
            fail("pair1 pair2 equality test");
        }

        if (pair1.equals(null))
        {
            fail("pair1 null equality test");
        }

        if (pair1.hashCode() != pair2.hashCode())
        {
            fail("pair1 pair2 hashCode equality test");
        }

        if (pair1.equals(pair3))
        {
            fail("pair1 pair3 inequality test");
        }

        if (pair1.equals(pair4))
        {
            fail("pair1 pair4 inequality test");
        }

        if (pair1.equals(pair5))
        {
            fail("pair1 pair5 inequality test");
        }

        if (pair1.equals(pair7))
        {
            fail("pair1 pair7 inequality test");
        }

        if (pair5.equals(pair1))
        {
            fail("pair5 pair1 inequality test");
        }

        if (pair7.equals(pair1))
        {
            fail("pair7 pair1 inequality test");
        }

        if (pair1.getForward() != rootCert)
        {
            fail("pair1 forward test");
        }

        if (pair1.getReverse() != interCert)
        {
            fail("pair1 reverse test");
        }

        if (!areEqual(pair1.getEncoded(), pair2.getEncoded()))
        {
            fail("encoding check");
        }

        pair4 = new X509CertificatePair(rootCert, TestUtils.createExceptionCertificate(false));

        try
        {
            pair4.getEncoded();

            fail("no exception on bad getEncoded()");
        }
        catch (CertificateEncodingException e)
        {
            // expected
        }

        pair4 = new X509CertificatePair(rootCert, TestUtils.createExceptionCertificate(true));

        try
        {
            pair4.getEncoded();
View Full Code Here

        Set certPairSet = new HashSet();

        int i = 0;
        while (i < list.size())
        {
            X509CertificatePair pair;
            try
            {
                // first try to decode it as certificate pair
                try
                {
                    X509CertPairParser parser = new X509CertPairParser();
                    parser.engineInit(new ByteArrayInputStream(
                        (byte[])list.get(i)));
                    pair = (X509CertificatePair)parser.engineRead();
                }
                catch (StreamParsingException e)
                {
                    // now try it to construct it the forward and reverse
                    // certificate
                    byte[] forward = (byte[])list.get(i);
                    byte[] reverse = (byte[])list.get(i + 1);
                    pair = new X509CertificatePair(new CertificatePair(
                        X509CertificateStructure
                            .getInstance(new ASN1InputStream(
                            forward).readObject()),
                        X509CertificateStructure
                            .getInstance(new ASN1InputStream(
View Full Code Here

        throws IOException, CertificateParsingException
    {
        ASN1InputStream dIn = new ASN1InputStream(in, ProviderUtil.getReadLimit(in));
        ASN1Sequence seq = (ASN1Sequence)dIn.readObject();
        CertificatePair pair = CertificatePair.getInstance(seq);
        return new X509CertificatePair(pair);
    }
View Full Code Here

        }
    }

    public Collection engineReadAll() throws StreamParsingException
    {
        X509CertificatePair pair;
        List certs = new ArrayList();

        while ((pair = (X509CertificatePair)engineRead()) != null)
        {
            certs.add(pair);
View Full Code Here

        Set certPairSet = new HashSet();

        int i = 0;
        while (i < list.size())
        {
            X509CertificatePair pair;
            try
            {
                // first try to decode it as certificate pair
                try
                {
                    X509CertPairParser parser = new X509CertPairParser();
                    parser.engineInit(new ByteArrayInputStream(
                        (byte[])list.get(i)));
                    pair = (X509CertificatePair)parser.engineRead();
                }
                catch (StreamParsingException e)
                {
                    // now try it to construct it the forward and reverse
                    // certificate
                    byte[] forward = (byte[])list.get(i);
                    byte[] reverse = (byte[])list.get(i + 1);
                    pair = new X509CertificatePair(new CertificatePair(
                        X509CertificateStructure
                            .getInstance(new ASN1InputStream(
                            forward).readObject()),
                        X509CertificateStructure
                            .getInstance(new ASN1InputStream(
View Full Code Here

        {
            Object obj = iter.next();

            if (obj instanceof X509Store)
            {
                X509Store certStore = (X509Store)obj;
                try
                {
                    certs.addAll(certStore.getMatches(certSelect));
                }
                catch (StoreException e)
                {
                    throw new AnnotatedException(
                            "Problem while picking certificates from X.509 store.", e);
                }
            }
            else
            {
                CertStore certStore = (CertStore)obj;

                try
                {
                    certs.addAll(certStore.getCertificates(certSelect));
                }
                catch (CertStoreException e)
                {
                    throw new AnnotatedException(
                        "Problem while picking certificates from certificate store.",
View Full Code Here

        {
            Object obj = iter.next();

            if (obj instanceof X509Store)
            {
                X509Store certStore = (X509Store)obj;
                try
                {
                    certs.addAll(certStore.getMatches(certSelect));
                }
                catch (StoreException e)
                {
                    throw new AnnotatedException(
                            "Problem while picking certificates from X.509 store.", e);
View Full Code Here

        {
            Object obj = iter.next();

            if (obj instanceof X509Store)
            {
                X509Store store = (X509Store)obj;

                try
                {
                    crls.addAll(store.getMatches(crlSelect));
                    foundValidStore = true;
                }
                catch (StoreException e)
                {
                    lastException = new AnnotatedException(
                        "Exception searching in X.509 CRL store.", e);
                }
            }
            else
            {
                CertStore store = (CertStore)obj;

                try
                {
                    crls.addAll(store.getCRLs(crlSelect));
                    foundValidStore = true;
                }
                catch (CertStoreException e)
                {
                    lastException = new AnnotatedException(
View Full Code Here

TOP

Related Classes of org.bouncycastle.x509.X509CertificatePair

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.