Package pgp.cert_d

Class PGPCertificateDirectory

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Iterator<java.lang.String> fingerprints()
      Get the fingerprints of all certificates in the directory, except for certificates which are stored by special name.
      pgp.certificate_store.certificate.Certificate getByFingerprint​(java.lang.String fingerprint)
      Get the certificate identified by the given fingerprint.
      pgp.certificate_store.certificate.Certificate getByFingerprintIfChanged​(java.lang.String fingerprint, long tag)
      Get the certificate identified by the given fingerprint if it has changed.
      pgp.certificate_store.certificate.Certificate getBySpecialName​(java.lang.String specialName)
      Get the certificate identified by the given special name.
      pgp.certificate_store.certificate.Certificate getBySpecialNameIfChanged​(java.lang.String specialName, long tag)
      Get the certificate identified by the given special name or null, if it has not been changed.
      java.util.Set<java.lang.String> getCertificateFingerprintsForSubkeyId​(long subkeyId)
      Lookup the fingerprint of the certificate that contains the given subkey.
      pgp.certificate_store.certificate.KeyMaterial getTrustRoot()
      Return the certificate or key identified by the special name
      pgp.certificate_store.certificate.Certificate getTrustRootCertificate()
      Get the trust-root certificate.
      pgp.certificate_store.certificate.Certificate getTrustRootCertificateIfChanged​(long tag)
      Get the trust-root certificate if it has changed.
      pgp.certificate_store.certificate.Certificate insert​(java.io.InputStream data, pgp.certificate_store.certificate.KeyMaterialMerger merge)
      Insert a certificate identified by its fingerprint.
      pgp.certificate_store.certificate.KeyMaterial insertTrustRoot​(java.io.InputStream data, pgp.certificate_store.certificate.KeyMaterialMerger merge)
      Insert a key or certificate under the special name
      pgp.certificate_store.certificate.Certificate insertWithSpecialName​(java.lang.String specialName, java.io.InputStream data, pgp.certificate_store.certificate.KeyMaterialMerger merge)
      Insert a certificate or key under the given special name.
      java.util.Iterator<pgp.certificate_store.certificate.Certificate> items()
      Get all certificates in the directory, except for certificates which are stored by special name.
      void storeCertificateSubkeyIds​(java.lang.String certificate, java.util.List<java.lang.Long> subkeyIds)
      Record, which certificate the subkey-ids in the list belong to.
      pgp.certificate_store.certificate.Certificate tryInsert​(java.io.InputStream data, pgp.certificate_store.certificate.KeyMaterialMerger merge)
      Insert a certificate identified by its fingerprint.
      pgp.certificate_store.certificate.KeyMaterial tryInsertTrustRoot​(java.io.InputStream data, pgp.certificate_store.certificate.KeyMaterialMerger merge)
      Insert a key or certificate under the special name
      pgp.certificate_store.certificate.Certificate tryInsertWithSpecialName​(java.lang.String specialName, java.io.InputStream data, pgp.certificate_store.certificate.KeyMaterialMerger merge)
      Insert a certificate or key under the given special name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PGPCertificateDirectory

        public PGPCertificateDirectory​(PGPCertificateDirectory.Backend backend,
                                       SubkeyLookup subkeyLookup)
        Constructor for a PGP certificate directory.
        Parameters:
        backend - storage backend
        subkeyLookup - subkey lookup mechanism to map subkey-ids to certificates
    • Method Detail

      • getByFingerprint

        public pgp.certificate_store.certificate.Certificate getByFingerprint​(java.lang.String fingerprint)
                                                                       throws pgp.certificate_store.exception.BadDataException,
                                                                              pgp.certificate_store.exception.BadNameException,
                                                                              java.io.IOException
        Description copied from interface: ReadOnlyPGPCertificateDirectory
        Get the certificate identified by the given fingerprint.
        Specified by:
        getByFingerprint in interface ReadOnlyPGPCertificateDirectory
        Parameters:
        fingerprint - lower-case fingerprint of the certificate
        Returns:
        certificate
        Throws:
        pgp.certificate_store.exception.BadDataException - if the certificate contains bad data
        pgp.certificate_store.exception.BadNameException - if the fingerprint is malformed
        java.io.IOException - in case of an IO error
      • getByFingerprintIfChanged

        public pgp.certificate_store.certificate.Certificate getByFingerprintIfChanged​(java.lang.String fingerprint,
                                                                                       long tag)
                                                                                throws java.io.IOException,
                                                                                       pgp.certificate_store.exception.BadNameException,
                                                                                       pgp.certificate_store.exception.BadDataException
        Description copied from interface: ReadOnlyPGPCertificateDirectory
        Get the certificate identified by the given fingerprint if it has changed. This method uses the
        tag
        to calculate, if the certificate might have changed. If the computed tag equals the given tag, the certificate has not changed, so
        null
        is returned. Otherwise, the changed certificate is returned.
        Specified by:
        getByFingerprintIfChanged in interface ReadOnlyPGPCertificateDirectory
        Parameters:
        fingerprint - lower-case fingerprint of the certificate
        tag - tag
        Returns:
        certificate or null if the certificate has not been changed
        Throws:
        java.io.IOException - in case of an IO error
        pgp.certificate_store.exception.BadNameException - if the fingerprint is malformed
        pgp.certificate_store.exception.BadDataException - if the certificate contains bad data
      • getBySpecialName

        public pgp.certificate_store.certificate.Certificate getBySpecialName​(java.lang.String specialName)
                                                                       throws pgp.certificate_store.exception.BadNameException,
                                                                              pgp.certificate_store.exception.BadDataException,
                                                                              java.io.IOException
        Description copied from interface: ReadOnlyPGPCertificateDirectory
        Get the certificate identified by the given special name.
        Specified by:
        getBySpecialName in interface ReadOnlyPGPCertificateDirectory
        Parameters:
        specialName - special name
        Returns:
        certificate
        Throws:
        pgp.certificate_store.exception.BadNameException - if the special name is not known
        pgp.certificate_store.exception.BadDataException - if the certificate contains bad data
        java.io.IOException - in case of an IO error
      • getBySpecialNameIfChanged

        public pgp.certificate_store.certificate.Certificate getBySpecialNameIfChanged​(java.lang.String specialName,
                                                                                       long tag)
                                                                                throws java.io.IOException,
                                                                                       pgp.certificate_store.exception.BadNameException,
                                                                                       pgp.certificate_store.exception.BadDataException
        Description copied from interface: ReadOnlyPGPCertificateDirectory
        Get the certificate identified by the given special name or null, if it has not been changed. This method uses the
        tag
        to calculate, if the certificate might have changed. If the computed tag equals the given tag, the certificate has not changed, so
        null
        is returned. Otherwise, the changed certificate is returned.
        Specified by:
        getBySpecialNameIfChanged in interface ReadOnlyPGPCertificateDirectory
        Parameters:
        specialName - special name
        tag - tag
        Returns:
        certificate or null
        Throws:
        java.io.IOException - in case of an IO error
        pgp.certificate_store.exception.BadNameException - if the special name is not known
        pgp.certificate_store.exception.BadDataException - if the certificate contains bad data
      • getTrustRootCertificate

        public pgp.certificate_store.certificate.Certificate getTrustRootCertificate()
                                                                              throws java.io.IOException,
                                                                                     pgp.certificate_store.exception.BadDataException
        Description copied from interface: ReadOnlyPGPCertificateDirectory
        Get the trust-root certificate. This is a certificate which is stored under the special name
        trust-root
        .
        Specified by:
        getTrustRootCertificate in interface ReadOnlyPGPCertificateDirectory
        Returns:
        trust-root certificate
        Throws:
        java.io.IOException - in case of an IO error
        pgp.certificate_store.exception.BadDataException - if the certificate contains bad data
      • getTrustRootCertificateIfChanged

        public pgp.certificate_store.certificate.Certificate getTrustRootCertificateIfChanged​(long tag)
                                                                                       throws java.io.IOException,
                                                                                              pgp.certificate_store.exception.BadDataException
        Description copied from interface: ReadOnlyPGPCertificateDirectory
        Get the trust-root certificate if it has changed. This method uses the
        tag
        to calculate if the certificate might have changed. If the computed tag equals the given tag, the certificate has not changed, so
        null
        is returned. Otherwise. the changed certificate is returned.
        Specified by:
        getTrustRootCertificateIfChanged in interface ReadOnlyPGPCertificateDirectory
        Parameters:
        tag - tag
        Returns:
        changed certificate, or null if the certificate is unchanged.
        Throws:
        java.io.IOException - in case of an IO error
        pgp.certificate_store.exception.BadDataException - if the certificate contains bad data
      • items

        public java.util.Iterator<pgp.certificate_store.certificate.Certificate> items()
        Description copied from interface: ReadOnlyPGPCertificateDirectory
        Get all certificates in the directory, except for certificates which are stored by special name.
        Specified by:
        items in interface ReadOnlyPGPCertificateDirectory
        Returns:
        iterator of certificates
      • getTrustRoot

        public pgp.certificate_store.certificate.KeyMaterial getTrustRoot()
                                                                   throws java.io.IOException,
                                                                          pgp.certificate_store.exception.BadDataException
        Description copied from interface: WritingPGPCertificateDirectory
        Return the certificate or key identified by the special name
        trust-root
        .
        Specified by:
        getTrustRoot in interface WritingPGPCertificateDirectory
        Returns:
        trust-root key or certificate
        Throws:
        java.io.IOException - in case of an IO error
        pgp.certificate_store.exception.BadDataException - if the certificate contains bad data
      • insertTrustRoot

        public pgp.certificate_store.certificate.KeyMaterial insertTrustRoot​(java.io.InputStream data,
                                                                             pgp.certificate_store.certificate.KeyMaterialMerger merge)
                                                                      throws java.io.IOException,
                                                                             pgp.certificate_store.exception.BadDataException,
                                                                             java.lang.InterruptedException
        Description copied from interface: WritingPGPCertificateDirectory
        Insert a key or certificate under the special name
        trust-root
        . This method blocks until the key material has been written.
        Specified by:
        insertTrustRoot in interface WritingPGPCertificateDirectory
        Parameters:
        data - input stream containing the key or certificate
        merge - key material merger to merge the key or certificate with existing key material
        Returns:
        the merged or inserted key or certificate
        Throws:
        java.io.IOException - in case of an IO error
        pgp.certificate_store.exception.BadDataException - if the data stream or the existing trust-root key material contains bad data
        java.lang.InterruptedException - if the thread is interrupted
      • tryInsertTrustRoot

        public pgp.certificate_store.certificate.KeyMaterial tryInsertTrustRoot​(java.io.InputStream data,
                                                                                pgp.certificate_store.certificate.KeyMaterialMerger merge)
                                                                         throws java.io.IOException,
                                                                                pgp.certificate_store.exception.BadDataException
        Description copied from interface: WritingPGPCertificateDirectory
        Insert a key or certificate under the special name
        trust-root
        . Contrary to WritingPGPCertificateDirectory.insertTrustRoot(InputStream, KeyMaterialMerger), this method does not block. Instead, it returns null if the write-lock cannot be obtained.
        Specified by:
        tryInsertTrustRoot in interface WritingPGPCertificateDirectory
        Parameters:
        data - input stream containing the key or certificate
        merge - key material merger to merge the key or certificate with existing key material
        Returns:
        the merged or inserted key or certificate, or null if the write-lock cannot be obtained
        Throws:
        java.io.IOException - in case of an IO error
        pgp.certificate_store.exception.BadDataException - if the thread is interrupted
      • insert

        public pgp.certificate_store.certificate.Certificate insert​(java.io.InputStream data,
                                                                    pgp.certificate_store.certificate.KeyMaterialMerger merge)
                                                             throws java.io.IOException,
                                                                    pgp.certificate_store.exception.BadDataException,
                                                                    java.lang.InterruptedException
        Description copied from interface: WritingPGPCertificateDirectory
        Insert a certificate identified by its fingerprint. This method blocks until the certificate has been written.
        Specified by:
        insert in interface WritingPGPCertificateDirectory
        Parameters:
        data - input stream containing the certificate data
        merge - merge callback to merge the certificate with existing certificate material
        Returns:
        the merged or inserted certificate
        Throws:
        java.io.IOException - in case of an IO error
        pgp.certificate_store.exception.BadDataException - if the data stream or existing certificate contains bad data
        java.lang.InterruptedException - if the thread is interrupted
      • tryInsert

        public pgp.certificate_store.certificate.Certificate tryInsert​(java.io.InputStream data,
                                                                       pgp.certificate_store.certificate.KeyMaterialMerger merge)
                                                                throws java.io.IOException,
                                                                       pgp.certificate_store.exception.BadDataException
        Description copied from interface: WritingPGPCertificateDirectory
        Insert a certificate identified by its fingerprint. Contrary to WritingPGPCertificateDirectory.insert(InputStream, KeyMaterialMerger), this method does not block. Instead, it returns null if the write-lock cannot be obtained.
        Specified by:
        tryInsert in interface WritingPGPCertificateDirectory
        Parameters:
        data - input stream containing the certificate data
        merge - merge callback to merge the certificate with existing certificate material
        Returns:
        the merged or inserted certificate
        Throws:
        java.io.IOException - in case of an IO error
        pgp.certificate_store.exception.BadDataException - if the data stream or existing certificate contains bad data
      • insertWithSpecialName

        public pgp.certificate_store.certificate.Certificate insertWithSpecialName​(java.lang.String specialName,
                                                                                   java.io.InputStream data,
                                                                                   pgp.certificate_store.certificate.KeyMaterialMerger merge)
                                                                            throws java.io.IOException,
                                                                                   pgp.certificate_store.exception.BadDataException,
                                                                                   pgp.certificate_store.exception.BadNameException,
                                                                                   java.lang.InterruptedException
        Description copied from interface: WritingPGPCertificateDirectory
        Insert a certificate or key under the given special name. This method blocks until the certificate/key has been written.
        Specified by:
        insertWithSpecialName in interface WritingPGPCertificateDirectory
        Parameters:
        specialName - special name under which the key material shall be inserted
        data - input stream containing the key/certificate data
        merge - callback to merge the key/certificate with existing key material
        Returns:
        certificate component of the merged or inserted key material data
        Throws:
        java.io.IOException - in case of an IO error
        pgp.certificate_store.exception.BadDataException - if the data stream or the existing certificate contains bad data
        pgp.certificate_store.exception.BadNameException - if the special name is not known
        java.lang.InterruptedException - if the thread is interrupted
      • tryInsertWithSpecialName

        public pgp.certificate_store.certificate.Certificate tryInsertWithSpecialName​(java.lang.String specialName,
                                                                                      java.io.InputStream data,
                                                                                      pgp.certificate_store.certificate.KeyMaterialMerger merge)
                                                                               throws java.io.IOException,
                                                                                      pgp.certificate_store.exception.BadDataException,
                                                                                      pgp.certificate_store.exception.BadNameException
        Description copied from interface: WritingPGPCertificateDirectory
        Insert a certificate or key under the given special name. Contrary to WritingPGPCertificateDirectory.insertWithSpecialName(String, InputStream, KeyMaterialMerger), this method does not block. Instead, it returns null if the write-lock cannot be obtained.
        Specified by:
        tryInsertWithSpecialName in interface WritingPGPCertificateDirectory
        Parameters:
        specialName - special name under which the key material shall be inserted
        data - input stream containing the key material
        merge - callback to merge the key/certificate with existing key material
        Returns:
        certificate component of the merged or inserted key material
        Throws:
        java.io.IOException - in case of an IO error
        pgp.certificate_store.exception.BadDataException - if the data stream or existing key material contains bad data
        pgp.certificate_store.exception.BadNameException - if the special name is not known
      • getCertificateFingerprintsForSubkeyId

        public java.util.Set<java.lang.String> getCertificateFingerprintsForSubkeyId​(long subkeyId)
                                                                              throws java.io.IOException
        Description copied from interface: SubkeyLookup
        Lookup the fingerprint of the certificate that contains the given subkey. If no record is found, return null.
        Specified by:
        getCertificateFingerprintsForSubkeyId in interface SubkeyLookup
        Parameters:
        subkeyId - subkey id
        Returns:
        fingerprint of the certificate
        Throws:
        java.io.IOException - in case of an IO error
      • storeCertificateSubkeyIds

        public void storeCertificateSubkeyIds​(java.lang.String certificate,
                                              java.util.List<java.lang.Long> subkeyIds)
                                       throws java.io.IOException
        Description copied from interface: SubkeyLookup
        Record, which certificate the subkey-ids in the list belong to. This method does not change the affiliation of subkey-ids not contained in the provided list.
        Specified by:
        storeCertificateSubkeyIds in interface SubkeyLookup
        Parameters:
        certificate - certificate fingerprint
        subkeyIds - subkey ids
        Throws:
        java.io.IOException - in case of an IO error