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 java.lang.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 java.util.Map<BareJid,OpenPgpContact>contactsprotected OpenPgpKeyStorekeyStoreprotected OpenPgpMetadataStoremetadataStoreprotected SecretKeyPassphraseCallbacksecretKeyPassphraseCallbackprotected OpenPgpTrustStoretrustStoreprotected org.pgpainless.key.protection.SecretKeyRingProtectorunlocker
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractOpenPgpStore(OpenPgpKeyStore keyStore, OpenPgpMetadataStore metadataStore, OpenPgpTrustStore trustStore)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeletePublicKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)Remove aPGPPublicKeyRingwhich contains the key described byfingerprintfrom thePGPPublicKeyRingCollectionofowner.voiddeleteSecretKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)Remove aPGPSecretKeyRingwhich contains the key described byfingerprintfrom thePGPSecretKeyRingCollectionofowner.org.pgpainless.key.collection.PGPKeyRinggenerateKeyRing(BareJid owner)Generate a newPGPKeyRingforowner.java.util.Map<org.pgpainless.key.OpenPgpV4Fingerprint,java.util.Date>getAnnouncedFingerprintsOf(BareJid contact)Return aMapcontaining all announced fingerprints of a contact, as well as the dates on which they were last modified bycontact.org.pgpainless.key.protection.SecretKeyRingProtectorgetKeyRingProtector()Return theSecretKeyRingProtectorwhich is used to decrypt password protected secret keys.OpenPgpContactgetOpenPgpContact(BareJid jid)Return anOpenPgpContactfor a contacts jid.java.util.Map<org.pgpainless.key.OpenPgpV4Fingerprint,java.util.Date>getPublicKeyFetchDates(BareJid contact)Return the last date on which keys ofcontactwere fetched from PubSub.org.bouncycastle.openpgp.PGPPublicKeyRinggetPublicKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)Return thePGPPublicKeyRingofownerwhich contains the key described byfingerprint.org.bouncycastle.openpgp.PGPPublicKeyRingCollectiongetPublicKeysOf(BareJid owner)Return thePGPPublicKeyRingCollectioncontaining all public keys ofownerthat are locally available.org.bouncycastle.openpgp.PGPSecretKeyRinggetSecretKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)Return thePGPSecretKeyRingofownerwhich contains the key described byfingerprint.org.bouncycastle.openpgp.PGPSecretKeyRingCollectiongetSecretKeysOf(BareJid owner)Return thePGPSecretKeyRingCollectioncontaining all secret keys ofownerwhich are locally available.OpenPgpTrustStore.TrustgetTrust(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)voidimportPublicKey(BareJid owner, org.bouncycastle.openpgp.PGPPublicKeyRing publicKeys)Import aPGPPublicKeyRingofowner.voidimportSecretKey(BareJid owner, org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys)Import aPGPSecretKeyRingofowner.voidsetAnnouncedFingerprintsOf(BareJid contact, java.util.Map<org.pgpainless.key.OpenPgpV4Fingerprint,java.util.Date> data)Store a contacts announced fingerprints and dates of last modification.voidsetKeyRingProtector(org.pgpainless.key.protection.SecretKeyRingProtector protector)Set aSecretKeyRingProtectorwhich is used to decrypt password protected secret keys.voidsetPublicKeyFetchDates(BareJid contact, java.util.Map<org.pgpainless.key.OpenPgpV4Fingerprint,java.util.Date> dates)Set the last date on which keys ofcontactwere fetched from PubSub.voidsetSecretKeyPassphraseCallback(SecretKeyPassphraseCallback callback)Set aSecretKeyPassphraseCallbackwhich is called in case we stumble over a secret key for which we have no passphrase.voidsetTrust(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 java.util.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 java.io.IOException, org.bouncycastle.openpgp.PGPException
Description copied from interface:OpenPgpKeyStoreRemove aPGPPublicKeyRingwhich contains the key described byfingerprintfrom thePGPPublicKeyRingCollectionofowner.- Specified by:
deletePublicKeyRingin interfaceOpenPgpKeyStore- Parameters:
owner- owner of the key ringfingerprint- fingerprint of the key whose key ring will be removed.- Throws:
java.io.IOException- IO is dangerousorg.bouncycastle.openpgp.PGPException- PGP is brittle
-
deleteSecretKeyRing
public void deleteSecretKeyRing(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
Description copied from interface:OpenPgpKeyStoreRemove aPGPSecretKeyRingwhich contains the key described byfingerprintfrom thePGPSecretKeyRingCollectionofowner.- Specified by:
deleteSecretKeyRingin interfaceOpenPgpKeyStore- Parameters:
owner- owner of the key ringfingerprint- fingerprint of the key whose key ring will be removed.- Throws:
java.io.IOException- IO is dangerousorg.bouncycastle.openpgp.PGPException- PGP is brittle
-
getOpenPgpContact
public OpenPgpContact getOpenPgpContact(BareJid jid)
Description copied from interface:OpenPgpStoreReturn anOpenPgpContactfor a contacts jid.- Specified by:
getOpenPgpContactin interfaceOpenPgpStore- Parameters:
jid-BareJidof the contact.- Returns:
OpenPgpContactobject of the contact.
-
setKeyRingProtector
public void setKeyRingProtector(org.pgpainless.key.protection.SecretKeyRingProtector protector)
Description copied from interface:OpenPgpStoreSet aSecretKeyRingProtectorwhich is used to decrypt password protected secret keys.- Specified by:
setKeyRingProtectorin interfaceOpenPgpStore- Parameters:
protector- unlocker which unlocks encrypted secret keys.
-
getKeyRingProtector
public org.pgpainless.key.protection.SecretKeyRingProtector getKeyRingProtector()
Description copied from interface:OpenPgpStoreReturn theSecretKeyRingProtectorwhich is used to decrypt password protected secret keys. In case noSecretKeyRingProtectorhas been set, this method MUST return anUnprotectedKeysProtector.- Specified by:
getKeyRingProtectorin interfaceOpenPgpStore- Returns:
- secret key unlocker.
-
setSecretKeyPassphraseCallback
public void setSecretKeyPassphraseCallback(SecretKeyPassphraseCallback callback)
Description copied from interface:OpenPgpStoreSet aSecretKeyPassphraseCallbackwhich is called in case we stumble over a secret key for which we have no passphrase.- Specified by:
setSecretKeyPassphraseCallbackin interfaceOpenPgpStore- Parameters:
callback- callback. MUST NOT be null.
-
getPublicKeysOf
public org.bouncycastle.openpgp.PGPPublicKeyRingCollection getPublicKeysOf(BareJid owner) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
Description copied from interface:OpenPgpKeyStoreReturn thePGPPublicKeyRingCollectioncontaining all public keys ofownerthat are locally available. This method might return null.- Specified by:
getPublicKeysOfin interfaceOpenPgpKeyStore- Parameters:
owner-BareJidof the user we want to get keys from.- Returns:
PGPPublicKeyRingCollectionof the user.- Throws:
java.io.IOException- IO is dangerousorg.bouncycastle.openpgp.PGPException- PGP is brittle
-
getSecretKeysOf
public org.bouncycastle.openpgp.PGPSecretKeyRingCollection getSecretKeysOf(BareJid owner) throws java.io.IOException, org.bouncycastle.openpgp.PGPException
Description copied from interface:OpenPgpKeyStoreReturn thePGPSecretKeyRingCollectioncontaining all secret keys ofownerwhich are locally available. This method might return null.- Specified by:
getSecretKeysOfin interfaceOpenPgpKeyStore- Parameters:
owner-BareJidof the user we want to get keys from.- Returns:
PGPSecretKeyRingCollectionof the user.- Throws:
java.io.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 java.io.IOException, org.bouncycastle.openpgp.PGPException
Description copied from interface:OpenPgpKeyStoreReturn thePGPPublicKeyRingofownerwhich contains the key described byfingerprint. This method might return null.- Specified by:
getPublicKeyRingin interfaceOpenPgpKeyStore- Parameters:
owner-BareJidof the keys ownerfingerprint-OpenPgpV4Fingerprintof a key contained in the key ring- Returns:
PGPPublicKeyRingwhich contains the key described byfingerprint.- Throws:
java.io.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 java.io.IOException, org.bouncycastle.openpgp.PGPException
Description copied from interface:OpenPgpKeyStoreReturn thePGPSecretKeyRingofownerwhich contains the key described byfingerprint. This method might return null.- Specified by:
getSecretKeyRingin interfaceOpenPgpKeyStore- Parameters:
owner-BareJidof the keys ownerfingerprint-OpenPgpV4Fingerprintof a key contained in the key ring- Returns:
PGPSecretKeyRingwhich contains the key described byfingerprint.- Throws:
java.io.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, java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, java.security.InvalidAlgorithmParameterException
Description copied from interface:OpenPgpKeyStoreGenerate a newPGPKeyRingforowner. The key will have a user-id containing the usersBareJid(eg. "xmpp:juliet@capulet.lit"). This method MUST NOT return null.- Specified by:
generateKeyRingin interfaceOpenPgpKeyStore- Parameters:
owner- owner of the key ring.- Returns:
- key ring
- Throws:
org.bouncycastle.openpgp.PGPException- PGP is brittlejava.security.NoSuchAlgorithmException- in case there is noProviderregistered for the used OpenPGP algorithms.java.security.NoSuchProviderException- in case there is no suitableProviderregistered.java.security.InvalidAlgorithmParameterException- in case an invalid algorithms configuration is used.
-
importSecretKey
public void importSecretKey(BareJid owner, org.bouncycastle.openpgp.PGPSecretKeyRing secretKeys) throws java.io.IOException, org.bouncycastle.openpgp.PGPException, MissingUserIdOnKeyException
Description copied from interface:OpenPgpKeyStoreImport aPGPSecretKeyRingofowner. In case the key ring is already available locally, the keys are skipped.- Specified by:
importSecretKeyin interfaceOpenPgpKeyStore- Parameters:
owner- owner of the keyssecretKeys- secret keys- Throws:
java.io.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 java.io.IOException, org.bouncycastle.openpgp.PGPException, MissingUserIdOnKeyException
Description copied from interface:OpenPgpKeyStoreImport aPGPPublicKeyRingofowner. In case the key ring is already available locally, the keys are skipped.- Specified by:
importPublicKeyin interfaceOpenPgpKeyStore- Parameters:
owner- owner of the keyspublicKeys- public keys- Throws:
java.io.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 java.util.Map<org.pgpainless.key.OpenPgpV4Fingerprint,java.util.Date> getPublicKeyFetchDates(BareJid contact) throws java.io.IOException
Description copied from interface:OpenPgpKeyStoreReturn the last date on which keys ofcontactwere fetched from PubSub. This method MUST NOT return null.- Specified by:
getPublicKeyFetchDatesin interfaceOpenPgpKeyStore- Parameters:
contact- contact in which we are interested.- Returns:
- dates of last key fetching.
- Throws:
java.io.IOException- IO is dangerous
-
setPublicKeyFetchDates
public void setPublicKeyFetchDates(BareJid contact, java.util.Map<org.pgpainless.key.OpenPgpV4Fingerprint,java.util.Date> dates) throws java.io.IOException
Description copied from interface:OpenPgpKeyStoreSet the last date on which keys ofcontactwere fetched from PubSub.- Specified by:
setPublicKeyFetchDatesin interfaceOpenPgpKeyStore- Parameters:
contact- contact in which we are interested.dates- dates of last key fetching.- Throws:
java.io.IOException- IO is dangerous
-
getAnnouncedFingerprintsOf
public java.util.Map<org.pgpainless.key.OpenPgpV4Fingerprint,java.util.Date> getAnnouncedFingerprintsOf(BareJid contact) throws java.io.IOException
Description copied from interface:OpenPgpMetadataStoreReturn aMapcontaining 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:
getAnnouncedFingerprintsOfin interfaceOpenPgpMetadataStore- Parameters:
contact- contact in which we are interested.- Returns:
- announced fingerprints
- Throws:
java.io.IOException- IO is dangerous
-
setAnnouncedFingerprintsOf
public void setAnnouncedFingerprintsOf(BareJid contact, java.util.Map<org.pgpainless.key.OpenPgpV4Fingerprint,java.util.Date> data) throws java.io.IOException
Description copied from interface:OpenPgpMetadataStoreStore a contacts announced fingerprints and dates of last modification.- Specified by:
setAnnouncedFingerprintsOfin interfaceOpenPgpMetadataStore- Parameters:
contact- contact in which we are interested.data-Mapcontaining the contacts announced fingerprints and dates of last modification.- Throws:
java.io.IOException- IO is dangerous
-
getTrust
public OpenPgpTrustStore.Trust getTrust(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws java.io.IOException
Description copied from interface:OpenPgpTrustStoreReturn theOpenPgpTrustStore.Truststate ofowners key with fingerprintfingerprint. The trust state describes, whether the user trusts a certain key of a contact. If noOpenPgpTrustStore.Trustrecord has been found, this method MUST return not null, nutOpenPgpTrustStore.Trust.undecided.- Specified by:
getTrustin interfaceOpenPgpTrustStore- Parameters:
owner- owner of the keyfingerprint- fingerprint of the key- Returns:
- trust state
- Throws:
java.io.IOException- IO is dangerous
-
setTrust
public void setTrust(BareJid owner, org.pgpainless.key.OpenPgpV4Fingerprint fingerprint, OpenPgpTrustStore.Trust trust) throws java.io.IOException
Description copied from interface:OpenPgpTrustStore- Specified by:
setTrustin interfaceOpenPgpTrustStore- Parameters:
owner- owner of the keyfingerprint- fingerprint of the keytrust- trust record- Throws:
java.io.IOException- IO is dangerous
-
-