├── .gitignore
├── LICENSE
├── README.md
├── inspector-clr
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── org
│ │ └── oneedtech
│ │ └── inspect
│ │ └── clr
│ │ ├── CLR20Inspector.java
│ │ └── probe
│ │ └── ClrSubjectProbe.java
│ └── test
│ ├── java
│ └── org
│ │ └── oneedtech
│ │ └── inspect
│ │ └── clr
│ │ ├── CLR20Tests.java
│ │ └── Samples.java
│ └── resources
│ └── clr20
│ ├── complex.json
│ ├── simple-noproof.json
│ ├── simple.json
│ ├── simple.jwt
│ ├── simple_old_safesigned.json
│ └── simple_v1.json
├── inspector-vc-web
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── org
│ │ └── oneedtech
│ │ └── inspect
│ │ └── vc
│ │ └── web
│ │ └── ValidatorApplication.java
│ └── resources
│ ├── application.properties
│ └── validators.json
├── inspector-vc
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── oneedtech
│ │ │ └── inspect
│ │ │ └── vc
│ │ │ ├── Assertion.java
│ │ │ ├── BitstringStatusListCredentialInspector.java
│ │ │ ├── Credential.java
│ │ │ ├── EndorsementInspector.java
│ │ │ ├── OB20EndorsementInspector.java
│ │ │ ├── OB20Inspector.java
│ │ │ ├── OB30Inspector.java
│ │ │ ├── VCInspector.java
│ │ │ ├── Validation.java
│ │ │ ├── VerifiableCredential.java
│ │ │ ├── W3CVCHolder.java
│ │ │ ├── W3CVerifiableCredentialDM2.java
│ │ │ ├── jsonld
│ │ │ ├── JsonLDObjectUtils.java
│ │ │ ├── JsonLdGeneratedObject.java
│ │ │ └── probe
│ │ │ │ ├── ExtensionProbe.java
│ │ │ │ ├── GraphFetcherProbe.java
│ │ │ │ ├── JsonLDCompactionProve.java
│ │ │ │ └── JsonLDValidationProbe.java
│ │ │ ├── payload
│ │ │ ├── JsonParser.java
│ │ │ ├── JwtParser.java
│ │ │ ├── PayloadParser.java
│ │ │ ├── PayloadParserFactory.java
│ │ │ ├── PngParser.java
│ │ │ └── SvgParser.java
│ │ │ ├── probe
│ │ │ ├── AssertionRevocationListProbe.java
│ │ │ ├── ContextPropertyProbe.java
│ │ │ ├── CredentialParseProbe.java
│ │ │ ├── CredentialSubjectProbe.java
│ │ │ ├── EmbeddedProofModel.java
│ │ │ ├── EmbeddedProofModelGenerator.java
│ │ │ ├── EmbeddedProofProbe.java
│ │ │ ├── EvidenceProbe.java
│ │ │ ├── ExpirationProbe.java
│ │ │ ├── ExternalProofProbe.java
│ │ │ ├── InlineJsonSchemaProbe.java
│ │ │ ├── IssuanceProbe.java
│ │ │ ├── IssuerProbe.java
│ │ │ ├── JsonSchemasProbe.java
│ │ │ ├── PropertyProbe.java
│ │ │ ├── RevocationListProbe.java
│ │ │ ├── RunContextKey.java
│ │ │ ├── StringValuePropertyProbe.java
│ │ │ ├── TypePropertyProbe.java
│ │ │ ├── VerificationDependenciesProbe.java
│ │ │ ├── VerificationJWTProbe.java
│ │ │ ├── VerificationRecipientProbe.java
│ │ │ ├── did
│ │ │ │ ├── DidResolution.java
│ │ │ │ ├── DidResolutionException.java
│ │ │ │ ├── DidResolver.java
│ │ │ │ └── SimpleDidResolver.java
│ │ │ └── validation
│ │ │ │ ├── ValidationImagePropertyProbe.java
│ │ │ │ ├── ValidationIssuerPropertyProbe.java
│ │ │ │ ├── ValidationPropertyProbe.java
│ │ │ │ ├── ValidationPropertyProbeFactory.java
│ │ │ │ └── ValidationRdfTypePropertyProbe.java
│ │ │ ├── resource
│ │ │ ├── DefaultUriResourceFactory.java
│ │ │ └── UriResourceFactory.java
│ │ │ ├── status
│ │ │ └── bitstring
│ │ │ │ └── BitstringStatusListProbe.java
│ │ │ ├── util
│ │ │ ├── CachingDocumentLoader.java
│ │ │ ├── JsonNodeUtil.java
│ │ │ └── PrimitiveValueValidator.java
│ │ │ └── verification
│ │ │ ├── Ed25519Signature2022LdVerifier.java
│ │ │ ├── Ed25519Signature2022SignatureSuite.java
│ │ │ ├── Ed25519Signature2022VCDM20LdVerifier.java
│ │ │ ├── Eddsa2022LdProof.java
│ │ │ ├── Eddsa2022v2LdProof.java
│ │ │ ├── LDSecurityContexts.java
│ │ │ ├── SignatureSuites.java
│ │ │ └── URDNA2015Canonicalizer.java
│ └── resources
│ │ └── contexts
│ │ ├── 2018-credentials-examples-v1.jsonld
│ │ ├── 2018-credentials-v1.jsonld
│ │ ├── clr-v2p0-2.0.1.json
│ │ ├── clr-v2p0.json
│ │ ├── credentials-v2.jsonld
│ │ ├── data-integrity-v1.jsonld
│ │ ├── did-v1.jsonld
│ │ ├── ob-v2p0.json
│ │ ├── ob-v3p0-3.0.1.json
│ │ ├── ob-v3p0-3.0.2.json
│ │ ├── ob-v3p0-3.0.3.json
│ │ ├── ob-v3p0-extensions.json
│ │ ├── ob-v3p0.json
│ │ ├── obv2x-applylink-extensions.json
│ │ ├── obv2x-example-extension.json
│ │ ├── obv2x.jsonld
│ │ ├── obv3x.jsonld
│ │ ├── odrl.jsonld
│ │ ├── security-bbs-v1.jsonld
│ │ ├── security-suites-ed25519-2020-v1.jsonld
│ │ ├── security-v1.jsonld
│ │ ├── security-v2.jsonld
│ │ ├── security-v3-unstable.jsonld
│ │ ├── suites-ed25519-2018.jsonld
│ │ ├── suites-ed25519-2020.jsonld
│ │ ├── suites-jws-2020.jsonld
│ │ ├── suites-secp256k1-2019.jsonld
│ │ └── suites-x25519-2019.jsonld
│ └── test
│ ├── java
│ └── org
│ │ └── oneedtech
│ │ └── inspect
│ │ └── vc
│ │ ├── BitstringStatusListCredentialInspectorTest.java
│ │ ├── Endorsement30Tests.java
│ │ ├── OB20Tests.java
│ │ ├── OB30Tests.java
│ │ ├── Samples.java
│ │ ├── credential
│ │ └── PayloadParserTests.java
│ │ ├── resource
│ │ └── TestUriResourceFactory.java
│ │ └── util
│ │ ├── CachingDocumentLoaderTests.java
│ │ ├── JsonNodeUtilTests.java
│ │ ├── PrimitiveValueValidatorTests.java
│ │ └── TestOB20Inspector.java
│ └── resources
│ ├── ob20
│ ├── assertion-with-data-image.json
│ ├── assertion-with-endorsements.json
│ ├── assertion-with-extension-node-basic.json
│ ├── assertion-with-extension-node-invalid.json
│ ├── assertion-with-multiple-extensions.json
│ ├── assets
│ │ ├── altbadgeurl.json
│ │ ├── bad-issuer.json
│ │ ├── badge-from-organization-with-empty-revocation-list.json
│ │ ├── badge-from-organization-with-revocation-list.json
│ │ ├── badge-with-bad-issuer.json
│ │ ├── badge-with-data-image.json
│ │ ├── badgeclass-with-complex-image.json
│ │ ├── badgeclass-with-endorsements.json
│ │ ├── badgeclass-with-language.json
│ │ ├── badgeclass-with-verification-invalid-multiple-starts-with.json
│ │ ├── badgeclass-with-verification-invalid-starts-with.json
│ │ ├── badgeclass-with-verification-valid-multiple-starts-with.json
│ │ ├── badgeclass-with-verification-valid-starts-with.json
│ │ ├── badgeclass-with-verification.json
│ │ ├── badgeclass1.json
│ │ ├── badgecriteria.json
│ │ ├── basic-badge-no-public-key.json
│ │ ├── beths-robot-badge.png
│ │ ├── beths-robot-work.html
│ │ ├── criteria-no-type.json
│ │ ├── empty-revocation-list.json
│ │ ├── endorsement-1.json
│ │ ├── endorsement-2.json
│ │ ├── endorsement-3.json
│ │ ├── endorsement-4.json
│ │ ├── issuer-invalid-type.json
│ │ ├── issuer-with-allowed-origins-invalid-multiple-starts-with.json
│ │ ├── issuer-with-allowed-origins-invalid-starts-with.json
│ │ ├── issuer-with-allowed-origins-valid-multiple-starts-with.json
│ │ ├── issuer-with-allowed-origins-valid-starts-with.json
│ │ ├── issuer-with-allowed-origins.json
│ │ ├── issuer1.json
│ │ ├── key1.json
│ │ ├── key2.json
│ │ ├── key3.json
│ │ ├── openbadges_context.json
│ │ ├── organization-no-public-key.json
│ │ ├── organization-with-empty-revocation-list.json
│ │ ├── organization-with-revocation-list.json
│ │ ├── organization.json
│ │ ├── revocation-list.json
│ │ ├── robotics-badge.json
│ │ └── robotics-badge.png
│ ├── badge-class-with-language.json
│ ├── basic-assertion-expired-before-issued.json
│ ├── basic-assertion-expired.json
│ ├── basic-assertion-in-future.json
│ ├── basic-assertion-invalid-context.json
│ ├── basic-assertion-invalid-type.json
│ ├── basic-assertion-no-public-key.json
│ ├── basic-assertion-with-allowed-origins-invalid-multiple-starts-with.json
│ ├── basic-assertion-with-allowed-origins-invalid-starts-with.json
│ ├── basic-assertion-with-allowed-origins-valid-multiple-starts-with.json
│ ├── basic-assertion-with-allowed-origins-valid-starts-with.json
│ ├── basic-assertion-with-allowed-origins.json
│ ├── basic-assertion-with-language.json
│ ├── basic-assertion.json
│ ├── issuer-compact-iri-validation.json
│ ├── rdf-validation
│ │ ├── badge-class-invalid-issuer-type.json
│ │ ├── invalid-class.json
│ │ ├── invalid-empty-type.json
│ │ ├── invalid-one-invalid-class.json
│ │ ├── valid-alignment-object.json
│ │ ├── valid-badge-class-empty-criteria-type.json
│ │ ├── valid-badge-class.json
│ │ ├── valid-cool-class.json
│ │ └── valid-issuer-extension.json
│ ├── redirected-validation-subject.json
│ ├── simple-badge.png
│ ├── simple-not-revoked.jwt
│ ├── simple-revoked.jwt
│ ├── simple.jwt
│ ├── warning-issuer-non-http.json
│ └── warning-with-redirection.json
│ └── ob30
│ ├── bit-string-list
│ ├── credential-status-revoked-blank-nodes.json
│ ├── credential-status-revoked.json
│ └── testlist
│ ├── complete.json
│ ├── complete_v1.json
│ ├── credential-status-revoked.json
│ ├── endorsement-err-schema-status-refresh.json
│ ├── endorsement-valid.json
│ ├── simple-context-alias.json
│ ├── simple-context-version.json
│ ├── simple-did-key-method.json
│ ├── simple-did-web-method.json
│ ├── simple-eddsa-2022.json
│ ├── simple-err-context.json
│ ├── simple-err-credential-subject-achievement-result-description-type.json
│ ├── simple-err-credential-subject-identifier-type.json
│ ├── simple-err-credential-subject-profile-type.json
│ ├── simple-err-credential-subject-result-type.json
│ ├── simple-err-credential-subject-type.json
│ ├── simple-err-evidence-type.json
│ ├── simple-err-expired.json
│ ├── simple-err-issued.json
│ ├── simple-err-issuer-otheridentifier-type.json
│ ├── simple-err-issuer-parentorg-type.json
│ ├── simple-err-issuer-type.json
│ ├── simple-err-issuer.json
│ ├── simple-err-proof-method-no-scheme.json
│ ├── simple-err-proof-method-unknown-did-method.json
│ ├── simple-err-proof-method-unknown-scheme.json
│ ├── simple-err-proof-method.json
│ ├── simple-err-proof-value.json
│ ├── simple-err-type.json
│ ├── simple-json.png
│ ├── simple-json.svg
│ ├── simple-jwt.png
│ ├── simple-jwt.svg
│ ├── simple-jwt_v1.png
│ ├── simple-jwt_v1.svg
│ ├── simple-multiple-proofs.json
│ ├── simple-noproof.json
│ ├── simple.1ob
│ ├── simple.json
│ ├── simple.jwt
│ └── simple_v1.json
└── pom.xml
/inspector-clr/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 | org.1edtech
7 | vc-public-validator
8 | 1.3.5
9 |
10 | inspector-clr
11 |
12 |
13 | org.1edtech
14 | inspector-vc
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/inspector-clr/src/main/java/org/oneedtech/inspect/clr/probe/ClrSubjectProbe.java:
--------------------------------------------------------------------------------
1 | package org.oneedtech.inspect.clr.probe;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.Optional;
6 |
7 | import org.oneedtech.inspect.core.probe.RunContext;
8 | import org.oneedtech.inspect.core.report.ReportItems;
9 | import org.oneedtech.inspect.vc.probe.CredentialSubjectProbe;
10 |
11 | import com.fasterxml.jackson.databind.JsonNode;
12 |
13 | public class ClrSubjectProbe extends CredentialSubjectProbe {
14 |
15 | public ClrSubjectProbe(String requiredType) {
16 | super(requiredType);
17 | }
18 |
19 | @Override
20 | protected Optional checkAchievement(JsonNode achievementNode, RunContext ctx) {
21 | if ( achievementNode.isObject() ) {
22 | return super.checkAchievement(achievementNode, ctx);
23 | }
24 | if (achievementNode.isArray()) {
25 | List reportItems = new ArrayList<>();
26 | for (JsonNode node : achievementNode) {
27 | if (node.isObject()) {
28 | Optional result = super.checkAchievement(node, ctx);
29 | if (result.isPresent()) {
30 | reportItems.add(result.get());
31 | }
32 | }
33 | }
34 | return !reportItems.isEmpty() ?
35 | Optional.of(new ReportItems(reportItems)) :
36 | Optional.empty();
37 | }
38 | return Optional.empty();
39 | }
40 |
41 |
42 |
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/inspector-clr/src/test/java/org/oneedtech/inspect/clr/CLR20Tests.java:
--------------------------------------------------------------------------------
1 | package org.oneedtech.inspect.clr;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
4 | import static org.oneedtech.inspect.test.Assertions.assertValid;
5 | import static org.oneedtech.inspect.test.Assertions.assertWarning;
6 |
7 | import org.junit.jupiter.api.BeforeAll;
8 | import org.junit.jupiter.api.Disabled;
9 | import org.junit.jupiter.api.Test;
10 | import org.oneedtech.inspect.core.Inspector;
11 | import org.oneedtech.inspect.core.Inspector.Behavior;
12 | import org.oneedtech.inspect.core.report.Report;
13 | import org.oneedtech.inspect.test.PrintHelper;
14 |
15 | public class CLR20Tests {
16 | private static CLR20Inspector validator;
17 | private static boolean verbose = true;
18 |
19 | @BeforeAll
20 | static void setup() {
21 | validator = new CLR20Inspector.Builder()
22 | .set(Behavior.TEST_INCLUDE_SUCCESS, true)
23 | .set(Behavior.VALIDATOR_FAIL_FAST, false)
24 | .inject(Inspector.InjectionKeys.DID_RESOLUTION_SERVICE_URL, "http://dev.uniresolver.io/1.0/identifiers/")
25 | .build();
26 | }
27 |
28 | @Test
29 | void testSimpleJsonValid() {
30 | assertDoesNotThrow(()->{
31 | Report report = validator.run(Samples.CLR20.JSON.SIMPLE_JSON.asFileResource());
32 | if(verbose) PrintHelper.print(report, true);
33 | assertValid(report);
34 | });
35 | }
36 |
37 | @Test
38 | void testSimpleV1JsonValid() {
39 | assertDoesNotThrow(()->{
40 | Report report = validator.run(Samples.CLR20.JSON.SIMPLE_V1_JSON.asFileResource());
41 | if(verbose) PrintHelper.print(report, true);
42 | // warning due to outdated context versions
43 | assertWarning(report);
44 | });
45 | }
46 |
47 | // commented out due that https://western.riverwell.k12.or.us/ is not accessible
48 | // @Test
49 | // void testComplexJsonValid() {
50 | // assertDoesNotThrow(()->{
51 | // Report report = validator.run(Samples.CLR20.JSON.COMPLEX_JSON.asFileResource());
52 | // if(verbose) PrintHelper.print(report, true);
53 | // assertValid(report);
54 | // });
55 | // }
56 |
57 | @Disabled
58 | @Test
59 | void testSimpleJWTValid() {
60 | assertDoesNotThrow(()->{
61 | Report report = validator.run(Samples.CLR20.JSON.SIMPLE_JWT.asFileResource());
62 | if(verbose) PrintHelper.print(report, true);
63 | assertValid(report);
64 | });
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/inspector-clr/src/test/java/org/oneedtech/inspect/clr/Samples.java:
--------------------------------------------------------------------------------
1 | package org.oneedtech.inspect.clr;
2 |
3 | import org.oneedtech.inspect.test.Sample;
4 |
5 | public class Samples {
6 | public static final class CLR20 {
7 | public static final class JSON {
8 | public final static Sample SIMPLE_JSON = new Sample("clr20/simple.json", true);
9 | public final static Sample SIMPLE_V1_JSON = new Sample("clr20/simple_v1.json", true);
10 | public final static Sample SIMPLE_JSON_NOPROOF = new Sample("clr20/simple-noproof.json", true);
11 | public final static Sample SIMPLE_JWT = new Sample("clr20/simple.jwt", true);
12 | public final static Sample COMPLEX_JSON = new Sample("clr20/complex.json", true);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/inspector-vc-web/src/main/java/org/oneedtech/inspect/vc/web/ValidatorApplication.java:
--------------------------------------------------------------------------------
1 | package org.oneedtech.inspect.vc.web;
2 |
3 | import org.apache.logging.log4j.LogManager;
4 | import org.apache.logging.log4j.Logger;
5 | import org.oneedtech.inspect.web.InspectorWebConfig;
6 | import org.springframework.boot.SpringApplication;
7 | import org.springframework.boot.autoconfigure.SpringBootApplication;
8 | import org.springframework.context.annotation.ComponentScan;
9 | import org.springframework.context.annotation.Configuration;
10 | import org.springframework.context.annotation.Import;
11 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
12 |
13 | @SpringBootApplication // == @SpringBootConfiguration @EnableAutoConfiguration @ComponentScan
14 | @Configuration
15 | @Import(InspectorWebConfig.class)
16 | @ComponentScan("org.oneedtech.inspect.web")
17 | public class ValidatorApplication implements WebMvcConfigurer {
18 |
19 | public static void main(String[] args) {
20 | SpringApplication.run(ValidatorApplication.class, args);
21 | }
22 |
23 | private final static Logger logger = LogManager.getLogger();
24 | }
25 |
--------------------------------------------------------------------------------
/inspector-vc-web/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # To build a docker image for distribution, set spring.profiles.active=prod and dockerMode=true
2 | # To build a fatjar for deployment on the ims website with oauth sso, set dockerMode=false and spring.profiles.active=prod
3 | # During development, set spring.profiles.active=dev. If dockerMode is true during devMode, a jwt license in /resources is used as a dummy.
4 |
5 | # to deploy jars to nexus: set profile=prod & dockerMode false, then mvn clean deploy -Dmaven.test.skip=true -P deploy-nexus
6 | # to build docker: set profile=prod & dockerMode true, then mvn clean install -Dmaven.test.skip=true -P docker, then docker:push gcr.io/staging-1edtech/ims/inspector:0.x.0
7 |
8 | #spring.profiles.active = dev | prod
9 | spring.profiles.active=dev
10 | dockerMode=false
11 | app.version=1.0.0
12 |
13 | # misc
14 | spring.jackson.serialization.INDENT_OUTPUT=true
15 | server.servlet.encoding.charset=UTF-8
16 | server.servlet.encoding.force-response=true
--------------------------------------------------------------------------------
/inspector-vc-web/src/main/resources/validators.json:
--------------------------------------------------------------------------------
1 | {
2 | "groups": [
3 | {
4 | "id": "vc",
5 | "name": "Verifiable Credentials",
6 | "desc": "Verifiers for the Open Badges and Comprehensive Learner Record specifications"
7 | }
8 | ],
9 | "validators" : [
10 | {
11 | "id": "OB30Inspector",
12 | "name": "Open Badges 3.0 Verifier",
13 | "pkg": "org.oneedtech.inspect.vc",
14 | "desc": "Verifies Open Badges 3.0 files",
15 | "instr": "This validator supports Open Badges 3.0 files.",
16 | "spec": "ob",
17 | "group": "vc",
18 | "initParams": {
19 | "DID_RESOLUTION_SERVICE_URL": "http://dev.uniresolver.io/1.0/identifiers/"
20 | },
21 | "supportsCertification": false,
22 | "submissionTypes": ["upload","uri"]
23 | },
24 | {
25 | "id": "OB20Inspector",
26 | "name": "Open Badges 2.0 Verifier",
27 | "pkg": "org.oneedtech.inspect.vc",
28 | "desc": "Verifies Open Badges 2.0 files",
29 | "instr": "This validator supports Open Badges 2.0 files.",
30 | "spec": "ob",
31 | "group": "vc",
32 | "supportsCertification": false,
33 | "submissionTypes": ["upload","uri"]
34 | },
35 | {
36 | "id": "CLR20Inspector",
37 | "name": "CLR 2.0 Verifier",
38 | "pkg": "org.oneedtech.inspect.clr",
39 | "desc": "Verifies Comprehensive Learner Record (CLR) 2.0 files",
40 | "instr": "This validator supports Comprehensive Learner Record (CLR) 2.0 files.",
41 | "spec": "spec-pid-todo",
42 | "group": "vc",
43 | "initParams": {
44 | "DID_RESOLUTION_SERVICE_URL": "http://dev.uniresolver.io/1.0/identifiers/"
45 | },
46 | "supportsCertification": false,
47 | "submissionTypes": ["upload","uri"]
48 | }
49 | ]
50 |
51 | }
--------------------------------------------------------------------------------
/inspector-vc/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 | org.1edtech
7 | vc-public-validator
8 | 1.3.5
9 |
10 | inspector-vc
11 |
12 |
13 | org.1edtech
14 | inspector-core
15 |
16 |
17 | com.auth0
18 | auth0
19 | 1.42.0
20 |
21 |
22 | com.auth0
23 | jwks-rsa
24 | 0.21.1
25 |
26 |
27 | com.auth0
28 | java-jwt
29 | 3.19.2
30 |
31 |
32 |
33 |
34 | com.danubetech
35 | verifiable-credentials-java
36 | 1.12.0
37 |
38 |
39 |
40 |
41 | com.apicatalog
42 | iron-eddsa-rdfc-2022
43 | 0.14.0
44 |
45 |
46 |
47 |
48 | decentralized-identity
49 | uni-resolver-client
50 | 0.5.0
51 |
52 |
53 |
54 |
55 | org.apache.httpcomponents
56 | httpclient
57 | 4.5.13
58 |
59 |
60 | org.glassfish
61 | jakarta.json
62 | 2.0.1
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/inspector-vc/src/main/java/org/oneedtech/inspect/vc/W3CVCHolder.java:
--------------------------------------------------------------------------------
1 | package org.oneedtech.inspect.vc;
2 |
3 | import java.io.StringReader;
4 | import java.util.List;
5 |
6 | import org.oneedtech.inspect.vc.jsonld.JsonLDObjectUtils;
7 | import org.oneedtech.inspect.vc.util.CachingDocumentLoader;
8 |
9 | import info.weboftrust.ldsignatures.LdProof;
10 |
11 | /**
12 | * Holder for W3C's Verifiable Credential
13 | */
14 | public class W3CVCHolder {
15 | private com.danubetech.verifiablecredentials.VerifiableCredential credential;
16 |
17 | public W3CVCHolder(VerifiableCredential credential) {
18 | switch (credential.version) {
19 | case VCDMv1p1:
20 | this.credential = com.danubetech.verifiablecredentials.VerifiableCredential
21 | .fromJson(new StringReader(credential.getJson().toString()));
22 | break;
23 | case VCDMv2p0:
24 | this.credential = W3CVerifiableCredentialDM2
25 | .fromJson(new StringReader(credential.getJson().toString()));
26 | break;
27 | default:
28 | throw new IllegalArgumentException("Unsupported version: " + credential.version);
29 | }
30 | this.credential.setDocumentLoader(new CachingDocumentLoader());
31 | }
32 |
33 | /**
34 | * Get the list of proofs in the credential.
35 | * {@link VerifiableCredential} contains the method getLdProof(), but only works with one proof. This methods
36 | * returns a list of all proofs defined in the credential.
37 | * @return proofs defined in the credential
38 | */
39 | public List getProofs() {
40 | return JsonLDObjectUtils.getListFromJsonLDObject(LdProof.class, credential);
41 | }
42 |
43 | public com.danubetech.verifiablecredentials.VerifiableCredential getCredential() {
44 | return credential;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/inspector-vc/src/main/java/org/oneedtech/inspect/vc/W3CVerifiableCredentialDM2.java:
--------------------------------------------------------------------------------
1 | package org.oneedtech.inspect.vc;
2 |
3 | import java.net.URI;
4 | import java.util.Date;
5 | import java.util.Map;
6 |
7 | import com.fasterxml.jackson.annotation.JsonCreator;
8 |
9 | import foundation.identity.jsonld.JsonLDUtils;
10 |
11 | public class W3CVerifiableCredentialDM2 extends com.danubetech.verifiablecredentials.VerifiableCredential {
12 | public static final URI[] DEFAULT_JSONLD_CONTEXTS = { URI.create(VerifiableCredential.JSONLD_CONTEXT_W3C_CREDENTIALS_V2) };
13 |
14 | @JsonCreator
15 | public W3CVerifiableCredentialDM2() {
16 | super();
17 | }
18 |
19 | protected W3CVerifiableCredentialDM2(Map jsonObject) {
20 | super(jsonObject);
21 | }
22 |
23 | public static W3CVerifiableCredentialDM2 fromJson(String json) {
24 | return new W3CVerifiableCredentialDM2(readJson(json));
25 | }
26 |
27 | public Date getValidFrom() {
28 | return JsonLDUtils.stringToDate(JsonLDUtils.jsonLdGetString(this.getJsonObject(), JSONLD_TERM_VALIDFROM));
29 | }
30 |
31 | public Date getValidUntil() {
32 | return JsonLDUtils.stringToDate(JsonLDUtils.jsonLdGetString(this.getJsonObject(), JSONLD_TERM_VALIDUNTIL));
33 | }
34 | private static final String JSONLD_TERM_VALIDFROM = "validFrom";
35 | private static final String JSONLD_TERM_VALIDUNTIL = "validUntil";
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/inspector-vc/src/main/java/org/oneedtech/inspect/vc/jsonld/JsonLDObjectUtils.java:
--------------------------------------------------------------------------------
1 | package org.oneedtech.inspect.vc.jsonld;
2 |
3 | import java.lang.reflect.InvocationTargetException;
4 | import java.lang.reflect.Method;
5 | import java.util.Collections;
6 | import java.util.List;
7 | import java.util.Map;
8 | import java.util.stream.Collectors;
9 |
10 | import foundation.identity.jsonld.JsonLDObject;
11 |
12 | public class JsonLDObjectUtils {
13 | @SuppressWarnings("unchecked")
14 | public static List getListFromJsonLDObject(Class cl, JsonLDObject jsonLdObject) {
15 | String term = JsonLDObject.getDefaultJsonLDPredicate(cl);
16 | List