Interface PGPCertificateStore


  • public interface PGPCertificateStore
    Interface for an OpenPGP certificate (public key) store.
    • Method Detail

      • getCertificate

        Certificate getCertificate​(java.lang.String identifier)
                            throws java.io.IOException,
                                   BadNameException,
                                   BadDataException
        Return the certificate that matches the given identifier. If no matching certificate can be found, return null.
        Parameters:
        identifier - identifier for a certificate.
        Returns:
        certificate or null
        Throws:
        java.io.IOException - in case of an IO-error
        BadNameException - if the identifier is invalid
        BadDataException - if the certificate file contains invalid data
      • getCertificateIfChanged

        Certificate getCertificateIfChanged​(java.lang.String identifier,
                                            java.lang.Long tag)
                                     throws java.io.IOException,
                                            BadNameException,
                                            BadDataException
        Return the certificate that matches the given identifier, but only if it has been changed. Whether it has been changed is determined by calculating the tag in the directory (e.g. by looking at the inode and last modification date) and comparing the result with the tag provided by the caller.
        Parameters:
        identifier - certificate identifier
        tag - tag by the caller
        Returns:
        certificate if it has been changed, null otherwise
        Throws:
        java.io.IOException - in case of an IO-error
        BadNameException - if the identifier is invalid
        BadDataException - if the certificate file contains invalid data
      • getCertificatesBySubkeyId

        java.util.Iterator<Certificate> getCertificatesBySubkeyId​(long subkeyId)
                                                           throws java.io.IOException,
                                                                  BadDataException
        Return an Iterator over all certificates in the store that contain a subkey with the given subkey id.
        Parameters:
        subkeyId - id of the subkey
        Returns:
        iterator
        Throws:
        java.io.IOException - in case of an IO error
        BadDataException - if any of the certificate files contains invalid data
      • insertCertificate

        Certificate insertCertificate​(java.io.InputStream data,
                                      KeyMaterialMerger merge)
                               throws java.io.IOException,
                                      java.lang.InterruptedException,
                                      BadDataException
        Insert a certificate into the store. If an instance of the certificate is already present in the store, the given KeyMaterialMerger will be used to merge both the existing and the new instance of the Certificate. The resulting merged certificate will be stored in the store and returned. This method will block until a write-lock on the store can be acquired.
        Parameters:
        data - input stream containing the new certificate instance
        merge - callback for merging with an existing certificate instance
        Returns:
        merged certificate
        Throws:
        java.io.IOException - in case of an IO-error
        java.lang.InterruptedException - in case the inserting thread gets interrupted
        BadDataException - if the data stream does not contain valid OpenPGP data
      • insertCertificateBySpecialName

        Certificate insertCertificateBySpecialName​(java.lang.String specialName,
                                                   java.io.InputStream data,
                                                   KeyMaterialMerger merge)
                                            throws java.io.IOException,
                                                   java.lang.InterruptedException,
                                                   BadDataException,
                                                   BadNameException
        Insert a certificate into the store. The certificate will be stored under the given special name instead of its fingerprint. If an instance of the certificate is already present under the special name in the store, the given KeyMaterialMerger will be used to merge both the existing and the new instance of the Certificate. The resulting merged certificate will be stored in the store and returned. This method will block until a write-lock on the store can be acquired.
        Parameters:
        specialName - special name of the certificate
        data - input stream containing the new certificate instance
        merge - callback for merging with an existing certificate instance
        Returns:
        merged certificate or null if the store cannot be locked
        Throws:
        java.io.IOException - in case of an IO-error
        java.lang.InterruptedException - if the thread is interrupted
        BadDataException - if the certificate file does not contain valid OpenPGP data
        BadNameException - if the special name is unknown
      • getCertificates

        java.util.Iterator<Certificate> getCertificates()
        Return an Iterator containing all certificates in the store. The iterator will contain both certificates addressed by special names and by fingerprints.
        Returns:
        certificates
      • getFingerprints

        java.util.Iterator<java.lang.String> getFingerprints()
        Return an Iterator containing all certificate fingerprints from the store. Note that this only includes the fingerprints of certificate primary keys, not those of subkeys.
        Returns:
        fingerprints