Class AbstractOpenPgpKeyStore
- java.lang.Object
-
- org.jivesoftware.smackx.ox.store.abstr.AbstractOpenPgpKeyStore
-
- All Implemented Interfaces:
OpenPgpKeyStore
- Direct Known Subclasses:
FileBasedOpenPgpKeyStore
public abstract class AbstractOpenPgpKeyStore extends Object implements OpenPgpKeyStore
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<BareJid,Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date>>
keyFetchDates
protected static Logger
LOGGER
protected Map<BareJid,org.bouncycastle.openpgp.PGPPublicKeyRingCollection>
publicKeyRingCollections
protected Map<BareJid,org.bouncycastle.openpgp.PGPSecretKeyRingCollection>
secretKeyRingCollections
-
Constructor Summary
Constructors Constructor Description AbstractOpenPgpKeyStore()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
deletePublicKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)
Remove aPGPPublicKeyRing
which contains the key described byfingerprint
from thePGPPublicKeyRingCollection
ofowner
.void
deleteSecretKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)
Remove aPGPSecretKeyRing
which contains the key described byfingerprint
from thePGPSecretKeyRingCollection
ofowner
.org.pgpainless.key.collection.PGPKeyRing
generateKeyRing(BareJid owner)
Generate a newPGPKeyRing
forowner
.Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date>
getPublicKeyFetchDates(BareJid contact)
Return the last date on which keys ofcontact
were fetched from PubSub.org.bouncycastle.openpgp.PGPPublicKeyRing
getPublicKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)
Return thePGPPublicKeyRing
ofowner
which contains the key described byfingerprint
.org.bouncycastle.openpgp.PGPPublicKeyRingCollection
getPublicKeysOf(BareJid owner)
Return thePGPPublicKeyRingCollection
containing all public keys ofowner
that are locally available.org.bouncycastle.openpgp.PGPSecretKeyRing
getSecretKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)
Return thePGPSecretKeyRing
ofowner
which contains the key described byfingerprint
.org.bouncycastle.openpgp.PGPSecretKeyRingCollection
getSecretKeysOf(BareJid owner)
Return thePGPSecretKeyRingCollection
containing all secret keys ofowner
which are locally available.void
importPublicKey(BareJid owner, org.bouncycastle.openpgp.PGPPublicKeyRing publicKeys)
Import aPGPPublicKeyRing
ofowner
.void
importSecretKey(BareJid owner, org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)
Import aPGPSecretKeyRing
ofowner
.protected abstract Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date>
readKeyFetchDates(BareJid owner)
Read the key fetch dates for a users keys from local storage.protected abstract org.bouncycastle.openpgp.PGPPublicKeyRingCollection
readPublicKeysOf(BareJid owner)
Read aPGPPublicKeyRingCollection
from local storage.protected abstract org.bouncycastle.openpgp.PGPSecretKeyRingCollection
readSecretKeysOf(BareJid owner)
Read aPGPSecretKeyRingCollection
from local storage.void
setPublicKeyFetchDates(BareJid contact, Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> dates)
Set the last date on which keys ofcontact
were fetched from PubSub.protected abstract void
writeKeyFetchDates(BareJid owner, Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> dates)
Write the key fetch dates for a users keys to local storage.protected abstract void
writePublicKeysOf(BareJid owner, org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeys)
Write thePGPPublicKeyRingCollection
of a user to local storage.protected abstract void
writeSecretKeysOf(BareJid owner, org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeys)
Write thePGPSecretKeyRingCollection
of a user to local storage.
-
-
-
Field Detail
-
publicKeyRingCollections
protected Map<BareJid,org.bouncycastle.openpgp.PGPPublicKeyRingCollection> publicKeyRingCollections
-
secretKeyRingCollections
protected Map<BareJid,org.bouncycastle.openpgp.PGPSecretKeyRingCollection> secretKeyRingCollections
-
keyFetchDates
protected Map<BareJid,Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date>> keyFetchDates
-
-
Constructor Detail
-
AbstractOpenPgpKeyStore
public AbstractOpenPgpKeyStore()
-
-
Method Detail
-
readPublicKeysOf
protected abstract org.bouncycastle.openpgp.PGPPublicKeyRingCollection readPublicKeysOf(BareJid owner) throws IOException, org.bouncycastle.openpgp.PGPException
Read aPGPPublicKeyRingCollection
from local storage. This method returns null, if no keys were found.- Parameters:
owner
- owner of the keys- Returns:
- public keys
- Throws:
IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittle
-
writePublicKeysOf
protected abstract void writePublicKeysOf(BareJid owner, org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeys) throws IOException
Write thePGPPublicKeyRingCollection
of a user to local storage.- Parameters:
owner
- owner of the keyspublicKeys
- keys- Throws:
IOException
- IO is dangerous
-
readSecretKeysOf
protected abstract org.bouncycastle.openpgp.PGPSecretKeyRingCollection readSecretKeysOf(BareJid owner) throws IOException, org.bouncycastle.openpgp.PGPException
Read aPGPSecretKeyRingCollection
from local storage. This method returns null, if no keys were found.- Parameters:
owner
- owner of the keys- Returns:
- secret keys
- Throws:
IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittle
-
writeSecretKeysOf
protected abstract void writeSecretKeysOf(BareJid owner, org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeys) throws IOException
Write thePGPSecretKeyRingCollection
of a user to local storage.- Parameters:
owner
- owner of the keyssecretKeys
- secret keys- Throws:
IOException
- IO is dangerous
-
readKeyFetchDates
protected abstract Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> readKeyFetchDates(BareJid owner) throws IOException
Read the key fetch dates for a users keys from local storage.- Parameters:
owner
- owner- Returns:
- fetch dates for the owners keys
- Throws:
IOException
- IO is dangerous
-
writeKeyFetchDates
protected abstract void writeKeyFetchDates(BareJid owner, Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> dates) throws IOException
Write the key fetch dates for a users keys to local storage.- Parameters:
owner
- ownerdates
- fetch dates for the owners keys- Throws:
IOException
- IO is dangerous
-
getPublicKeyFetchDates
public Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> getPublicKeyFetchDates(BareJid contact) throws IOException
Description copied from interface:OpenPgpKeyStore
Return the last date on which keys ofcontact
were fetched from PubSub. This method MUST NOT return null.- Specified by:
getPublicKeyFetchDates
in interfaceOpenPgpKeyStore
- Parameters:
contact
- contact in which we are interested.- Returns:
- dates of last key fetching.
- Throws:
IOException
- IO is dangerous
-
setPublicKeyFetchDates
public void setPublicKeyFetchDates(BareJid contact, Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> dates) throws IOException
Description copied from interface:OpenPgpKeyStore
Set the last date on which keys ofcontact
were fetched from PubSub.- Specified by:
setPublicKeyFetchDates
in interfaceOpenPgpKeyStore
- Parameters:
contact
- contact in which we are interested.dates
- dates of last key fetching.- Throws:
IOException
- IO is dangerous
-
getPublicKeysOf
public org.bouncycastle.openpgp.PGPPublicKeyRingCollection getPublicKeysOf(BareJid owner) throws IOException, org.bouncycastle.openpgp.PGPException
Description copied from interface:OpenPgpKeyStore
Return thePGPPublicKeyRingCollection
containing all public keys ofowner
that are locally available. This method might return null.- Specified by:
getPublicKeysOf
in interfaceOpenPgpKeyStore
- Parameters:
owner
-BareJid
of the user we want to get keys from.- Returns:
PGPPublicKeyRingCollection
of the user.- Throws:
IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittle
-
getSecretKeysOf
public org.bouncycastle.openpgp.PGPSecretKeyRingCollection getSecretKeysOf(BareJid owner) throws IOException, org.bouncycastle.openpgp.PGPException
Description copied from interface:OpenPgpKeyStore
Return thePGPSecretKeyRingCollection
containing all secret keys ofowner
which are locally available. This method might return null.- Specified by:
getSecretKeysOf
in interfaceOpenPgpKeyStore
- Parameters:
owner
-BareJid
of the user we want to get keys from.- Returns:
PGPSecretKeyRingCollection
of the user.- Throws:
IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittle
-
importSecretKey
public void importSecretKey(BareJid owner, org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys) throws IOException, org.bouncycastle.openpgp.PGPException, MissingUserIdOnKeyException
Description copied from interface:OpenPgpKeyStore
Import aPGPSecretKeyRing
ofowner
. In case the key ring is already available locally, the keys are skipped.- Specified by:
importSecretKey
in interfaceOpenPgpKeyStore
- Parameters:
owner
- owner of the keyssecretKeys
- secret keys- Throws:
IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittleMissingUserIdOnKeyException
- in case the secret keys are lacking a user-id with the owners jid.
-
importPublicKey
public void importPublicKey(BareJid owner, org.bouncycastle.openpgp.PGPPublicKeyRing publicKeys) throws IOException, org.bouncycastle.openpgp.PGPException, MissingUserIdOnKeyException
Description copied from interface:OpenPgpKeyStore
Import aPGPPublicKeyRing
ofowner
. In case the key ring is already available locally, the keys are skipped.- Specified by:
importPublicKey
in interfaceOpenPgpKeyStore
- Parameters:
owner
- owner of the keyspublicKeys
- public keys- Throws:
IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittleMissingUserIdOnKeyException
- in case the public keys are lacking a user-id with the owners jid.
-
getPublicKeyRing
public org.bouncycastle.openpgp.PGPPublicKeyRing getPublicKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws IOException, org.bouncycastle.openpgp.PGPException
Description copied from interface:OpenPgpKeyStore
Return thePGPPublicKeyRing
ofowner
which contains the key described byfingerprint
. This method might return null.- Specified by:
getPublicKeyRing
in interfaceOpenPgpKeyStore
- Parameters:
owner
-BareJid
of the keys ownerfingerprint
-OpenPgpV4Fingerprint
of a key contained in the key ring- Returns:
PGPPublicKeyRing
which contains the key described byfingerprint
.- Throws:
IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittle
-
getSecretKeyRing
public org.bouncycastle.openpgp.PGPSecretKeyRing getSecretKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws IOException, org.bouncycastle.openpgp.PGPException
Description copied from interface:OpenPgpKeyStore
Return thePGPSecretKeyRing
ofowner
which contains the key described byfingerprint
. This method might return null.- Specified by:
getSecretKeyRing
in interfaceOpenPgpKeyStore
- Parameters:
owner
-BareJid
of the keys ownerfingerprint
-OpenPgpV4Fingerprint
of a key contained in the key ring- Returns:
PGPSecretKeyRing
which contains the key described byfingerprint
.- Throws:
IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittle
-
deletePublicKeyRing
public void deletePublicKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws IOException, org.bouncycastle.openpgp.PGPException
Description copied from interface:OpenPgpKeyStore
Remove aPGPPublicKeyRing
which contains the key described byfingerprint
from thePGPPublicKeyRingCollection
ofowner
.- Specified by:
deletePublicKeyRing
in interfaceOpenPgpKeyStore
- Parameters:
owner
- owner of the key ringfingerprint
- fingerprint of the key whose key ring will be removed.- Throws:
IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittle
-
deleteSecretKeyRing
public void deleteSecretKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws IOException, org.bouncycastle.openpgp.PGPException
Description copied from interface:OpenPgpKeyStore
Remove aPGPSecretKeyRing
which contains the key described byfingerprint
from thePGPSecretKeyRingCollection
ofowner
.- Specified by:
deleteSecretKeyRing
in interfaceOpenPgpKeyStore
- Parameters:
owner
- owner of the key ringfingerprint
- fingerprint of the key whose key ring will be removed.- Throws:
IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittle
-
generateKeyRing
public org.pgpainless.key.collection.PGPKeyRing generateKeyRing(BareJid owner) throws org.bouncycastle.openpgp.PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException
Description copied from interface:OpenPgpKeyStore
Generate a newPGPKeyRing
forowner
. The key will have a user-id containing the usersBareJid
(eg. "xmpp:juliet@capulet.lit"). This method MUST NOT return null.- Specified by:
generateKeyRing
in interfaceOpenPgpKeyStore
- Parameters:
owner
- owner of the key ring.- Returns:
- key ring
- Throws:
org.bouncycastle.openpgp.PGPException
- PGP is brittleNoSuchAlgorithmException
- in case there is noProvider
registered for the used OpenPGP algorithms.NoSuchProviderException
- in case there is no suitableProvider
registered.InvalidAlgorithmParameterException
- in case an invalid algorithms configuration is used.
-
-