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
General class for reading a PGP object stream.
Note: if this class finds a PGPPublicKey or a PGPSecretKey it will create a
PGPPublicKeyRing, or a PGPSecretKeyRing for each key found. If all you are trying
to do is read a key ring file use either PGPPublicKeyRingCollection or
PGPSecretKeyRingCollection.
This factory supports reading the following types of objects:
PacketTags.SIGNATURE- produces aPGPSignatureListPacketTags.SECRET_KEY- produces aPGPSecretKeyRingPacketTags.PUBLIC_KEY- produces aPGPPublicKeyRingPacketTags.PUBLIC_SUBKEY- produces aPGPPublicKeyPacketTags.COMPRESSED_DATA- produces aPGPCompressedDataPacketTags.LITERAL_DATA- produces aPGPLiteralDataPacketTags.PUBLIC_KEY_ENC_SESSION- produces aPGPEncryptedDataListPacketTags.SYMMETRIC_KEY_ENC_SESSION- produces aPGPEncryptedDataListPacketTags.ONE_PASS_SIGNATURE- produces aPGPOnePassSignatureListPacketTags.MARKER- produces aPGPMarker
-
Constructor Summary
ConstructorsConstructorDescriptionPGPObjectFactory(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
Modifier and TypeMethodDescriptioniterator()Support method for Iterable where available.Return the next object in the stream, ornullif the end of stream is reached.setThrowForUnknownCriticalPackets(boolean throwException) If set to true, the object factory will throw anIOExceptionif it encounters an unknown packet with a packet tag within the critical range (0 - 39).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
PGPObjectFactory
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
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 Details
-
nextObject
Return the next object in the stream, ornullif 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.
-
iterator
Support method for Iterable where available. -
setThrowForUnknownCriticalPackets
If set to true, the object factory will throw anIOExceptionif it encounters an unknown packet with a packet tag within the critical range (0 - 39).- Parameters:
throwException- whether to throw- Returns:
- object factory
-