mirror of
https://codeberg.org/PGPainless/cert-d-java.git
synced 2024-11-05 08:35:58 +01:00
Rename MergeCallback to CertificateMerger
This commit is contained in:
parent
dd2877ccee
commit
96b22ff40a
6 changed files with 30 additions and 30 deletions
|
@ -5,12 +5,12 @@
|
||||||
package pgp.cert_d;
|
package pgp.cert_d;
|
||||||
|
|
||||||
import pgp.certificate_store.CertificateReaderBackend;
|
import pgp.certificate_store.CertificateReaderBackend;
|
||||||
import pgp.certificate_store.MergeCallback;
|
import pgp.certificate_store.CertificateMerger;
|
||||||
|
|
||||||
public abstract class BackendProvider {
|
public abstract class BackendProvider {
|
||||||
|
|
||||||
public abstract CertificateReaderBackend provideCertificateReaderBackend();
|
public abstract CertificateReaderBackend provideCertificateReaderBackend();
|
||||||
|
|
||||||
public abstract MergeCallback provideDefaultMergeCallback();
|
public abstract CertificateMerger provideDefaultMergeCallback();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ package pgp.cert_d;
|
||||||
import pgp.certificate_store.exception.BadDataException;
|
import pgp.certificate_store.exception.BadDataException;
|
||||||
import pgp.certificate_store.exception.BadNameException;
|
import pgp.certificate_store.exception.BadNameException;
|
||||||
import pgp.certificate_store.Certificate;
|
import pgp.certificate_store.Certificate;
|
||||||
import pgp.certificate_store.MergeCallback;
|
import pgp.certificate_store.CertificateMerger;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -127,7 +127,7 @@ public class CachingSharedPGPCertificateDirectoryWrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Certificate insert(InputStream data, MergeCallback merge)
|
public Certificate insert(InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadDataException, InterruptedException {
|
throws IOException, BadDataException, InterruptedException {
|
||||||
Certificate certificate = underlyingCertificateDirectory.insert(data, merge);
|
Certificate certificate = underlyingCertificateDirectory.insert(data, merge);
|
||||||
remember(certificate.getFingerprint(), certificate);
|
remember(certificate.getFingerprint(), certificate);
|
||||||
|
@ -135,7 +135,7 @@ public class CachingSharedPGPCertificateDirectoryWrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Certificate tryInsert(InputStream data, MergeCallback merge)
|
public Certificate tryInsert(InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadDataException {
|
throws IOException, BadDataException {
|
||||||
Certificate certificate = underlyingCertificateDirectory.tryInsert(data, merge);
|
Certificate certificate = underlyingCertificateDirectory.tryInsert(data, merge);
|
||||||
if (certificate != null) {
|
if (certificate != null) {
|
||||||
|
@ -145,7 +145,7 @@ public class CachingSharedPGPCertificateDirectoryWrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Certificate insertWithSpecialName(String specialName, InputStream data, MergeCallback merge)
|
public Certificate insertWithSpecialName(String specialName, InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadDataException, BadNameException, InterruptedException {
|
throws IOException, BadDataException, BadNameException, InterruptedException {
|
||||||
Certificate certificate = underlyingCertificateDirectory.insertWithSpecialName(specialName, data, merge);
|
Certificate certificate = underlyingCertificateDirectory.insertWithSpecialName(specialName, data, merge);
|
||||||
remember(specialName, certificate);
|
remember(specialName, certificate);
|
||||||
|
@ -153,7 +153,7 @@ public class CachingSharedPGPCertificateDirectoryWrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Certificate tryInsertWithSpecialName(String specialName, InputStream data, MergeCallback merge)
|
public Certificate tryInsertWithSpecialName(String specialName, InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadDataException, BadNameException {
|
throws IOException, BadDataException, BadNameException {
|
||||||
Certificate certificate = underlyingCertificateDirectory.tryInsertWithSpecialName(specialName, data, merge);
|
Certificate certificate = underlyingCertificateDirectory.tryInsertWithSpecialName(specialName, data, merge);
|
||||||
if (certificate != null) {
|
if (certificate != null) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.util.Iterator;
|
||||||
import pgp.certificate_store.exception.BadDataException;
|
import pgp.certificate_store.exception.BadDataException;
|
||||||
import pgp.certificate_store.exception.BadNameException;
|
import pgp.certificate_store.exception.BadNameException;
|
||||||
import pgp.certificate_store.Certificate;
|
import pgp.certificate_store.Certificate;
|
||||||
import pgp.certificate_store.MergeCallback;
|
import pgp.certificate_store.CertificateMerger;
|
||||||
|
|
||||||
public interface SharedPGPCertificateDirectory {
|
public interface SharedPGPCertificateDirectory {
|
||||||
|
|
||||||
|
@ -29,16 +29,16 @@ public interface SharedPGPCertificateDirectory {
|
||||||
Certificate getBySpecialNameIfChanged(String specialName, String tag)
|
Certificate getBySpecialNameIfChanged(String specialName, String tag)
|
||||||
throws IOException, BadNameException, BadDataException;
|
throws IOException, BadNameException, BadDataException;
|
||||||
|
|
||||||
Certificate insert(InputStream data, MergeCallback merge)
|
Certificate insert(InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadDataException, InterruptedException;
|
throws IOException, BadDataException, InterruptedException;
|
||||||
|
|
||||||
Certificate tryInsert(InputStream data, MergeCallback merge)
|
Certificate tryInsert(InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadDataException;
|
throws IOException, BadDataException;
|
||||||
|
|
||||||
Certificate insertWithSpecialName(String specialName, InputStream data, MergeCallback merge)
|
Certificate insertWithSpecialName(String specialName, InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadDataException, BadNameException, InterruptedException;
|
throws IOException, BadDataException, BadNameException, InterruptedException;
|
||||||
|
|
||||||
Certificate tryInsertWithSpecialName(String specialName, InputStream data, MergeCallback merge)
|
Certificate tryInsertWithSpecialName(String specialName, InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadDataException, BadNameException;
|
throws IOException, BadDataException, BadNameException;
|
||||||
|
|
||||||
Iterator<Certificate> items();
|
Iterator<Certificate> items();
|
||||||
|
|
|
@ -21,7 +21,7 @@ import pgp.certificate_store.exception.BadNameException;
|
||||||
import pgp.certificate_store.exception.NotAStoreException;
|
import pgp.certificate_store.exception.NotAStoreException;
|
||||||
import pgp.certificate_store.Certificate;
|
import pgp.certificate_store.Certificate;
|
||||||
import pgp.certificate_store.CertificateReaderBackend;
|
import pgp.certificate_store.CertificateReaderBackend;
|
||||||
import pgp.certificate_store.MergeCallback;
|
import pgp.certificate_store.CertificateMerger;
|
||||||
|
|
||||||
public class SharedPGPCertificateDirectoryImpl implements SharedPGPCertificateDirectory {
|
public class SharedPGPCertificateDirectoryImpl implements SharedPGPCertificateDirectory {
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ public class SharedPGPCertificateDirectoryImpl implements SharedPGPCertificateDi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Certificate insert(InputStream data, MergeCallback merge)
|
public Certificate insert(InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadDataException, InterruptedException {
|
throws IOException, BadDataException, InterruptedException {
|
||||||
writeLock.lockDirectory();
|
writeLock.lockDirectory();
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ public class SharedPGPCertificateDirectoryImpl implements SharedPGPCertificateDi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Certificate tryInsert(InputStream data, MergeCallback merge)
|
public Certificate tryInsert(InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadDataException {
|
throws IOException, BadDataException {
|
||||||
if (!writeLock.tryLockDirectory()) {
|
if (!writeLock.tryLockDirectory()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -154,7 +154,7 @@ public class SharedPGPCertificateDirectoryImpl implements SharedPGPCertificateDi
|
||||||
return certificate;
|
return certificate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Certificate _insert(InputStream data, MergeCallback merge)
|
private Certificate _insert(InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadDataException {
|
throws IOException, BadDataException {
|
||||||
Certificate newCertificate = certificateReaderBackend.readCertificate(data);
|
Certificate newCertificate = certificateReaderBackend.readCertificate(data);
|
||||||
Certificate existingCertificate;
|
Certificate existingCertificate;
|
||||||
|
@ -196,7 +196,7 @@ public class SharedPGPCertificateDirectoryImpl implements SharedPGPCertificateDi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Certificate insertWithSpecialName(String specialName, InputStream data, MergeCallback merge)
|
public Certificate insertWithSpecialName(String specialName, InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadNameException, BadDataException, InterruptedException {
|
throws IOException, BadNameException, BadDataException, InterruptedException {
|
||||||
writeLock.lockDirectory();
|
writeLock.lockDirectory();
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ public class SharedPGPCertificateDirectoryImpl implements SharedPGPCertificateDi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Certificate tryInsertWithSpecialName(String specialName, InputStream data, MergeCallback merge)
|
public Certificate tryInsertWithSpecialName(String specialName, InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadNameException, BadDataException {
|
throws IOException, BadNameException, BadDataException {
|
||||||
if (!writeLock.tryLockDirectory()) {
|
if (!writeLock.tryLockDirectory()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -219,7 +219,7 @@ public class SharedPGPCertificateDirectoryImpl implements SharedPGPCertificateDi
|
||||||
return certificate;
|
return certificate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Certificate _insertSpecial(String specialName, InputStream data, MergeCallback merge)
|
private Certificate _insertSpecial(String specialName, InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadNameException, BadDataException {
|
throws IOException, BadNameException, BadDataException {
|
||||||
Certificate newCertificate = certificateReaderBackend.readCertificate(data);
|
Certificate newCertificate = certificateReaderBackend.readCertificate(data);
|
||||||
Certificate existingCertificate = getBySpecialName(specialName);
|
Certificate existingCertificate = getBySpecialName(specialName);
|
||||||
|
|
|
@ -54,12 +54,12 @@ public interface CertificateDirectory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert a certificate into the store.
|
* Insert a certificate into the store.
|
||||||
* If an instance of the certificate is already present in the store, the given {@link MergeCallback} will be
|
* If an instance of the certificate is already present in the store, the given {@link CertificateMerger} will be
|
||||||
* used to merge both the existing and the new instance of the {@link Certificate}. The resulting merged certificate
|
* used to merge both the existing and the new instance of the {@link Certificate}. The resulting merged certificate
|
||||||
* will be stored in the store and returned.
|
* will be stored in the store and returned.
|
||||||
*
|
*
|
||||||
* This method will block until a write-lock on the store can be acquired. If you cannot afford blocking,
|
* This method will block until a write-lock on the store can be acquired. If you cannot afford blocking,
|
||||||
* consider to use {@link #tryInsertCertificate(InputStream, MergeCallback)} instead.
|
* consider to use {@link #tryInsertCertificate(InputStream, CertificateMerger)} instead.
|
||||||
*
|
*
|
||||||
* @param data input stream containing the new certificate instance
|
* @param data input stream containing the new certificate instance
|
||||||
* @param merge callback for merging with an existing certificate instance
|
* @param merge callback for merging with an existing certificate instance
|
||||||
|
@ -69,12 +69,12 @@ public interface CertificateDirectory {
|
||||||
* @throws InterruptedException in case the inserting thread gets interrupted
|
* @throws InterruptedException in case the inserting thread gets interrupted
|
||||||
* @throws BadDataException if the data stream does not contain valid OpenPGP data
|
* @throws BadDataException if the data stream does not contain valid OpenPGP data
|
||||||
*/
|
*/
|
||||||
Certificate insertCertificate(InputStream data, MergeCallback merge)
|
Certificate insertCertificate(InputStream data, CertificateMerger merge)
|
||||||
throws IOException, InterruptedException, BadDataException;
|
throws IOException, InterruptedException, BadDataException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert a certificate into the store.
|
* Insert a certificate into the store.
|
||||||
* If an instance of the certificate is already present in the store, the given {@link MergeCallback} will be
|
* If an instance of the certificate is already present in the store, the given {@link CertificateMerger} will be
|
||||||
* used to merge both the existing and the new instance of the {@link Certificate}. The resulting merged certificate
|
* used to merge both the existing and the new instance of the {@link Certificate}. The resulting merged certificate
|
||||||
* will be stored in the store and returned.
|
* will be stored in the store and returned.
|
||||||
*
|
*
|
||||||
|
@ -90,19 +90,19 @@ public interface CertificateDirectory {
|
||||||
* @throws IOException in case of an IO-error
|
* @throws IOException in case of an IO-error
|
||||||
* @throws BadDataException if the data stream does not contain valid OpenPGP data
|
* @throws BadDataException if the data stream does not contain valid OpenPGP data
|
||||||
*/
|
*/
|
||||||
Certificate tryInsertCertificate(InputStream data, MergeCallback merge)
|
Certificate tryInsertCertificate(InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadDataException;
|
throws IOException, BadDataException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert a certificate into the store.
|
* Insert a certificate into the store.
|
||||||
* The certificate will be stored under the given special name instead of its fingerprint.
|
* 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 {@link MergeCallback} will be
|
* If an instance of the certificate is already present under the special name in the store, the given {@link CertificateMerger} will be
|
||||||
* used to merge both the existing and the new instance of the {@link Certificate}. The resulting merged certificate
|
* used to merge both the existing and the new instance of the {@link Certificate}. The resulting merged certificate
|
||||||
* will be stored in the store and returned.
|
* will be stored in the store and returned.
|
||||||
*
|
*
|
||||||
* This method will block until a write-lock on the store can be acquired. If you cannot afford blocking,
|
* This method will block until a write-lock on the store can be acquired. If you cannot afford blocking,
|
||||||
* consider to use {@link #tryInsertCertificateBySpecialName(String, InputStream, MergeCallback)} instead.
|
* consider to use {@link #tryInsertCertificateBySpecialName(String, InputStream, CertificateMerger)} instead.
|
||||||
*
|
*
|
||||||
* @param specialName special name of the certificate
|
* @param specialName special name of the certificate
|
||||||
* @param data input stream containing the new certificate instance
|
* @param data input stream containing the new certificate instance
|
||||||
|
@ -114,14 +114,14 @@ public interface CertificateDirectory {
|
||||||
* @throws BadDataException if the certificate file does not contain valid OpenPGP data
|
* @throws BadDataException if the certificate file does not contain valid OpenPGP data
|
||||||
* @throws BadNameException if the special name is unknown
|
* @throws BadNameException if the special name is unknown
|
||||||
*/
|
*/
|
||||||
Certificate insertCertificateBySpecialName(String specialName, InputStream data, MergeCallback merge)
|
Certificate insertCertificateBySpecialName(String specialName, InputStream data, CertificateMerger merge)
|
||||||
throws IOException, InterruptedException, BadDataException, BadNameException;
|
throws IOException, InterruptedException, BadDataException, BadNameException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert a certificate into the store.
|
* Insert a certificate into the store.
|
||||||
* The certificate will be stored under the given special name instead of its fingerprint.
|
* 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 {@link MergeCallback} will be
|
* If an instance of the certificate is already present under the special name in the store, the given {@link CertificateMerger} will be
|
||||||
* used to merge both the existing and the new instance of the {@link Certificate}. The resulting merged certificate
|
* used to merge both the existing and the new instance of the {@link Certificate}. The resulting merged certificate
|
||||||
* will be stored in the store and returned.
|
* will be stored in the store and returned.
|
||||||
*
|
*
|
||||||
|
@ -139,7 +139,7 @@ public interface CertificateDirectory {
|
||||||
* @throws BadDataException if the data stream does not contain valid OpenPGP data
|
* @throws BadDataException if the data stream does not contain valid OpenPGP data
|
||||||
* @throws BadNameException if the special name is not known
|
* @throws BadNameException if the special name is not known
|
||||||
*/
|
*/
|
||||||
Certificate tryInsertCertificateBySpecialName(String specialName, InputStream data, MergeCallback merge)
|
Certificate tryInsertCertificateBySpecialName(String specialName, InputStream data, CertificateMerger merge)
|
||||||
throws IOException, BadDataException, BadNameException;
|
throws IOException, BadDataException, BadNameException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.io.IOException;
|
||||||
/**
|
/**
|
||||||
* Merge a given certificate (update) with an existing certificate.
|
* Merge a given certificate (update) with an existing certificate.
|
||||||
*/
|
*/
|
||||||
public interface MergeCallback {
|
public interface CertificateMerger {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge the given certificate data with the existing certificate and return the result.
|
* Merge the given certificate data with the existing certificate and return the result.
|
Loading…
Reference in a new issue