mirror of
https://codeberg.org/PGPainless/cert-d-java.git
synced 2025-09-10 03:39:40 +02:00
Add tests for PGPCertificateStoreAdapter
This commit is contained in:
parent
dee2ea88a7
commit
f34c6d7735
6 changed files with 295 additions and 148 deletions
|
@ -16,6 +16,7 @@ import java.io.InputStream;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Implementation of the Shared PGP Certificate Directory.
|
||||
|
@ -27,6 +28,7 @@ public class PGPCertificateDirectory
|
|||
|
||||
final Backend backend;
|
||||
final SubkeyLookup subkeyLookup;
|
||||
private final Pattern openPgpV4FingerprintPattern = Pattern.compile("^[a-f0-9]{40}$");
|
||||
|
||||
/**
|
||||
* Constructor for a PGP certificate directory.
|
||||
|
@ -41,6 +43,9 @@ public class PGPCertificateDirectory
|
|||
|
||||
@Override
|
||||
public Certificate getByFingerprint(String fingerprint) throws BadDataException, BadNameException, IOException {
|
||||
if (!openPgpV4FingerprintPattern.matcher(fingerprint).matches()) {
|
||||
throw new BadNameException();
|
||||
}
|
||||
return backend.readByFingerprint(fingerprint);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue