Use URI methods

This commit is contained in:
Andy Miller (IMS) 2022-11-10 14:16:27 -08:00
parent aec2be38bd
commit 4eb82c819b

View File

@ -59,18 +59,19 @@ public class EmbeddedProofProbe extends Probe<Credential> {
// if starts with http and does not have hashcode, try fetch and see if returns Ed25519VerificationKey2020 // if starts with http and does not have hashcode, try fetch and see if returns Ed25519VerificationKey2020
// property is publicKeyMultibase // property is publicKeyMultibase
if (method.toString().contains("#")) { publicKeyMultibase = method.toString();
if (method.getFragment() != null) {
publicKeyMultibase = method.getFragment(); publicKeyMultibase = method.getFragment();
} else { } else {
if (method.toString().startsWith("did")) { if (method.getScheme().equals("did")) {
String didScheme = method.getSchemeSpecificPart(); if (method.getSchemeSpecificPart().startsWith("key:")) {
if (didScheme.startsWith("key:")) { publicKeyMultibase = method.getSchemeSpecificPart().substring(4);
publicKeyMultibase = didScheme.substring(4);
} else { } else {
return error("Unknown verification method: " + method.toString(), ctx); return error("Unknown verification method: " + method, ctx);
} }
} else { } else if (method.getScheme().equals("http") || method.getScheme().equals("https")) {
publicKeyMultibase = method.toString(); return error("Cannot parse http verification key yet", ctx);
} }
} }