From 4eb82c819bb2dac758a8f9253781dda4bbe78228 Mon Sep 17 00:00:00 2001 From: "Andy Miller (IMS)" <48326098+amiller-ims@users.noreply.github.com> Date: Thu, 10 Nov 2022 14:16:27 -0800 Subject: [PATCH] Use URI methods --- .../inspect/vc/probe/EmbeddedProofProbe.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/EmbeddedProofProbe.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/EmbeddedProofProbe.java index 81ab97a..66ca945 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/EmbeddedProofProbe.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/probe/EmbeddedProofProbe.java @@ -58,21 +58,22 @@ public class EmbeddedProofProbe extends Probe { // TODO fourth format that we don't support yet: a URL that returns a Ed25519VerificationKey2020 // if starts with http and does not have hashcode, try fetch and see if returns Ed25519VerificationKey2020 // property is publicKeyMultibase + + publicKeyMultibase = method.toString(); - if (method.toString().contains("#")) { - publicKeyMultibase = method.getFragment(); - } else { - if (method.toString().startsWith("did")) { - String didScheme = method.getSchemeSpecificPart(); - if (didScheme.startsWith("key:")) { - publicKeyMultibase = didScheme.substring(4); - } else { - return error("Unknown verification method: " + method.toString(), ctx); - } - } else { - publicKeyMultibase = method.toString(); - } - } + if (method.getFragment() != null) { + publicKeyMultibase = method.getFragment(); + } else { + if (method.getScheme().equals("did")) { + if (method.getSchemeSpecificPart().startsWith("key:")) { + publicKeyMultibase = method.getSchemeSpecificPart().substring(4); + } else { + return error("Unknown verification method: " + method, ctx); + } + } else if (method.getScheme().equals("http") || method.getScheme().equals("https")) { + return error("Cannot parse http verification key yet", ctx); + } + } // Decode the Multibase to Multicodec and check that it is an Ed25519 public key // https://w3c-ccg.github.io/di-eddsa-2020/#ed25519verificationkey2020