Package org.bouncycastle.openpgp.api
Class OpenPGPKeyMaterialPool<M extends OpenPGPCertificate>
java.lang.Object
org.bouncycastle.openpgp.api.OpenPGPKeyMaterialPool<M>
- Type Parameters:
M-OpenPGPCertificateorOpenPGPKey
- All Implemented Interfaces:
OpenPGPKeyMaterialProvider<M>
- Direct Known Subclasses:
OpenPGPKeyMaterialPool.OpenPGPCertificatePool,OpenPGPKeyMaterialPool.OpenPGPKeyPool
public abstract class OpenPGPKeyMaterialPool<M extends OpenPGPCertificate>
extends Object
implements OpenPGPKeyMaterialProvider<M>
Implementation of the
OpenPGPKeyMaterialProvider which caches items in a HashMap.
It allows to provide key or certificates dynamically via a callback that can be set using
setMissingItemCallback(OpenPGPKeyMaterialProvider).
Results from this callback are automatically cached for later access. This behavior can be adjusted via
setCacheResultsFromCallback(boolean).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classImplementation ofOpenPGPKeyMaterialPooltailored to providingOpenPGPCertificates.static classImplementation ofOpenPGPKeyMaterialPooltailored to provideOpenPGPKeys.Nested classes/interfaces inherited from interface org.bouncycastle.openpgp.api.OpenPGPKeyMaterialProvider
OpenPGPKeyMaterialProvider.OpenPGPCertificateProvider, OpenPGPKeyMaterialProvider.OpenPGPKeyProvider -
Constructor Summary
ConstructorsConstructorDescriptionCreate an empty pool.OpenPGPKeyMaterialPool(Collection<M> items) Create a pool and initialize its contents with the provided collection of items.OpenPGPKeyMaterialPool(M item) Create a pool from the single provided item. -
Method Summary
Modifier and TypeMethodDescriptionAdd a certificate to the pool.Return all items from the pool.provide(KeyIdentifier componentKeyIdentifier) Provide the requestedOpenPGPCertificateorOpenPGPKeycontaining the component key identified by the passed inKeyIdentifier.setCacheResultsFromCallback(boolean cacheResults) Decide, whether the implementation should addcertificatesreturned bycallbackto the pool of cached certificates.setMissingItemCallback(OpenPGPKeyMaterialProvider<M> callback) Set a callback that gets fired whenever an item is requested, which is not found in the pool.
-
Constructor Details
-
OpenPGPKeyMaterialPool
public OpenPGPKeyMaterialPool()Create an empty pool. -
OpenPGPKeyMaterialPool
Create a pool from the single provided item.- Parameters:
item- item
-
OpenPGPKeyMaterialPool
Create a pool and initialize its contents with the provided collection of items.- Parameters:
items- collection of keys or certificates
-
-
Method Details
-
setMissingItemCallback
Set a callback that gets fired whenever an item is requested, which is not found in the pool.- Parameters:
callback- callback- Returns:
- this
-
setCacheResultsFromCallback
Decide, whether the implementation should addcertificatesreturned bycallbackto the pool of cached certificates.- Parameters:
cacheResults- if true, cache certificates from callback- Returns:
- this
-
provide
Description copied from interface:OpenPGPKeyMaterialProviderProvide the requestedOpenPGPCertificateorOpenPGPKeycontaining the component key identified by the passed inKeyIdentifier.- Specified by:
providein interfaceOpenPGPKeyMaterialProvider<M extends OpenPGPCertificate>- Parameters:
componentKeyIdentifier- identifier of a component key (primary key or subkey)- Returns:
- the OpenPGP certificate or key containing the identified component key
-
addItem
Add a certificate to the pool. Note: If multiple items share the same subkey material, adding an item might overwrite the reference to another item for that subkey.- Parameters:
item- OpenPGP key or certificate that shall be added into the pool- Returns:
- this
-
getAllItems
Return all items from the pool.- Returns:
- all items
-