diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java index 76e75d8..9769561 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Assertion.java @@ -148,6 +148,14 @@ public class Assertion extends Credential { public List getValidations() { return validationMap.get(this); } + @Override + public Map> getContextAliases() { + return Collections.emptyMap(); + } + @Override + public Map> getContextVersionPatterns() { + return Collections.emptyMap(); + } } public enum ValueType { diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Credential.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Credential.java index 84e1c9b..d33b3fd 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Credential.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/Credential.java @@ -92,6 +92,8 @@ public abstract class Credential extends GeneratedObject { List getAllowedTypeValues(); boolean isAllowedTypeValuesRequired(); List getContextUris(); + Map> getContextAliases(); + Map> getContextVersionPatterns(); String toString(); } diff --git a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/VerifiableCredential.java b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/VerifiableCredential.java index 2b29f9f..9e93b9c 100644 --- a/inspector-vc/src/main/java/org/oneedtech/inspect/vc/VerifiableCredential.java +++ b/inspector-vc/src/main/java/org/oneedtech/inspect/vc/VerifiableCredential.java @@ -53,17 +53,24 @@ public class VerifiableCredential extends Credential { private static final Map, List> contextMap = new ImmutableMap.Builder, List>() .put(Set.of(Type.OpenBadgeCredential, AchievementCredential, EndorsementCredential), List.of("https://www.w3.org/2018/credentials/v1", - //"https://purl.imsglobal.org/spec/ob/v3p0/context.json")) //dev legacy "https://purl.imsglobal.org/spec/ob/v3p0/context.json")) .put(Set.of(ClrCredential), List.of("https://www.w3.org/2018/credentials/v1", - // "https://dc.imsglobal.org/draft/clr/v2p0/context", //dev legacy - // "https://purl.imsglobal.org/spec/ob/v3p0/context.json")) //dev legacy "https://purl.imsglobal.org/spec/clr/v2p0/context.json", "https://purl.imsglobal.org/spec/ob/v3p0/context.json")) .build(); + private static final Map> contextAliasesMap = new ImmutableMap.Builder>() + .put("https://purl.imsglobal.org/spec/ob/v3p0/context.json", + List.of("https://purl.imsglobal.org/spec/ob/v3p0/context/ob_v3p0.jsonld")) + .build(); + + private static final Map> contextVersioningPatternMap = new ImmutableMap.Builder>() + .put("https://purl.imsglobal.org/spec/ob/v3p0/context.json", + List.of("https:\\/\\/purl\\.imsglobal\\.org\\/spec\\/ob\\/v3p0\\/context(-\\d+\\.\\d+\\.\\d+)*\\.json")) + .build(); + public enum Type implements CredentialEnum { AchievementCredential(Collections.emptyList()), OpenBadgeCredential(List.of("OpenBadgeCredential", "AchievementCredential")), //treated as an alias of AchievementCredential @@ -119,6 +126,14 @@ public class VerifiableCredential extends Credential { .findFirst() .orElseThrow(()-> new IllegalArgumentException(this.name() + " not recognized"))); } + @Override + public Map> getContextAliases() { + return contextAliasesMap; + } + @Override + public Map> getContextVersionPatterns() { + return contextVersioningPatternMap; + } } public enum ProofType {