Class FileBasedOpenPgpKeyStore

  • All Implemented Interfaces:
    OpenPgpKeyStore

    public class FileBasedOpenPgpKeyStore
    extends AbstractOpenPgpKeyStore
    This class is an implementation of the OpenPgpKeyStore, which stores keys in a file structure. The keys are stored in the following directory structure:
     
     <basePath>/
         <userjid@server.tld>/
             pubring.pkr      // public keys of the user/contact
             secring.pkr      // secret keys of the user
             fetchDates.list  // date of the last time we fetched the users keys
     
     
    • Method Detail

      • writePublicKeysOf

        public void writePublicKeysOf​(BareJid owner,
                                      org.bouncycastle.openpgp.PGPPublicKeyRingCollection publicKeys)
                               throws java.io.IOException
        Description copied from class: AbstractOpenPgpKeyStore
        Write the PGPPublicKeyRingCollection of a user to local storage.
        Specified by:
        writePublicKeysOf in class AbstractOpenPgpKeyStore
        Parameters:
        owner - owner of the keys
        publicKeys - keys
        Throws:
        java.io.IOException - IO is dangerous
      • writeSecretKeysOf

        public void writeSecretKeysOf​(BareJid owner,
                                      org.bouncycastle.openpgp.PGPSecretKeyRingCollection secretKeys)
                               throws java.io.IOException
        Description copied from class: AbstractOpenPgpKeyStore
        Write the PGPSecretKeyRingCollection of a user to local storage.
        Specified by:
        writeSecretKeysOf in class AbstractOpenPgpKeyStore
        Parameters:
        owner - owner of the keys
        secretKeys - secret keys
        Throws:
        java.io.IOException - IO is dangerous
      • readPublicKeysOf

        public org.bouncycastle.openpgp.PGPPublicKeyRingCollection readPublicKeysOf​(BareJid owner)
                                                                             throws java.io.IOException,
                                                                                    org.bouncycastle.openpgp.PGPException
        Description copied from class: AbstractOpenPgpKeyStore
        Read a PGPPublicKeyRingCollection from local storage. This method returns null, if no keys were found.
        Specified by:
        readPublicKeysOf in class AbstractOpenPgpKeyStore
        Parameters:
        owner - owner of the keys
        Returns:
        public keys
        Throws:
        java.io.IOException - IO is dangerous
        org.bouncycastle.openpgp.PGPException - PGP is brittle
      • readSecretKeysOf

        public org.bouncycastle.openpgp.PGPSecretKeyRingCollection readSecretKeysOf​(BareJid owner)
                                                                             throws java.io.IOException,
                                                                                    org.bouncycastle.openpgp.PGPException
        Description copied from class: AbstractOpenPgpKeyStore
        Read a PGPSecretKeyRingCollection from local storage. This method returns null, if no keys were found.
        Specified by:
        readSecretKeysOf in class AbstractOpenPgpKeyStore
        Parameters:
        owner - owner of the keys
        Returns:
        secret keys
        Throws:
        java.io.IOException - IO is dangerous
        org.bouncycastle.openpgp.PGPException - PGP is brittle
      • readKeyFetchDates

        protected java.util.Map<org.pgpainless.key.OpenPgpV4Fingerprint,​java.util.Date> readKeyFetchDates​(BareJid owner)
                                                                                                         throws java.io.IOException
        Description copied from class: AbstractOpenPgpKeyStore
        Read the key fetch dates for a users keys from local storage.
        Specified by:
        readKeyFetchDates in class AbstractOpenPgpKeyStore
        Parameters:
        owner - owner
        Returns:
        fetch dates for the owners keys
        Throws:
        java.io.IOException - IO is dangerous
      • writeKeyFetchDates

        protected void writeKeyFetchDates​(BareJid owner,
                                          java.util.Map<org.pgpainless.key.OpenPgpV4Fingerprint,​java.util.Date> dates)
                                   throws java.io.IOException
        Description copied from class: AbstractOpenPgpKeyStore
        Write the key fetch dates for a users keys to local storage.
        Specified by:
        writeKeyFetchDates in class AbstractOpenPgpKeyStore
        Parameters:
        owner - owner
        dates - fetch dates for the owners keys
        Throws:
        java.io.IOException - IO is dangerous