Package org.bouncycastle.openpgp
Class PGPObjectFactory
- java.lang.Object
-
- org.bouncycastle.openpgp.PGPObjectFactory
-
- All Implemented Interfaces:
Iterable
,org.bouncycastle.util.Iterable
- Direct Known Subclasses:
BcPGPObjectFactory
,JcaPGPObjectFactory
public class PGPObjectFactory extends Object implements org.bouncycastle.util.Iterable
General class for reading a PGP object stream.Note: if this class finds a
PGPPublicKey
or aPGPSecretKey
it will create aPGPPublicKeyRing
, or aPGPSecretKeyRing
for each key found. If all you are trying to do is read a key ring file use eitherPGPPublicKeyRingCollection
orPGPSecretKeyRingCollection
.This factory supports reading the following types of objects:
PacketTags.SIGNATURE
- produces aPGPSignatureList
PacketTags.SECRET_KEY
- produces aPGPSecretKeyRing
PacketTags.PUBLIC_KEY
- produces aPGPPublicKeyRing
PacketTags.PUBLIC_SUBKEY
- produces aPGPPublicKey
PacketTags.COMPRESSED_DATA
- produces aPGPCompressedData
PacketTags.LITERAL_DATA
- produces aPGPLiteralData
PacketTags.PUBLIC_KEY_ENC_SESSION
- produces aPGPEncryptedDataList
PacketTags.SYMMETRIC_KEY_ENC_SESSION
- produces aPGPEncryptedDataList
PacketTags.ONE_PASS_SIGNATURE
- produces aPGPOnePassSignatureList
PacketTags.MARKER
- produces aPGPMarker
-
-
Constructor Summary
Constructors Constructor Description PGPObjectFactory(byte[] bytes, KeyFingerPrintCalculator fingerPrintCalculator)
Create an object factory suitable for reading PGP objects such as keys, key rings and key ring collections, or PGP encrypted data.PGPObjectFactory(InputStream in, KeyFingerPrintCalculator fingerPrintCalculator)
Create an object factory suitable for reading PGP objects such as keys, key rings and key ring collections, or PGP encrypted data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterator
iterator()
Support method for Iterable where available.Object
nextObject()
Return the next object in the stream, ornull
if the end of stream is reached.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
PGPObjectFactory
public PGPObjectFactory(InputStream in, KeyFingerPrintCalculator fingerPrintCalculator)
Create an object factory suitable for reading PGP objects such as keys, key rings and key ring collections, or PGP encrypted data.- Parameters:
in
- stream to read PGP data from.fingerPrintCalculator
- calculator to use in key finger print calculations.
-
PGPObjectFactory
public PGPObjectFactory(byte[] bytes, KeyFingerPrintCalculator fingerPrintCalculator)
Create an object factory suitable for reading PGP objects such as keys, key rings and key ring collections, or PGP encrypted data.- Parameters:
bytes
- PGP encoded data.fingerPrintCalculator
- calculator to use in key finger print calculations.
-
-
Method Detail
-
nextObject
public Object nextObject() throws IOException
Return the next object in the stream, ornull
if the end of stream is reached.- Returns:
- one of the supported objects - see class docs for details.
- Throws:
IOException
- if an error occurs reading from the wrapped stream or parsing data.
-
-