Examples of PGPPublicKeyRingCollection


Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

        while ((ch = aIn.read()) >= 0 && aIn.isClearText())
        {
            bOut.write((byte)ch);
        }

        PGPPublicKeyRingCollection pgpRings = new PGPPublicKeyRingCollection(publicKey);

        PGPObjectFactory           pgpFact = new PGPObjectFactory(aIn);
        PGPSignatureList           p3 = (PGPSignatureList)pgpFact.nextObject();
        PGPSignature               sig = p3.get(0);
       
        sig.initVerify(pgpRings.getPublicKey(sig.getKeyID()), "BC");

        ByteArrayOutputStream lineOut = new ByteArrayOutputStream();
        InputStream           sigIn = new ByteArrayInputStream(bOut.toByteArray());
        int lookAhead = readInputLine(lineOut, sigIn);
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

            return new ArrayList<PGPPublicKeyRing>();
        }
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(ROO_PGP_FILE);
            final PGPPublicKeyRingCollection pubRings = new PGPPublicKeyRingCollection(
                    PGPUtil.getDecoderStream(fis));
            final Iterator<PGPPublicKeyRing> rIt = pubRings.getKeyRings();
            final List<PGPPublicKeyRing> result = new ArrayList<PGPPublicKeyRing>();
            while (rIt.hasNext()) {
                final PGPPublicKeyRing pgpPub = rIt.next();
                rememberKey(pgpPub);
                result.add(pgpPub);
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

        }

        // Write back to disk
        OutputStream fos = null;
        try {
            final PGPPublicKeyRingCollection newCollection = new PGPPublicKeyRingCollection(
                    stillTrusted);
            fos = new FileOutputStream(ROO_PGP_FILE);
            newCollection.encode(fos);
        }
        catch (final Exception e) {
            throw new IllegalStateException(e);
        }
        finally {
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

                "The public key ID '%s' is not currently trusted", keyId);

        // Write back to disk
        OutputStream fos = null;
        try {
            final PGPPublicKeyRingCollection newCollection = new PGPPublicKeyRingCollection(
                    stillTrusted);
            fos = new FileOutputStream(ROO_PGP_FILE);
            newCollection.encode(fos);
        }
        catch (final Exception e) {
            throw new IllegalStateException(e);
        }
        finally {
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

        // trust it and write back to disk
        trusted.add(keyRing);
        OutputStream fos = null;
        try {
            final PGPPublicKeyRingCollection newCollection = new PGPPublicKeyRingCollection(
                    trusted);
            fos = new FileOutputStream(ROO_PGP_FILE);
            newCollection.encode(fos);
        }
        catch (final Exception e) {
            throw new IllegalStateException(e);
        }
        finally {
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

    }

    @SuppressWarnings("unchecked")
    private static PGPPublicKey findPublicKey(InputStream input, String userid, boolean forEncryption) throws IOException, PGPException,
            NoSuchProviderException {
        PGPPublicKeyRingCollection pgpSec = new PGPPublicKeyRingCollection(PGPUtil.getDecoderStream(input));

        Iterator<PGPPublicKeyRing> keyRingIter = pgpSec.getKeyRings();
        while (keyRingIter.hasNext()) {
            PGPPublicKeyRing keyRing = keyRingIter.next();

            Iterator<PGPPublicKey> keyIter = keyRing.getPublicKeys();
            String keyUserId = null;
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

        InputStream    in)
        throws IOException, PGPException
    {
        in = PGPUtil.getDecoderStream(in);
       
        PGPPublicKeyRingCollection        pgpPub = new PGPPublicKeyRingCollection(in);

        //
        // 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.
        //
       
        //
        // iterate through the key rings.
        //
        Iterator rIt = pgpPub.getKeyRings();
       
        while (rIt.hasNext())
        {
            PGPPublicKeyRing    kRing = (PGPPublicKeyRing)rIt.next();   
            Iterator                        kIt = kRing.getPublicKeys();
View Full Code Here

Examples of org.bouncycastle.openpgp.PGPPublicKeyRingCollection

        InputStream    in)
        throws IOException, PGPException
    {
        in = PGPUtil.getDecoderStream(in);
       
        PGPPublicKeyRingCollection        pgpPub = new PGPPublicKeyRingCollection(in);

        //
        // 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.
        //
        PGPPublicKey    key = null;
       
        //
        // iterate through the key rings.
        //
        Iterator rIt = pgpPub.getKeyRings();
       
        while (key == null && rIt.hasNext())
        {
            PGPPublicKeyRing    kRing = (PGPPublicKeyRing)rIt.next();   
            Iterator            kIt = kRing.getPublicKeys();
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);

        sig.initVerify(pgpRings.getPublicKey(sig.getKeyID()), "BC");

        //
        // read the input, making sure we ingore 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 FileInputStream(fileName);
        int                                     ch;

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

        sig.initVerify(key, "BC");

        while ((ch = dIn.read()) >= 0)
        {
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.