Package org.jivesoftware.smackx.ox
Class OpenPgpContact
- java.lang.Object
-
- org.jivesoftware.smackx.ox.OpenPgpContact
-
- Direct Known Subclasses:
OpenPgpSelf
public class OpenPgpContact extends java.lang.ObjectThe 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 Modifier and Type Field Description protected org.jxmpp.jid.BareJidjidprotected OpenPgpStorestoreprotected java.util.Map<org.pgpainless.key.OpenPgpV4Fingerprint,java.lang.Throwable>unfetchableKeys
-
Constructor Summary
Constructors Constructor Description OpenPgpContact(org.jxmpp.jid.BareJid jid, OpenPgpStore store)Create a new OpenPgpContact.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddistrust(org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)Mark a key asOpenPgpTrustStore.Trust.untrusted.org.bouncycastle.openpgp.PGPPublicKeyRingCollectiongetAnnouncedPublicKeys()Return any announced public keys.org.bouncycastle.openpgp.PGPPublicKeyRingCollectiongetAnyPublicKeys()Return any available public keys of the user.java.util.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.org.jxmpp.jid.BareJidgetJid()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.OpenPgpTrustStore.TrustgetTrust(org.pgpainless.key.OpenPgpV4Fingerprint fingerprint)Determine theOpenPgpTrustStore.Truststate of the key identified by thefingerprint.org.bouncycastle.openpgp.PGPPublicKeyRingCollectiongetTrustedAnnouncedKeys()Return aPGPPublicKeyRingCollectionwhich contains all public keys of the contact, which are announced, as well as marked asOpenPgpTrustStore.Trust.trusted.java.util.Set<org.pgpainless.key.OpenPgpV4Fingerprint>getTrustedFingerprints()Return aSetofOpenPgpV4Fingerprints of all keys of the contact, which have the trust stateOpenPgpTrustStore.Trust.trusted.java.util.Set<org.pgpainless.key.OpenPgpV4Fingerprint>getUndecidedFingerprints()Return aSetofOpenPgpV4Fingerprints of all keys of the contact, which have the trust stateOpenPgpTrustStore.Trust.undecided.java.util.Map<org.pgpainless.key.OpenPgpV4Fingerprint,java.lang.Throwable>getUnfetchableKeys()Return aMapof any unfetchable keys fingerprints and the cause of them not being fetched.java.util.Set<org.pgpainless.key.OpenPgpV4Fingerprint>getUntrustedFingerprints()Return aSetofOpenPgpV4Fingerprints of all keys of the contact, which have the trust stateOpenPgpTrustStore.Trust.untrusted.booleanhasUndecidedKeys()Determine, 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(org.jivesoftware.smack.XMPPConnection connection)Update the contacts keys by consulting the users PubSub nodes.voidupdateKeys(org.jivesoftware.smack.XMPPConnection connection, PublicKeysListElement metadata)Update the contacts keys using a prefetchedPublicKeysListElement.
-
-
-
Field Detail
-
jid
protected final org.jxmpp.jid.BareJid jid
-
store
protected final OpenPgpStore store
-
unfetchableKeys
protected final java.util.Map<org.pgpainless.key.OpenPgpV4Fingerprint,java.lang.Throwable> unfetchableKeys
-
-
Constructor Detail
-
OpenPgpContact
public OpenPgpContact(org.jxmpp.jid.BareJid jid, OpenPgpStore store)Create a new OpenPgpContact.- Parameters:
jid-BareJidof the contact.store-OpenPgpStore.
-
-
Method Detail
-
getJid
public org.jxmpp.jid.BareJid getJid()
Return the jid of the contact.- Returns:
- jid TODO javadoc me please
-
getAnyPublicKeys
public org.bouncycastle.openpgp.PGPPublicKeyRingCollection getAnyPublicKeys() throws java.io.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:
java.io.IOException- IO is dangerousorg.bouncycastle.openpgp.PGPException- PGP is brittle
-
getAnnouncedPublicKeys
public org.bouncycastle.openpgp.PGPPublicKeyRingCollection getAnnouncedPublicKeys() throws java.io.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:
java.io.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 java.io.IOExceptionReturn 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:
java.io.IOException- IO error
-
getTrustedAnnouncedKeys
public org.bouncycastle.openpgp.PGPPublicKeyRingCollection getTrustedAnnouncedKeys() throws java.io.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:
java.io.IOException- IO errororg.bouncycastle.openpgp.PGPException- PGP error
-
getTrustedFingerprints
public java.util.Set<org.pgpainless.key.OpenPgpV4Fingerprint> getTrustedFingerprints() throws java.io.IOException, org.bouncycastle.openpgp.PGPExceptionReturn aSetofOpenPgpV4Fingerprints of all keys of the contact, which have the trust stateOpenPgpTrustStore.Trust.trusted.- Returns:
- trusted fingerprints
- Throws:
java.io.IOException- IO errororg.bouncycastle.openpgp.PGPException- PGP error
-
getUntrustedFingerprints
public java.util.Set<org.pgpainless.key.OpenPgpV4Fingerprint> getUntrustedFingerprints() throws java.io.IOException, org.bouncycastle.openpgp.PGPExceptionReturn aSetofOpenPgpV4Fingerprints of all keys of the contact, which have the trust stateOpenPgpTrustStore.Trust.untrusted.- Returns:
- untrusted fingerprints
- Throws:
java.io.IOException- IO errororg.bouncycastle.openpgp.PGPException- PGP error
-
getUndecidedFingerprints
public java.util.Set<org.pgpainless.key.OpenPgpV4Fingerprint> getUndecidedFingerprints() throws java.io.IOException, org.bouncycastle.openpgp.PGPExceptionReturn aSetofOpenPgpV4Fingerprints of all keys of the contact, which have the trust stateOpenPgpTrustStore.Trust.undecided.- Returns:
- undecided fingerprints
- Throws:
java.io.IOException- IO errororg.bouncycastle.openpgp.PGPException- PGP error
-
getFingerprintsOfKeysWithState
public java.util.Set<org.pgpainless.key.OpenPgpV4Fingerprint> getFingerprintsOfKeysWithState(org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeys, OpenPgpTrustStore.Trust trust) throws java.io.IOExceptionReturn 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:
java.io.IOException- IO error
-
getTrust
public OpenPgpTrustStore.Trust getTrust(org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws java.io.IOException
Determine theOpenPgpTrustStore.Truststate of the key identified by thefingerprint.- Parameters:
fingerprint-OpenPgpV4Fingerprintof the key- Returns:
- trust record
- Throws:
java.io.IOException- IO error
-
isTrusted
public boolean isTrusted(org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws java.io.IOExceptionDetermine, 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:
java.io.IOException- IO error
-
trust
public void trust(org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws java.io.IOExceptionMark a key asOpenPgpTrustStore.Trust.trusted.- Parameters:
fingerprint-OpenPgpV4Fingerprintof the key to mark as trusted.- Throws:
java.io.IOException- IO error
-
distrust
public void distrust(org.pgpainless.key.OpenPgpV4Fingerprint fingerprint) throws java.io.IOExceptionMark a key asOpenPgpTrustStore.Trust.untrusted.- Parameters:
fingerprint-OpenPgpV4Fingerprintof the key to mark as untrusted.- Throws:
java.io.IOException- IO error
-
hasUndecidedKeys
public boolean hasUndecidedKeys() throws java.io.IOException, org.bouncycastle.openpgp.PGPExceptionDetermine, 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:
java.io.IOException- I/O error reading the keys or trust records.org.bouncycastle.openpgp.PGPException- PGP error reading the keys.
-
getUnfetchableKeys
public java.util.Map<org.pgpainless.key.OpenPgpV4Fingerprint,java.lang.Throwable> getUnfetchableKeys()
Return aMapof any unfetchable keys fingerprints and the cause of them not being fetched.- Returns:
- unfetchable keys
-
updateKeys
public void updateKeys(org.jivesoftware.smack.XMPPConnection connection) throws java.lang.InterruptedException, org.jivesoftware.smack.SmackException.NotConnectedException, org.jivesoftware.smack.SmackException.NoResponseException, org.jivesoftware.smack.XMPPException.XMPPErrorException, org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException, org.jivesoftware.smackx.pubsub.PubSubException.NotAPubSubNodeException, java.io.IOExceptionUpdate 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:
java.lang.InterruptedException- In case the thread gets interrupted.org.jivesoftware.smack.SmackException.NotConnectedException- in case the connection is not connected.org.jivesoftware.smack.SmackException.NoResponseException- in case the server doesn't respond.org.jivesoftware.smack.XMPPException.XMPPErrorException- in case of an XMPP protocol error.org.jivesoftware.smackx.pubsub.PubSubException.NotALeafNodeException- in case the metadata node is not aLeafNode.org.jivesoftware.smackx.pubsub.PubSubException.NotAPubSubNodeException- in case the metadata node is not a PubSub node.java.io.IOException- IO is brittle.
-
updateKeys
public void updateKeys(org.jivesoftware.smack.XMPPConnection connection, PublicKeysListElement metadata) throws java.lang.InterruptedException, org.jivesoftware.smack.SmackException.NotConnectedException, org.jivesoftware.smack.SmackException.NoResponseException, java.io.IOExceptionUpdate the contacts keys using a prefetchedPublicKeysListElement.- Parameters:
connection- ourXMPPConnection.metadata- pre-fetched OX metadata node of the contact.- Throws:
java.lang.InterruptedException- in case the thread gets interrupted.org.jivesoftware.smack.SmackException.NotConnectedException- in case the connection is not connected.org.jivesoftware.smack.SmackException.NoResponseException- in case the server doesn't respond.java.io.IOException- IO is dangerous.
-
-