Examples of PGPPublicKeyRingCollection


Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

    }
   
    public void test3()
        throws Exception
    {
        PGPPublicKeyRingCollection    pubRings = new PGPPublicKeyRingCollection(pub3);

        int                                        count = 0;

        byte[]    encRing = pubRings.getEncoded();

        pubRings = new PGPPublicKeyRingCollection(encRing);
       
        Iterator    rIt = pubRings.getKeyRings();
       
        while (rIt.hasNext())
        {
            PGPPublicKeyRing                    pgpPub = (PGPPublicKeyRing)rIt.next();
           
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

    }

    public void test5()
        throws Exception
    {
        PGPPublicKeyRingCollection    pubRings = new PGPPublicKeyRingCollection(pub5);

        int                           count = 0;

        byte[]    encRing = pubRings.getEncoded();

        pubRings = new PGPPublicKeyRingCollection(encRing);
       
        Iterator    rIt = pubRings.getKeyRings();
       
        while (rIt.hasNext())
        {
            PGPPublicKeyRing                    pgpPub = (PGPPublicKeyRing)rIt.next();
           
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

    }

    public void test6()
        throws Exception
    {
        PGPPublicKeyRingCollection  pubRings = new PGPPublicKeyRingCollection(pub6);
        Iterator                    rIt = pubRings.getKeyRings();

        while (rIt.hasNext())
        {
            PGPPublicKeyRing    pgpPub = (PGPPublicKeyRing)rIt.next();
            Iterator            it = pgpPub.getPublicKeys();
            while (it.hasNext())
            {
                PGPPublicKey    k = (PGPPublicKey)it.next();

                if (k.getKeyID() == 0x5ce086b5b5a18ff4L)
                {
                    int             count = 0;
                    Iterator        sIt = k.getSignaturesOfType(PGPSignature.SUBKEY_REVOCATION);
                    while (sIt.hasNext())
                    {
                        PGPSignature sig = (PGPSignature)sIt.next();
                        count++;
                    }
                   
                    if (count != 1)
                    {
                        fail("wrong number of revocations in test6.");
                    }
                }
            }
        }
       
        byte[]    encRing = pubRings.getEncoded();
    }
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

    }

    public void test8()
        throws Exception
    {
        PGPPublicKeyRingCollection    pubRings = new PGPPublicKeyRingCollection(pub8);

        int                           count = 0;

        byte[]    encRing = pubRings.getEncoded();

        pubRings = new PGPPublicKeyRingCollection(encRing);
       
        Iterator    rIt = pubRings.getKeyRings();
       
        while (rIt.hasNext())
        {
            PGPPublicKeyRing          pgpPub = (PGPPublicKeyRing)rIt.next();
           
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

            }
        }

        out.close();

        PGPPublicKeyRingCollection pgpRings = new PGPPublicKeyRingCollection(keyIn);

        PGPObjectFactory           pgpFact = new PGPObjectFactory(aIn);
        PGPSignatureList           p3 = (PGPSignatureList)pgpFact.nextObject();
        PGPSignature               sig = p3.get(0);

        PGPPublicKey publicKey = pgpRings.getPublicKey(sig.getKeyID());
        sig.init(new JcaPGPContentVerifierBuilderProvider().setProvider("BC"), publicKey);

        //
        // read the input, making sure we ignore the last newline.
        //
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

        else
        {
            p3 = (PGPSignatureList)o;
        }
           
        PGPPublicKeyRingCollection  pgpPubRingCollection = new PGPPublicKeyRingCollection(PGPUtil.getDecoderStream(keyIn));


        InputStream                 dIn = new BufferedInputStream(new FileInputStream(fileName));

        PGPSignature                sig = p3.get(0);
        PGPPublicKey                key = pgpPubRingCollection.getPublicKey(sig.getKeyID());

        sig.init(new JcaPGPContentVerifierBuilderProvider().setProvider("BC"), key);

        int ch;
        while ((ch = dIn.read()) >= 0)
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

           
        PGPLiteralData              p2 = (PGPLiteralData)pgpFact.nextObject();

        InputStream                 dIn = p2.getInputStream();
        int                         ch;
        PGPPublicKeyRingCollection  pgpRing = new PGPPublicKeyRingCollection(PGPUtil.getDecoderStream(keyIn));

        PGPPublicKey                key = pgpRing.getPublicKey(ops.getKeyID());
        FileOutputStream            out = new FileOutputStream(p2.getFileName());

        ops.init(new JcaPGPContentVerifierBuilderProvider().setProvider("BC"), key);
           
        while ((ch = dIn.read()) >= 0)
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

        "POOoD7oxdRmJSU5hSspOCHrCwCa3");

    public void test1()
        throws Exception
    {
        PGPPublicKeyRingCollection    pubRings = new PGPPublicKeyRingCollection(pub1);

        int                                        count = 0;

        Iterator    rIt = pubRings.getKeyRings();
       
        while (rIt.hasNext())
        {
            PGPPublicKeyRing                    pgpPub = (PGPPublicKeyRing)rIt.next();

            count++;
           
            int    keyCount = 0;
           
            byte[]    bytes = pgpPub.getEncoded();
           
            pgpPub = new PGPPublicKeyRing(bytes);
           
            Iterator    it = pgpPub.getPublicKeys();
            while (it.hasNext())
            {
                keyCount++;

                PGPPublicKey    pubKey = (PGPPublicKey)it.next();
               
                Iterator   sIt = pubKey.getSignatures();
                while (sIt.hasNext())
                {
                    ((PGPSignature)sIt.next()).getSignatureType();
                }
            }
           
            if (keyCount != 2)
            {
                fail("wrong number of public keys");
            }
        }
       
        if (count != 1)
        {
            fail("wrong number of public keyrings");
        }
       
        //
        // exact match
        //
        rIt = pubRings.getKeyRings("test (Test key) <test@ubicall.com>");
        count = 0;
        while (rIt.hasNext())
        {
            count++;
            rIt.next();
        }
       
        if (count != 1)
        {
            fail("wrong number of public keyrings on exact match");
        }
       
        //
        // partial match 1 expected
        //
        rIt = pubRings.getKeyRings("test", true);
        count = 0;
        while (rIt.hasNext())
        {
            count++;
            rIt.next();
        }
       
        if (count != 1)
        {
            fail("wrong number of public keyrings on partial match 1");
        }
       
        //
        // partial match 0 expected
        //
        rIt = pubRings.getKeyRings("XXX", true);
        count = 0;
        while (rIt.hasNext())
        {
            count++;
            rIt.next();
        }
       
        if (count != 0)
        {
            fail("wrong number of public keyrings on partial match 0");
        }

        //
        // case-insensitive partial match
        //
        rIt = pubRings.getKeyRings("TEST@ubicall.com", true, true);
        count = 0;
        while (rIt.hasNext())
        {
            count++;
            rIt.next();
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

    }
   
    public void test2()
        throws Exception
    {
        PGPPublicKeyRingCollection    pubRings = new PGPPublicKeyRingCollection(pub2);

        int                            count = 0;

        byte[]    encRing = pubRings.getEncoded();

        pubRings = new PGPPublicKeyRingCollection(encRing);
       
        Iterator    rIt = pubRings.getKeyRings();
       
        while (rIt.hasNext())
        {
            PGPPublicKeyRing        pgpPub = (PGPPublicKeyRing)rIt.next();
           
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

     * @throws IOException
     * @throws PGPException
     */
    static PGPPublicKey readPublicKey(InputStream input) throws IOException, PGPException
    {
        PGPPublicKeyRingCollection pgpPub = new PGPPublicKeyRingCollection(
            PGPUtil.getDecoderStream(input));

        //
        // we just loop through the collection till we find a key suitable for encryption, in the real
        // world you would probably want to be a bit smarter about this.
        //

        Iterator keyRingIter = pgpPub.getKeyRings();
        while (keyRingIter.hasNext())
        {
            PGPPublicKeyRing keyRing = (PGPPublicKeyRing)keyRingIter.next();

            Iterator keyIter = keyRing.getPublicKeys();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.