Package org.jivesoftware.smackx.ox
Class OpenPgpContact
java.lang.Object
org.jivesoftware.smackx.ox.OpenPgpContact
- Direct Known Subclasses:
OpenPgpSelf
The OpenPgpContact is sort of a specialized view on the OpenPgpStore, which gives you access to the information
about the user. It also allows contact-specific actions like fetching the contacts keys from PubSub etc.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOpenPgpContact(BareJid jid, OpenPgpStore store) Create a new OpenPgpContact. -
Method Summary
Modifier and TypeMethodDescriptionvoiddistrust(org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) Mark a key asOpenPgpTrustStore.Trust.untrusted.org.bouncycastle.openpgp.PGPPublicKeyRingCollectionReturn any announced public keys.org.bouncycastle.openpgp.PGPPublicKeyRingCollectionReturn any available public keys of the user.Set<org.pgpainless.key.OpenPgpV4Fingerprint>getFingerprintsOfKeysWithState(org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeys, OpenPgpTrustStore.Trust trust) Return aSetofOpenPgpV4Fingerprints of all keys inpublicKeys, which are marked with theOpenPgpTrustStore.Trustoftrust.getJid()Return the jid of the contact.protected org.bouncycastle.openpgp.PGPPublicKeyRingCollectiongetPublicKeysOfTrustState(org.bouncycastle.openpgp.PGPPublicKeyRingCollection keys, OpenPgpTrustStore.Trust trust) Return aPGPPublicKeyRingCollection, which contains all keys fromkeys, which are marked with theOpenPgpTrustStore.Truststate oftrust.getTrust(org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) Determine theOpenPgpTrustStore.Truststate of the key identified by thefingerprint.org.bouncycastle.openpgp.PGPPublicKeyRingCollectionReturn aPGPPublicKeyRingCollectionwhich contains all public keys of the contact, which are announced, as well as marked asOpenPgpTrustStore.Trust.trusted.Set<org.pgpainless.key.OpenPgpV4Fingerprint>Return aSetofOpenPgpV4Fingerprints of all keys of the contact, which have the trust stateOpenPgpTrustStore.Trust.trusted.Set<org.pgpainless.key.OpenPgpV4Fingerprint>Return aSetofOpenPgpV4Fingerprints of all keys of the contact, which have the trust stateOpenPgpTrustStore.Trust.undecided.Return aMapof any unfetchable keys fingerprints and the cause of them not being fetched.Set<org.pgpainless.key.OpenPgpV4Fingerprint>Return aSetofOpenPgpV4Fingerprints of all keys of the contact, which have the trust stateOpenPgpTrustStore.Trust.untrusted.booleanDetermine, whether there are keys available, for which we did not yet decided whether to trust them or not.booleanisTrusted(org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) Determine, whether the key identified by thefingerprintis marked asOpenPgpTrustStore.Trust.trustedor not.voidtrust(org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) Mark a key asOpenPgpTrustStore.Trust.trusted.voidupdateKeys(XMPPConnection connection) Update the contacts keys by consulting the users PubSub nodes.voidupdateKeys(XMPPConnection connection, PublicKeysListElement metadata) Update the contacts keys using a prefetchedPublicKeysListElement.
-
Field Details
-
jid
-
store
-
unfetchableKeys
-
-
Constructor Details
-
OpenPgpContact
Create a new OpenPgpContact.- Parameters:
jid-BareJidof the contact.store-OpenPgpStore.
-
-
Method Details
-
getJid
Return the jid of the contact.- Returns:
- jid TODO javadoc me please
-
getAnyPublicKeys
public org.bouncycastle.openpgp.PGPPublicKeyRingCollection getAnyPublicKeys() throws IOException, org.bouncycastle.openpgp.PGPExceptionReturn any available public keys of the user. The result might also contain outdated or invalid keys.- Returns:
- any keys of the contact.
- Throws:
IOException- IO is dangerousorg.bouncycastle.openpgp.PGPException- PGP is brittle
-
getAnnouncedPublicKeys
public org.bouncycastle.openpgp.PGPPublicKeyRingCollection getAnnouncedPublicKeys() throws IOException, org.bouncycastle.openpgp.PGPExceptionReturn any announced public keys. This is the set returned bygetAnyPublicKeys()with non-announced keys and keys which lack a user-id with the contacts jid removed.- Returns:
- announced keys of the contact
- Throws:
IOException- IO is dangerousorg.bouncycastle.openpgp.PGPException- PGP is brittle
-
getPublicKeysOfTrustState
protected org.bouncycastle.openpgp.PGPPublicKeyRingCollection getPublicKeysOfTrustState(org.bouncycastle.openpgp.PGPPublicKeyRingCollection keys, OpenPgpTrustStore.Trust trust) throws IOException Return aPGPPublicKeyRingCollection, which contains all keys fromkeys, which are marked with theOpenPgpTrustStore.Truststate oftrust.- Parameters:
keys-PGPPublicKeyRingCollectiontrust-OpenPgpTrustStore.Trust- Returns:
- all keys from
keyswith trust statetrust. - Throws:
IOException- IO error
-
getTrustedAnnouncedKeys
public org.bouncycastle.openpgp.PGPPublicKeyRingCollection getTrustedAnnouncedKeys() throws IOException, org.bouncycastle.openpgp.PGPExceptionReturn aPGPPublicKeyRingCollectionwhich contains all public keys of the contact, which are announced, as well as marked asOpenPgpTrustStore.Trust.trusted.- Returns:
- announced, trusted keys.
- Throws:
IOException- IO errororg.bouncycastle.openpgp.PGPException- PGP error
-
getTrustedFingerprints
public Set<org.pgpainless.key.OpenPgpV4Fingerprint> getTrustedFingerprints() throws IOException, org.bouncycastle.openpgp.PGPExceptionReturn aSetofOpenPgpV4Fingerprints of all keys of the contact, which have the trust stateOpenPgpTrustStore.Trust.trusted.- Returns:
- trusted fingerprints
- Throws:
IOException- IO errororg.bouncycastle.openpgp.PGPException- PGP error
-
getUntrustedFingerprints
public Set<org.pgpainless.key.OpenPgpV4Fingerprint> getUntrustedFingerprints() throws IOException, org.bouncycastle.openpgp.PGPExceptionReturn aSetofOpenPgpV4Fingerprints of all keys of the contact, which have the trust stateOpenPgpTrustStore.Trust.untrusted.- Returns:
- untrusted fingerprints
- Throws:
IOException- IO errororg.bouncycastle.openpgp.PGPException- PGP error
-
getUndecidedFingerprints
public Set<org.pgpainless.key.OpenPgpV4Fingerprint> getUndecidedFingerprints() throws IOException, org.bouncycastle.openpgp.PGPExceptionReturn aSetofOpenPgpV4Fingerprints of all keys of the contact, which have the trust stateOpenPgpTrustStore.Trust.undecided.- Returns:
- undecided fingerprints
- Throws:
IOException- IO errororg.bouncycastle.openpgp.PGPException- PGP error
-
getFingerprintsOfKeysWithState
public Set<org.pgpainless.key.OpenPgpV4Fingerprint> getFingerprintsOfKeysWithState(org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeys, OpenPgpTrustStore.Trust trust) throws IOException Return aSetofOpenPgpV4Fingerprints of all keys inpublicKeys, which are marked with theOpenPgpTrustStore.Trustoftrust.- Parameters:
publicKeys-PGPPublicKeyRingCollectionof keys which are iterated.trust-OpenPgpTrustStore.Truststate.- Returns:
Setof fingerprints- Throws:
IOException- IO error
-
getTrust
public OpenPgpTrustStore.Trust getTrust(org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws IOException Determine theOpenPgpTrustStore.Truststate of the key identified by thefingerprint.- Parameters:
fingerprint-OpenPgpV4Fingerprintof the key- Returns:
- trust record
- Throws:
IOException- IO error
-
isTrusted
Determine, whether the key identified by thefingerprintis marked asOpenPgpTrustStore.Trust.trustedor not.- Parameters:
fingerprint-OpenPgpV4Fingerprintof the key- Returns:
- true, if the key is marked as trusted, false otherwise
- Throws:
IOException- IO error
-
trust
Mark a key asOpenPgpTrustStore.Trust.trusted.- Parameters:
fingerprint-OpenPgpV4Fingerprintof the key to mark as trusted.- Throws:
IOException- IO error
-
distrust
Mark a key asOpenPgpTrustStore.Trust.untrusted.- Parameters:
fingerprint-OpenPgpV4Fingerprintof the key to mark as untrusted.- Throws:
IOException- IO error
-
hasUndecidedKeys
Determine, whether there are keys available, for which we did not yet decided whether to trust them or not.- Returns:
- more than 0 keys with trust state
OpenPgpTrustStore.Trust.undecided. - Throws:
IOException- I/O error reading the keys or trust records.org.bouncycastle.openpgp.PGPException- PGP error reading the keys.
-
getUnfetchableKeys
Return aMapof any unfetchable keys fingerprints and the cause of them not being fetched.- Returns:
- unfetchable keys
-
updateKeys
public void updateKeys(XMPPConnection connection) throws InterruptedException, SmackException.NotConnectedException, SmackException.NoResponseException, XMPPException.XMPPErrorException, PubSubException.NotALeafNodeException, PubSubException.NotAPubSubNodeException, IOException Update the contacts keys by consulting the users PubSub nodes. This method fetches the users metadata node and then tries to fetch any announced keys.- Parameters:
connection- ourXMPPConnection.- Throws:
InterruptedException- In case the thread gets interrupted.SmackException.NotConnectedException- in case the connection is not connected.SmackException.NoResponseException- in case the server doesn't respond.XMPPException.XMPPErrorException- in case of an XMPP protocol error.PubSubException.NotALeafNodeException- in case the metadata node is not aLeafNode.PubSubException.NotAPubSubNodeException- in case the metadata node is not a PubSub node.IOException- IO is brittle.
-
updateKeys
public void updateKeys(XMPPConnection connection, PublicKeysListElement metadata) throws InterruptedException, SmackException.NotConnectedException, SmackException.NoResponseException, IOException Update the contacts keys using a prefetchedPublicKeysListElement.- Parameters:
connection- ourXMPPConnection.metadata- pre-fetched OX metadata node of the contact.- Throws:
InterruptedException- in case the thread gets interrupted.SmackException.NotConnectedException- in case the connection is not connected.SmackException.NoResponseException- in case the server doesn't respond.IOException- IO is dangerous.
-