Removed duplicated code

This commit is contained in:
Xavi Aracil 2022-11-15 10:14:51 +01:00
parent 347f44e804
commit 2a6b045f0c

View File

@ -47,9 +47,7 @@ public class EmbeddedProofProbe extends Probe<Credential> {
ConfigurableDocumentLoader documentLoader = new ConfigurableDocumentLoader(); ConfigurableDocumentLoader documentLoader = new ConfigurableDocumentLoader();
documentLoader.setEnableHttp(true); documentLoader.setEnableHttp(true);
documentLoader.setEnableHttps(true); documentLoader.setEnableHttps(true);
vc.setDocumentLoader(new CachingDocumentLoader());
vc.setDocumentLoader(documentLoader); vc.setDocumentLoader(documentLoader);
URI method = vc.getLdProof().getVerificationMethod();
LdProof proof = vc.getLdProof(); LdProof proof = vc.getLdProof();
if (proof == null) { if (proof == null) {
@ -93,11 +91,11 @@ public class EmbeddedProofProbe extends Probe<Credential> {
} }
} else if (method.getScheme().equals("http") || method.getScheme().equals("https")) { } else if (method.getScheme().equals("http") || method.getScheme().equals("https")) {
// TODO: Can we use proof.getDocumentLoader()? // TODO: Can we use proof.getDocumentLoader()?
ConfigurableDocumentLoader documentLoader = new ConfigurableDocumentLoader(); ConfigurableDocumentLoader keyDocumentLoader = new ConfigurableDocumentLoader();
documentLoader.setEnableHttp(true); keyDocumentLoader.setEnableHttp(true);
documentLoader.setEnableHttps(true); keyDocumentLoader.setEnableHttps(true);
Document keyDocument = documentLoader.loadDocument(method, new DocumentLoaderOptions()); Document keyDocument = keyDocumentLoader.loadDocument(method, new DocumentLoaderOptions());
Optional<JsonStructure> keyStructure = keyDocument.getJsonContent(); Optional<JsonStructure> keyStructure = keyDocument.getJsonContent();
if (keyStructure.isEmpty()) { if (keyStructure.isEmpty()) {
return error("Key document not found at " + method, ctx); return error("Key document not found at " + method, ctx);