Class OpenPgpManager

java.lang.Object
org.jivesoftware.smack.Manager
org.jivesoftware.smackx.ox.OpenPgpManager

public final class OpenPgpManager extends Manager
Entry point for Smacks API for OpenPGP for XMPP.

Setup

In order to use OpenPGP for XMPP in Smack, just follow the following procedure.

First, acquire an instance of the OpenPgpManager for your XMPPConnection using getInstanceFor(XMPPConnection).
 
 OpenPgpManager openPgpManager = OpenPgpManager.getInstanceFor(connection);
 
 
You also need an OpenPgpProvider, as well as an OpenPgpStore. The provider must be registered using setOpenPgpProvider(OpenPgpProvider).
 
 OpenPgpStore store = new FileBasedOpenPgpStore(storePath);
 OpenPgpProvider provider = new PainlessOpenPgpProvider(connection, store);
 openPgpManager.setOpenPgpProvider(provider);
 
 
It is also advised to register a custom SecretKeyRingProtector using OpenPgpStore.setKeyRingProtector(SecretKeyRingProtector) in order to be able to handle password protected secret keys.

Speaking of keys, you can now check, if you have any keys available in your OpenPgpStore by doing hasSecretKeysAvailable().

If you do, you can now announce support for OX and publish those keys using announceSupportAndPublish().

Otherwise, you can either generate fresh keys using generateAndImportKeyPair(BareJid), or try to restore a secret key backup from your private PubSub node by doing restoreSecretKeyServerBackup(AskForBackupCodeCallback).

In any case you should still do an announceSupportAndPublish() afterwards.

Contacts are represented by OpenPgpContacts in the context of OpenPGP for XMPP. You can get those by using getOpenPgpContact(EntityBareJid). The main function of OpenPgpContacts is to bundle information about the OpenPGP capabilities of a contact in one spot. The pendant to the OpenPgpContact is the OpenPgpSelf, which encapsulates your own OpenPGP identity. Both classes can be used to acquire information about the OpenPGP keys of a user.

Elements

OpenPGP for XMPP defines multiple different element classes which contain the users messages. The outermost element is the OpenPgpElement, which contains an OpenPGP encrypted content element. The content can be either a SignElement, CryptElement or SigncryptElement, depending on the use-case. Those content elements contain the actual payload. If an OpenPgpElement is decrypted, it will be returned in form of an OpenPgpMessage, which represents the decrypted message + metadata.
See Also: