Package org.bouncycastle.openpgp

Examples of org.bouncycastle.openpgp.PGPObjectFactory.nextObject()


    @Override
    public void initialize(OutputStream out) throws Exception
    {
        InputStream decodedInputStream = PGPUtil.getDecoderStream(this.toBeDecrypted);
        PGPObjectFactory pgpF = new PGPObjectFactory(decodedInputStream);
        Object pgpObject = pgpF.nextObject();

        if (pgpObject == null)
        {
            throw new IllegalArgumentException("Invalid PGP message");
        }
View Full Code Here


            enc = (PGPEncryptedDataList) pgpObject;

        }
        else
        {
            enc = (PGPEncryptedDataList) pgpF.nextObject();
        }

        // This loop looks like it is ready for multiple encrypted
        // objects, but really only one is expected.
        Iterator<?> it = enc.getEncryptedDataObjects();
View Full Code Here

        }

        clearStream = pbe.getDataStream(privateKey, provider);
        PGPObjectFactory pgpObjectFactory = new PGPObjectFactory(clearStream);

        pgpObject = pgpObjectFactory.nextObject();

        while (!(pgpObject instanceof PGPLiteralData))
        {
            if (pgpObject instanceof PGPOnePassSignatureList)
            {
View Full Code Here

                PGPOnePassSignatureList list = (PGPOnePassSignatureList) pgpObject;
                signature = list.get(0);
                signature.initVerify(this.publicKey, provider);
                // TODO verify signature
                // signature.verify(null);
                pgpObject = pgpObjectFactory.nextObject();
            }
            else if (pgpObject instanceof PGPCompressedData)
            {
                PGPCompressedData cData = (PGPCompressedData) pgpObject;
                compressedStream = new BufferedInputStream(cData.getDataStream());
View Full Code Here

            else if (pgpObject instanceof PGPCompressedData)
            {
                PGPCompressedData cData = (PGPCompressedData) pgpObject;
                compressedStream = new BufferedInputStream(cData.getDataStream());
                pgpObjectFactory = new PGPObjectFactory(compressedStream);
                pgpObject = pgpObjectFactory.nextObject();
            }
            else
            {
                throw new PGPException("input is not PGPLiteralData - type unknown.");
            }
View Full Code Here

      in = PGPUtil.getDecoderStream(stream);

      final PGPObjectFactory pgpF = new JcaPGPObjectFactory(in);
      PGPEncryptedDataList enc;
      final Object o = pgpF.nextObject();

      // the first object might be a PGP marker packet.
      if (o instanceof PGPEncryptedDataList) {
        enc = (PGPEncryptedDataList) o;
      } else {
View Full Code Here

      // the first object might be a PGP marker packet.
      if (o instanceof PGPEncryptedDataList) {
        enc = (PGPEncryptedDataList) o;
      } else {
        enc = (PGPEncryptedDataList) pgpF.nextObject();
      }

      final PGPPBEEncryptedData pbe = (PGPPBEEncryptedData) enc.get(0);

      final InputStream clear = pbe.getDataStream(new JcePBEDataDecryptorFactoryBuilder(new JcaPGPDigestCalculatorProviderBuilder().setProvider("BC").build()).setProvider("BC").build(
View Full Code Here

      final InputStream clear = pbe.getDataStream(new JcePBEDataDecryptorFactoryBuilder(new JcaPGPDigestCalculatorProviderBuilder().setProvider("BC").build()).setProvider("BC").build(
          passphrase.toCharArray()));

      PGPObjectFactory pgpFact = new JcaPGPObjectFactory(clear);

      final PGPCompressedData cData = (PGPCompressedData) pgpFact.nextObject();

      pgpFact = new JcaPGPObjectFactory(cData.getDataStream());
     
      final PGPLiteralData ld = (PGPLiteralData) pgpFact.nextObject();
View Full Code Here

      final PGPCompressedData cData = (PGPCompressedData) pgpFact.nextObject();

      pgpFact = new JcaPGPObjectFactory(cData.getDataStream());
     
      final PGPLiteralData ld = (PGPLiteralData) pgpFact.nextObject();

      return Streams.readAll(ld.getInputStream());
    } catch (Exception e) {
      throw new CloudsyncException("can't encrypt data", e);
    } finally {
View Full Code Here

        ArmoredInputStream aIn = new ArmoredInputStream(new ByteArrayInputStream(bOut.toByteArray()));

        PGPObjectFactory fact = new PGPObjectFactory(aIn);
        int count = 0;

        while (fact.nextObject() != null)
        {
            count++;
        }

        if (count != 1)
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.