public abstract class AbstractOpenPgpStore extends Observable implements OpenPgpStore
OpenPgpTrustStore.Trust
Modifier and Type | Field and 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 |
Modifier | Constructor and Description |
---|---|
protected |
AbstractOpenPgpStore(OpenPgpKeyStore keyStore,
OpenPgpMetadataStore metadataStore,
OpenPgpTrustStore trustStore) |
Modifier and Type | Method and Description |
---|---|
void |
deletePublicKeyRing(BareJid owner,
org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)
Remove a
PGPPublicKeyRing which contains the key described by fingerprint from the
PGPPublicKeyRingCollection of owner . |
void |
deleteSecretKeyRing(BareJid owner,
org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)
Remove a
PGPSecretKeyRing which contains the key described by fingerprint from the
PGPSecretKeyRingCollection of owner . |
org.pgpainless.key.collection.PGPKeyRing |
generateKeyRing(BareJid owner)
Generate a new
PGPKeyRing for owner . |
Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> |
getAnnouncedFingerprintsOf(BareJid contact)
Return a
Map containing all announced fingerprints of a contact, as well as the dates on which they were
last modified by contact . |
org.pgpainless.key.protection.SecretKeyRingProtector |
getKeyRingProtector()
Return the
SecretKeyRingProtector which is used to decrypt password protected secret keys. |
OpenPgpContact |
getOpenPgpContact(BareJid jid)
Return an
OpenPgpContact for a contacts jid. |
Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> |
getPublicKeyFetchDates(BareJid contact)
Return the last date on which keys of
contact were fetched from PubSub. |
org.bouncycastle.openpgp.PGPPublicKeyRing |
getPublicKeyRing(BareJid owner,
org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)
Return the
PGPPublicKeyRing of owner which contains the key described by fingerprint . |
org.bouncycastle.openpgp.PGPPublicKeyRingCollection |
getPublicKeysOf(BareJid owner)
Return the
PGPPublicKeyRingCollection containing all public keys of owner that are locally
available. |
org.bouncycastle.openpgp.PGPSecretKeyRing |
getSecretKeyRing(BareJid owner,
org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)
Return the
PGPSecretKeyRing of owner which contains the key described by fingerprint . |
org.bouncycastle.openpgp.PGPSecretKeyRingCollection |
getSecretKeysOf(BareJid owner)
Return the
PGPSecretKeyRingCollection containing all secret keys of owner which are locally
available. |
OpenPgpTrustStore.Trust |
getTrust(BareJid owner,
org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)
|
void |
importPublicKey(BareJid owner,
org.bouncycastle.openpgp.PGPPublicKeyRing publicKeys)
Import a
PGPPublicKeyRing of owner . |
void |
importSecretKey(BareJid owner,
org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)
Import a
PGPSecretKeyRing of owner . |
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 a
SecretKeyRingProtector 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 of
contact were fetched from PubSub. |
void |
setSecretKeyPassphraseCallback(SecretKeyPassphraseCallback callback)
Set a
SecretKeyPassphraseCallback 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)
|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
protected final OpenPgpKeyStore keyStore
protected final OpenPgpMetadataStore metadataStore
protected final OpenPgpTrustStore trustStore
protected SecretKeyPassphraseCallback secretKeyPassphraseCallback
protected org.pgpainless.key.protection.SecretKeyRingProtector unlocker
protected final Map<BareJid,OpenPgpContact> contacts
protected AbstractOpenPgpStore(OpenPgpKeyStore keyStore, OpenPgpMetadataStore metadataStore, OpenPgpTrustStore trustStore)
public void deletePublicKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws IOException, org.bouncycastle.openpgp.PGPException
OpenPgpKeyStore
PGPPublicKeyRing
which contains the key described by fingerprint
from the
PGPPublicKeyRingCollection
of owner
.deletePublicKeyRing
in interface OpenPgpKeyStore
owner
- owner of the key ringfingerprint
- fingerprint of the key whose key ring will be removed.IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittlepublic void deleteSecretKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws IOException, org.bouncycastle.openpgp.PGPException
OpenPgpKeyStore
PGPSecretKeyRing
which contains the key described by fingerprint
from the
PGPSecretKeyRingCollection
of owner
.deleteSecretKeyRing
in interface OpenPgpKeyStore
owner
- owner of the key ringfingerprint
- fingerprint of the key whose key ring will be removed.IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittlepublic OpenPgpContact getOpenPgpContact(BareJid jid)
OpenPgpStore
OpenPgpContact
for a contacts jid.getOpenPgpContact
in interface OpenPgpStore
jid
- BareJid
of the contact.OpenPgpContact
object of the contact.public void setKeyRingProtector(org.pgpainless.key.protection.SecretKeyRingProtector protector)
OpenPgpStore
SecretKeyRingProtector
which is used to decrypt password protected secret keys.setKeyRingProtector
in interface OpenPgpStore
protector
- unlocker which unlocks encrypted secret keys.public org.pgpainless.key.protection.SecretKeyRingProtector getKeyRingProtector()
OpenPgpStore
SecretKeyRingProtector
which is used to decrypt password protected secret keys.
In case no SecretKeyRingProtector
has been set, this method MUST return an UnprotectedKeysProtector
.getKeyRingProtector
in interface OpenPgpStore
public void setSecretKeyPassphraseCallback(SecretKeyPassphraseCallback callback)
OpenPgpStore
SecretKeyPassphraseCallback
which is called in case we stumble over a secret key for which we have
no passphrase.setSecretKeyPassphraseCallback
in interface OpenPgpStore
callback
- callback. MUST NOT be null.public org.bouncycastle.openpgp.PGPPublicKeyRingCollection getPublicKeysOf(BareJid owner) throws IOException, org.bouncycastle.openpgp.PGPException
OpenPgpKeyStore
PGPPublicKeyRingCollection
containing all public keys of owner
that are locally
available.
This method might return null.getPublicKeysOf
in interface OpenPgpKeyStore
owner
- BareJid
of the user we want to get keys from.PGPPublicKeyRingCollection
of the user.IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittlepublic org.bouncycastle.openpgp.PGPSecretKeyRingCollection getSecretKeysOf(BareJid owner) throws IOException, org.bouncycastle.openpgp.PGPException
OpenPgpKeyStore
PGPSecretKeyRingCollection
containing all secret keys of owner
which are locally
available.
This method might return null.getSecretKeysOf
in interface OpenPgpKeyStore
owner
- BareJid
of the user we want to get keys from.PGPSecretKeyRingCollection
of the user.IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittlepublic org.bouncycastle.openpgp.PGPPublicKeyRing getPublicKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws IOException, org.bouncycastle.openpgp.PGPException
OpenPgpKeyStore
PGPPublicKeyRing
of owner
which contains the key described by fingerprint
.
This method might return null.getPublicKeyRing
in interface OpenPgpKeyStore
owner
- BareJid
of the keys ownerfingerprint
- OpenPgpV4Fingerprint
of a key contained in the key ringPGPPublicKeyRing
which contains the key described by fingerprint
.IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittlepublic org.bouncycastle.openpgp.PGPSecretKeyRing getSecretKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws IOException, org.bouncycastle.openpgp.PGPException
OpenPgpKeyStore
PGPSecretKeyRing
of owner
which contains the key described by fingerprint
.
This method might return null.getSecretKeyRing
in interface OpenPgpKeyStore
owner
- BareJid
of the keys ownerfingerprint
- OpenPgpV4Fingerprint
of a key contained in the key ringPGPSecretKeyRing
which contains the key described by fingerprint
.IOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittlepublic org.pgpainless.key.collection.PGPKeyRing generateKeyRing(BareJid owner) throws org.bouncycastle.openpgp.PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException
OpenPgpKeyStore
PGPKeyRing
for owner
.
The key will have a user-id containing the users BareJid
(eg. "xmpp:juliet@capulet.lit").
This method MUST NOT return null.generateKeyRing
in interface OpenPgpKeyStore
owner
- owner of the key ring.org.bouncycastle.openpgp.PGPException
- PGP is brittleNoSuchAlgorithmException
- in case there is no Provider
registered for the used
OpenPGP algorithms.NoSuchProviderException
- in case there is no suitable Provider
registered.InvalidAlgorithmParameterException
- in case an invalid algorithms configuration is used.public void importSecretKey(BareJid owner, org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys) throws IOException, org.bouncycastle.openpgp.PGPException, MissingUserIdOnKeyException
OpenPgpKeyStore
PGPSecretKeyRing
of owner
.
In case the key ring is already available locally, the keys are skipped.importSecretKey
in interface OpenPgpKeyStore
owner
- owner of the keyssecretKeys
- secret keysIOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittleMissingUserIdOnKeyException
- in case the secret keys are lacking a user-id with the owners jid.public void importPublicKey(BareJid owner, org.bouncycastle.openpgp.PGPPublicKeyRing publicKeys) throws IOException, org.bouncycastle.openpgp.PGPException, MissingUserIdOnKeyException
OpenPgpKeyStore
PGPPublicKeyRing
of owner
.
In case the key ring is already available locally, the keys are skipped.importPublicKey
in interface OpenPgpKeyStore
owner
- owner of the keyspublicKeys
- public keysIOException
- IO is dangerousorg.bouncycastle.openpgp.PGPException
- PGP is brittleMissingUserIdOnKeyException
- in case the public keys are lacking a user-id with the owners jid.public Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> getPublicKeyFetchDates(BareJid contact) throws IOException
OpenPgpKeyStore
contact
were fetched from PubSub.
This method MUST NOT return null.getPublicKeyFetchDates
in interface OpenPgpKeyStore
contact
- contact in which we are interested.IOException
- IO is dangerouspublic void setPublicKeyFetchDates(BareJid contact, Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> dates) throws IOException
OpenPgpKeyStore
contact
were fetched from PubSub.setPublicKeyFetchDates
in interface OpenPgpKeyStore
contact
- contact in which we are interested.dates
- dates of last key fetching.IOException
- IO is dangerouspublic Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> getAnnouncedFingerprintsOf(BareJid contact) throws IOException
OpenPgpMetadataStore
Map
containing all announced fingerprints of a contact, as well as the dates on which they were
last modified by contact
.
This method MUST NOT return null.getAnnouncedFingerprintsOf
in interface OpenPgpMetadataStore
contact
- contact in which we are interested.IOException
- IO is dangerouspublic void setAnnouncedFingerprintsOf(BareJid contact, Map<org.pgpainless.key.OpenPgpV4Fingerprint,Date> data) throws IOException
OpenPgpMetadataStore
setAnnouncedFingerprintsOf
in interface OpenPgpMetadataStore
contact
- contact in which we are interested.data
- Map
containing the contacts announced fingerprints and dates of last modification.IOException
- IO is dangerouspublic OpenPgpTrustStore.Trust getTrust(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws IOException
OpenPgpTrustStore
OpenPgpTrustStore.Trust
state of owner
s key with fingerprint fingerprint
.
The trust state describes, whether the user trusts a certain key of a contact.
If no OpenPgpTrustStore.Trust
record has been found, this method MUST return not null, nut OpenPgpTrustStore.Trust.undecided
.getTrust
in interface OpenPgpTrustStore
owner
- owner of the keyfingerprint
- fingerprint of the keyIOException
- IO is dangerouspublic void setTrust(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint, OpenPgpTrustStore.Trust trust) throws IOException
OpenPgpTrustStore
setTrust
in interface OpenPgpTrustStore
owner
- owner of the keyfingerprint
- fingerprint of the keytrust
- trust recordIOException
- IO is dangerous