Package pgp.cert_d.backend
Class FileBasedCertificateDirectoryBackend
- java.lang.Object
-
- pgp.cert_d.backend.FileBasedCertificateDirectoryBackend
-
- All Implemented Interfaces:
PGPCertificateDirectory.Backend
public class FileBasedCertificateDirectoryBackend extends java.lang.Object implements PGPCertificateDirectory.Backend
Implementation ofPGPCertificateDirectory.Backendwhich stores certificates in a directory structure.- See Also:
- Shared PGP Certificate Directory
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFileBasedCertificateDirectoryBackend.FilenameResolverClass to resolve file names from certificate fingerprints / special names.
-
Constructor Summary
Constructors Constructor Description FileBasedCertificateDirectoryBackend(java.io.File baseDirectory, pgp.certificate_store.certificate.KeyMaterialReaderBackend reader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description pgp.certificate_store.certificate.CertificatedoInsert(java.io.InputStream data, pgp.certificate_store.certificate.KeyMaterialMerger merge)Insert aCertificateidentified by its fingerprint into the directory.pgp.certificate_store.certificate.KeyMaterialdoInsertTrustRoot(java.io.InputStream data, pgp.certificate_store.certificate.KeyMaterialMerger merge)Insert aKeyorCertificateas trust-root.pgp.certificate_store.certificate.CertificatedoInsertWithSpecialName(java.lang.String specialName, java.io.InputStream data, pgp.certificate_store.certificate.KeyMaterialMerger merge)Insert aKeyorCertificateunder the given special name.PGPCertificateDirectory.LockingMechanismgetLock()Get the locking mechanism to write-lock the backend.java.lang.LonggetTagForFingerprint(java.lang.String fingerprint)Calculate the tag of the certificate with the given fingerprint.java.lang.LonggetTagForSpecialName(java.lang.String specialName)Calculate the tag of the certificate identified by the given special name.pgp.certificate_store.certificate.CertificatereadByFingerprint(java.lang.String fingerprint)Read aCertificateby its OpenPGP fingerprint.pgp.certificate_store.certificate.KeyMaterialreadBySpecialName(java.lang.String specialName)Read aCertificateorKeyby the given special name.java.util.Iterator<pgp.certificate_store.certificate.Certificate>readItems()Return anIteratorof allCertificatesin the store, except for certificates stored under a special name.
-
-
-
Constructor Detail
-
FileBasedCertificateDirectoryBackend
public FileBasedCertificateDirectoryBackend(java.io.File baseDirectory, pgp.certificate_store.certificate.KeyMaterialReaderBackend reader) throws pgp.certificate_store.exception.NotAStoreException- Throws:
pgp.certificate_store.exception.NotAStoreException
-
-
Method Detail
-
getLock
public PGPCertificateDirectory.LockingMechanism getLock()
Description copied from interface:PGPCertificateDirectory.BackendGet the locking mechanism to write-lock the backend.- Specified by:
getLockin interfacePGPCertificateDirectory.Backend- Returns:
- lock
-
readByFingerprint
public pgp.certificate_store.certificate.Certificate readByFingerprint(java.lang.String fingerprint) throws pgp.certificate_store.exception.BadNameException, java.io.IOException, pgp.certificate_store.exception.BadDataExceptionDescription copied from interface:PGPCertificateDirectory.BackendRead aCertificateby its OpenPGP fingerprint.- Specified by:
readByFingerprintin interfacePGPCertificateDirectory.Backend- Parameters:
fingerprint- fingerprint- Returns:
- certificate
- Throws:
pgp.certificate_store.exception.BadNameException- if the fingerprint is malformedjava.io.IOException- in case of an IO errorpgp.certificate_store.exception.BadDataException- if the certificate contains bad data
-
readBySpecialName
public pgp.certificate_store.certificate.KeyMaterial readBySpecialName(java.lang.String specialName) throws pgp.certificate_store.exception.BadNameException, java.io.IOException, pgp.certificate_store.exception.BadDataExceptionDescription copied from interface:PGPCertificateDirectory.BackendRead aCertificateorKeyby the given special name.- Specified by:
readBySpecialNamein interfacePGPCertificateDirectory.Backend- Parameters:
specialName- special name- Returns:
- certificate or key
- Throws:
pgp.certificate_store.exception.BadNameException- if the special name is not knownjava.io.IOException- in case of an IO errorpgp.certificate_store.exception.BadDataException- if the certificate contains bad data
-
readItems
public java.util.Iterator<pgp.certificate_store.certificate.Certificate> readItems()
Description copied from interface:PGPCertificateDirectory.BackendReturn anIteratorof allCertificatesin the store, except for certificates stored under a special name.- Specified by:
readItemsin interfacePGPCertificateDirectory.Backend- Returns:
- iterator
-
doInsertTrustRoot
public pgp.certificate_store.certificate.KeyMaterial doInsertTrustRoot(java.io.InputStream data, pgp.certificate_store.certificate.KeyMaterialMerger merge) throws pgp.certificate_store.exception.BadDataException, java.io.IOExceptionDescription copied from interface:PGPCertificateDirectory.BackendInsert aKeyorCertificateas trust-root.- Specified by:
doInsertTrustRootin interfacePGPCertificateDirectory.Backend- Parameters:
data- input stream containing the key materialmerge- callback to merge the key material with existing key material- Returns:
- merged or inserted key material
- Throws:
pgp.certificate_store.exception.BadDataException- if the data stream or existing key material contains bad datajava.io.IOException- in case of an IO error
-
doInsert
public pgp.certificate_store.certificate.Certificate doInsert(java.io.InputStream data, pgp.certificate_store.certificate.KeyMaterialMerger merge) throws java.io.IOException, pgp.certificate_store.exception.BadDataExceptionDescription copied from interface:PGPCertificateDirectory.BackendInsert aCertificateidentified by its fingerprint into the directory.- Specified by:
doInsertin interfacePGPCertificateDirectory.Backend- Parameters:
data- input stream containing the certificate datamerge- callback to merge the certificate with existing key material- Returns:
- merged or inserted certificate
- Throws:
java.io.IOException- in case of an IO errorpgp.certificate_store.exception.BadDataException- if the data stream or existing certificate contains bad data
-
doInsertWithSpecialName
public pgp.certificate_store.certificate.Certificate doInsertWithSpecialName(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.BadNameExceptionDescription copied from interface:PGPCertificateDirectory.BackendInsert aKeyorCertificateunder the given special name.- Specified by:
doInsertWithSpecialNamein interfacePGPCertificateDirectory.Backend- Parameters:
specialName- special name to identify the key material withdata- data stream containing the key or certificatemerge- 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 errorpgp.certificate_store.exception.BadDataException- if the data stream or existing key material contains bad datapgp.certificate_store.exception.BadNameException- if the special name is not known
-
getTagForFingerprint
public java.lang.Long getTagForFingerprint(java.lang.String fingerprint) throws pgp.certificate_store.exception.BadNameException, java.io.IOExceptionDescription copied from interface:PGPCertificateDirectory.BackendCalculate the tag of the certificate with the given fingerprint.- Specified by:
getTagForFingerprintin interfacePGPCertificateDirectory.Backend- Parameters:
fingerprint- fingerprint- Returns:
- tag
- Throws:
pgp.certificate_store.exception.BadNameException- if the fingerprint is malformedjava.io.IOException- in case of an IO error
-
getTagForSpecialName
public java.lang.Long getTagForSpecialName(java.lang.String specialName) throws pgp.certificate_store.exception.BadNameException, java.io.IOExceptionDescription copied from interface:PGPCertificateDirectory.BackendCalculate the tag of the certificate identified by the given special name.- Specified by:
getTagForSpecialNamein interfacePGPCertificateDirectory.Backend- Parameters:
specialName- special name- Returns:
- tag
- Throws:
pgp.certificate_store.exception.BadNameException- if the special name is not knownjava.io.IOException- in case of an IO error
-
-