Class AbstractOpenPgpStore
- java.lang.Object
-
- org.jivesoftware.smackx.ox.store.abstr.AbstractOpenPgpStore
-
- All Implemented Interfaces:
OpenPgpKeyStore
,OpenPgpMetadataStore
,OpenPgpStore
,OpenPgpTrustStore
- Direct Known Subclasses:
FileBasedOpenPgpStore
public abstract class AbstractOpenPgpStore extends Object implements OpenPgpStore
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jivesoftware.smackx.ox.store.definition.OpenPgpTrustStore
OpenPgpTrustStore.Trust
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<BareJid,OpenPgpContact>
contacts
protected OpenPgpKeyStore
keyStore
protected OpenPgpMetadataStore
metadataStore
protected SecretKeyPassphraseCallback
secretKeyPassphraseCallback
protected OpenPgpTrustStore
trustStore
protected org.pgpainless.key.protection.SecretKeyRingProtector
unlocker
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractOpenPgpStore(OpenPgpKeyStore keyStore, OpenPgpMetadataStore metadataStore, OpenPgpTrustStore trustStore)
-
Method Summary
All Methods Instance 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>
getAnnouncedFingerprintsOf(BareJid contact)
Return aMap
containing all announced fingerprints of a contact, as well as the dates on which they were last modified bycontact
.org.pgpainless.key.protection.SecretKeyRingProtector
getKeyRingProtector()
Return theSecretKeyRingProtector
which is used to decrypt password protected secret keys.OpenPgpContact
getOpenPgpContact(BareJid jid)
Return anOpenPgpContact
for a contacts jid.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.OpenPgpTrustStore.Trust
getTrust(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)
void
importPublicKey(BareJid owner, org.bouncycastle.openpgp.PGPPublicKeyRing publicKeys)
Import aPGPPublicKeyRing
ofowner
.void
importSecretKey(BareJid owner, org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)
Import aPGPSecretKeyRing
ofowner
.void
setAnnouncedFingerprintsOf(BareJid contact, Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> data)
Store a contacts announced fingerprints and dates of last modification.void
setKeyRingProtector(org.pgpainless.key.protection.SecretKeyRingProtector protector)
Set aSecretKeyRingProtector
which is used to decrypt password protected secret keys.void
setPublicKeyFetchDates(BareJid contact, Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> dates)
Set the last date on which keys ofcontact
were fetched from PubSub.void
setSecretKeyPassphraseCallback(SecretKeyPassphraseCallback callback)
Set aSecretKeyPassphraseCallback
which is called in case we stumble over a secret key for which we have no passphrase.void
setTrust(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint, OpenPgpTrustStore.Trust trust)
-
-
-
Field Detail
-
keyStore
protected final OpenPgpKeyStore keyStore
-
metadataStore
protected final OpenPgpMetadataStore metadataStore
-
trustStore
protected final OpenPgpTrustStore trustStore
-
secretKeyPassphraseCallback
protected SecretKeyPassphraseCallback secretKeyPassphraseCallback
-
unlocker
protected org.pgpainless.key.protection.SecretKeyRingProtector unlocker
-
contacts
protected final Map<BareJid,OpenPgpContact> contacts
-
-
Constructor Detail
-
AbstractOpenPgpStore
protected AbstractOpenPgpStore(OpenPgpKeyStore keyStore, OpenPgpMetadataStore metadataStore, OpenPgpTrustStore trustStore)
-
-
Method Detail
-
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
-
getOpenPgpContact
public OpenPgpContact getOpenPgpContact(BareJid jid)
Description copied from interface:OpenPgpStore
Return anOpenPgpContact
for a contacts jid.- Specified by:
getOpenPgpContact
in interfaceOpenPgpStore
- Parameters:
jid
-BareJid
of the contact.- Returns:
OpenPgpContact
object of the contact.
-
setKeyRingProtector
public void setKeyRingProtector(org.pgpainless.key.protection.SecretKeyRingProtector protector)
Description copied from interface:OpenPgpStore
Set aSecretKeyRingProtector
which is used to decrypt password protected secret keys.- Specified by:
setKeyRingProtector
in interfaceOpenPgpStore
- Parameters:
protector
- unlocker which unlocks encrypted secret keys.
-
getKeyRingProtector
public org.pgpainless.key.protection.SecretKeyRingProtector getKeyRingProtector()
Description copied from interface:OpenPgpStore
Return theSecretKeyRingProtector
which is used to decrypt password protected secret keys. In case noSecretKeyRingProtector
has been set, this method MUST return anUnprotectedKeysProtector
.- Specified by:
getKeyRingProtector
in interfaceOpenPgpStore
- Returns:
- secret key unlocker.
-
setSecretKeyPassphraseCallback
public void setSecretKeyPassphraseCallback(SecretKeyPassphraseCallback callback)
Description copied from interface:OpenPgpStore
Set aSecretKeyPassphraseCallback
which is called in case we stumble over a secret key for which we have no passphrase.- Specified by:
setSecretKeyPassphraseCallback
in interfaceOpenPgpStore
- Parameters:
callback
- callback. MUST NOT be null.
-
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
-
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
-
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.
-
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.
-
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
-
getAnnouncedFingerprintsOf
public Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> getAnnouncedFingerprintsOf(BareJid contact) throws IOException
Description copied from interface:OpenPgpMetadataStore
Return aMap
containing all announced fingerprints of a contact, as well as the dates on which they were last modified bycontact
. This method MUST NOT return null.- Specified by:
getAnnouncedFingerprintsOf
in interfaceOpenPgpMetadataStore
- Parameters:
contact
- contact in which we are interested.- Returns:
- announced fingerprints
- Throws:
IOException
- IO is dangerous
-
setAnnouncedFingerprintsOf
public void setAnnouncedFingerprintsOf(BareJid contact, Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> data) throws IOException
Description copied from interface:OpenPgpMetadataStore
Store a contacts announced fingerprints and dates of last modification.- Specified by:
setAnnouncedFingerprintsOf
in interfaceOpenPgpMetadataStore
- Parameters:
contact
- contact in which we are interested.data
-Map
containing the contacts announced fingerprints and dates of last modification.- Throws:
IOException
- IO is dangerous
-
getTrust
public OpenPgpTrustStore.Trust getTrust(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws IOException
Description copied from interface:OpenPgpTrustStore
Return theOpenPgpTrustStore.Trust
state ofowner
s key with fingerprintfingerprint
. The trust state describes, whether the user trusts a certain key of a contact. If noOpenPgpTrustStore.Trust
record has been found, this method MUST return not null, nutOpenPgpTrustStore.Trust.undecided
.- Specified by:
getTrust
in interfaceOpenPgpTrustStore
- Parameters:
owner
- owner of the keyfingerprint
- fingerprint of the key- Returns:
- trust state
- Throws:
IOException
- IO is dangerous
-
setTrust
public void setTrust(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint, OpenPgpTrustStore.Trust trust) throws IOException
Description copied from interface:OpenPgpTrustStore
- Specified by:
setTrust
in interfaceOpenPgpTrustStore
- Parameters:
owner
- owner of the keyfingerprint
- fingerprint of the keytrust
- trust record- Throws:
IOException
- IO is dangerous
-
-