Add support for fetching policy objects

This commit is contained in:
Paul Schaub 2022-03-21 16:03:11 +01:00
parent cb996733fb
commit d7cddf26bb
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
9 changed files with 318 additions and 22 deletions

View file

@ -10,6 +10,7 @@ import pgp.wkd.discovery.CertificateFetcher;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
@ -26,6 +27,15 @@ public class DirectoryBasedCertificateFetcher implements CertificateFetcher {
@Override
public InputStream fetchCertificate(WKDAddress address, DiscoveryMethod method) throws IOException {
return inputStreamFromFile(address, method);
}
@Override
public InputStream fetchPolicy(WKDAddress address, DiscoveryMethod method) throws IOException {
return inputStreamFromFile(address, method);
}
private InputStream inputStreamFromFile(WKDAddress address, DiscoveryMethod method) throws FileNotFoundException {
URI uri = address.getUri(method);
String path = uri.getPath().substring(1); // get rid of leading slash at start of path
File file = rootPath.resolve(path).toFile();