diff --git a/src/main/java/com/danubetech/verifiablecredentials/CredentialSubject.java b/src/main/java/com/danubetech/verifiablecredentials/CredentialSubject.java index 7a8fc49..e41a696 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/CredentialSubject.java +++ b/src/main/java/com/danubetech/verifiablecredentials/CredentialSubject.java @@ -5,6 +5,7 @@ import com.apicatalog.jsonld.loader.DocumentLoader; import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialContexts; import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialKeywords; +import com.danubetech.verifiablecredentials.proof.BlockchainHashProof2020; import com.fasterxml.jackson.annotation.JsonCreator; import foundation.identity.jsonld.JsonLDKeywords; import foundation.identity.jsonld.JsonLDObject; @@ -14,7 +15,6 @@ import java.net.URI; import java.util.LinkedHashMap; import java.util.Map; -import java.util.stream.Collectors; public class CredentialSubject extends JsonLDObject { @@ -62,7 +62,7 @@ public B claims(Map claims) { } public static Builder> builder() { - return new Builder(new CredentialSubject()); + return new Builder>(new CredentialSubject()); } public static CredentialSubject fromJsonObject(Map jsonObject) { diff --git a/src/main/java/com/danubetech/verifiablecredentials/VerifiableCredential.java b/src/main/java/com/danubetech/verifiablecredentials/VerifiableCredential.java index 700af94..a64cfe8 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/VerifiableCredential.java +++ b/src/main/java/com/danubetech/verifiablecredentials/VerifiableCredential.java @@ -4,6 +4,7 @@ import com.danubetech.verifiablecredentials.credentialstatus.CredentialStatus; import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialContexts; import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialKeywords; +import com.danubetech.verifiablecredentials.proof.BlockchainHashProof2020; import com.fasterxml.jackson.annotation.JsonCreator; import foundation.identity.jsonld.JsonLDObject; import foundation.identity.jsonld.JsonLDUtils; @@ -99,7 +100,7 @@ public B ldProof(LdProof ldProof) { } public static Builder> builder() { - return new Builder(new VerifiableCredential()); + return new Builder>(new VerifiableCredential()); } public static VerifiableCredential fromJsonObject(Map jsonObject) { diff --git a/src/main/java/com/danubetech/verifiablecredentials/VerifiablePresentation.java b/src/main/java/com/danubetech/verifiablecredentials/VerifiablePresentation.java index 9a2d45b..ce66946 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/VerifiablePresentation.java +++ b/src/main/java/com/danubetech/verifiablecredentials/VerifiablePresentation.java @@ -3,6 +3,7 @@ import com.apicatalog.jsonld.loader.DocumentLoader; import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialContexts; import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialKeywords; +import com.danubetech.verifiablecredentials.proof.BlockchainHashProof2020; import com.fasterxml.jackson.annotation.JsonCreator; import foundation.identity.jsonld.JsonLDObject; import foundation.identity.jsonld.JsonLDUtils; @@ -77,7 +78,7 @@ public B ldProof(LdProof ldProof) { } public static Builder> builder() { - return new Builder(new VerifiablePresentation()); + return new Builder>(new VerifiablePresentation()); } public static VerifiablePresentation fromJsonObject(Map jsonObject) { @@ -148,7 +149,7 @@ public URI getHolder() { public VerifiableCredential getVerifiableCredential() { Object verifiableCredentialObject = this.getJsonObject().get(VerifiableCredentialKeywords.JSONLD_TERM_VERIFIABLECREDENTIAL); - if ((verifiableCredentialObject instanceof List && ! ((List) verifiableCredentialObject).isEmpty() && ((List) verifiableCredentialObject).get(0) instanceof Map)) { + if ((verifiableCredentialObject instanceof List && ! ((List) verifiableCredentialObject).isEmpty() && ((List) verifiableCredentialObject).get(0) instanceof Map)) { return VerifiableCredential.getFromJsonLDObject(this); } else if (verifiableCredentialObject instanceof Map) { return VerifiableCredential.getFromJsonLDObject(this); @@ -158,8 +159,8 @@ public VerifiableCredential getVerifiableCredential() { public String getJwtVerifiableCredentialString() { Object verifiableCredentialObject = this.getJsonObject().get(VerifiableCredentialKeywords.JSONLD_TERM_VERIFIABLECREDENTIAL); - if (verifiableCredentialObject instanceof List && ! ((List) verifiableCredentialObject).isEmpty() && ((List) verifiableCredentialObject).get(0) instanceof String) { - return (String) ((List) verifiableCredentialObject).get(0); + if (verifiableCredentialObject instanceof List && ! ((List) verifiableCredentialObject).isEmpty() && ((List) verifiableCredentialObject).get(0) instanceof String) { + return (String) ((List) verifiableCredentialObject).get(0); } else if (verifiableCredentialObject instanceof String) { return (String) verifiableCredentialObject; } diff --git a/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/CredentialStatus.java b/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/CredentialStatus.java index a1998b5..10ff4ed 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/CredentialStatus.java +++ b/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/CredentialStatus.java @@ -1,12 +1,11 @@ package com.danubetech.verifiablecredentials.credentialstatus; import com.apicatalog.jsonld.loader.DocumentLoader; -import com.danubetech.verifiablecredentials.CredentialSubject; import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialContexts; import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialKeywords; +import com.danubetech.verifiablecredentials.proof.BlockchainHashProof2020; import com.fasterxml.jackson.annotation.JsonCreator; import foundation.identity.jsonld.JsonLDObject; -import foundation.identity.jsonld.JsonLDUtils; import java.io.Reader; import java.net.URI; @@ -48,7 +47,7 @@ public CredentialStatus build() { } public static Builder> builder() { - return new Builder(new CredentialStatus()); + return new Builder>(new CredentialStatus()); } public static CredentialStatus fromJsonObject(Map jsonObject) { diff --git a/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/RevocationList2020Status.java b/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/RevocationList2020Status.java index e235e0b..4550e06 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/RevocationList2020Status.java +++ b/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/RevocationList2020Status.java @@ -1,9 +1,9 @@ package com.danubetech.verifiablecredentials.credentialstatus; import com.apicatalog.jsonld.loader.DocumentLoader; -import com.danubetech.verifiablecredentials.CredentialSubject; import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialContexts; import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialKeywords; +import com.danubetech.verifiablecredentials.proof.BlockchainHashProof2020; import com.fasterxml.jackson.annotation.JsonCreator; import foundation.identity.jsonld.JsonLDObject; import foundation.identity.jsonld.JsonLDUtils; @@ -66,7 +66,7 @@ public B revocationListCredential(URI revocationListCredential) { } public static Builder> builder() { - return new Builder(new RevocationList2020Status()); + return new Builder>(new RevocationList2020Status()); } public static RevocationList2020Status fromJsonObject(Map jsonObject) { diff --git a/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/RevocationQuery2020Status.java b/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/RevocationQuery2020Status.java index 1d4df9c..10c95c8 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/RevocationQuery2020Status.java +++ b/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/RevocationQuery2020Status.java @@ -7,7 +7,6 @@ import com.fasterxml.jackson.annotation.JsonCreator; import foundation.identity.jsonld.JsonLDObject; import foundation.identity.jsonld.JsonLDUtils; -import info.weboftrust.ldsignatures.LdProof; import java.io.Reader; import java.net.URI; @@ -67,7 +66,7 @@ public B revocationService(String revocationService) { } public static Builder> builder() { - return new Builder(new RevocationQuery2020Status()); + return new Builder>(new RevocationQuery2020Status()); } public static RevocationQuery2020Status fromJsonObject(Map jsonObject) { diff --git a/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/StatusList2021Entry.java b/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/StatusList2021Entry.java index ba3f6b5..a17c4de 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/StatusList2021Entry.java +++ b/src/main/java/com/danubetech/verifiablecredentials/credentialstatus/StatusList2021Entry.java @@ -3,6 +3,7 @@ import com.apicatalog.jsonld.loader.DocumentLoader; import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialContexts; import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialKeywords; +import com.danubetech.verifiablecredentials.proof.BlockchainHashProof2020; import com.fasterxml.jackson.annotation.JsonCreator; import foundation.identity.jsonld.JsonLDObject; import foundation.identity.jsonld.JsonLDUtils; @@ -73,7 +74,7 @@ public B statusPurpose(String statusPurpose) { } public static StatusList2021Entry.Builder> builder() { - return new StatusList2021Entry.Builder(new StatusList2021Entry()); + return new StatusList2021Entry.Builder>(new StatusList2021Entry()); } public static StatusList2021Entry fromJsonObject(Map jsonObject) { diff --git a/src/main/java/com/danubetech/verifiablecredentials/jsonld/VerifiableCredentialContexts.java b/src/main/java/com/danubetech/verifiablecredentials/jsonld/VerifiableCredentialContexts.java index 5b796fc..ef24cc9 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/jsonld/VerifiableCredentialContexts.java +++ b/src/main/java/com/danubetech/verifiablecredentials/jsonld/VerifiableCredentialContexts.java @@ -10,6 +10,7 @@ import java.net.URI; import java.util.HashMap; import java.util.Map; +import java.util.Objects; public class VerifiableCredentialContexts { @@ -34,21 +35,21 @@ public class VerifiableCredentialContexts { CONTEXTS.putAll(LDSecurityContexts.CONTEXTS); CONTEXTS.put(JSONLD_CONTEXT_W3C_2018_CREDENTIALS_V1, - JsonDocument.of(MediaType.JSON_LD, VerifiableCredentialContexts.class.getResourceAsStream("credentials-v1.jsonld"))); + JsonDocument.of(MediaType.JSON_LD, Objects.requireNonNull(VerifiableCredentialContexts.class.getResourceAsStream("credentials-v1.jsonld")))); CONTEXTS.put(JSONLD_CONTEXT_W3C_2018_CREDENTIALS_V2, - JsonDocument.of(MediaType.JSON_LD, VerifiableCredentialContexts.class.getResourceAsStream("credentials-v2-unstable.jsonld"))); + JsonDocument.of(MediaType.JSON_LD, Objects.requireNonNull(VerifiableCredentialContexts.class.getResourceAsStream("credentials-v2-unstable.jsonld")))); CONTEXTS.put(JSONLD_CONTEXT_W3C_2018_CREDENTIALS_EXAMPLES_V1, - JsonDocument.of(MediaType.JSON_LD, VerifiableCredentialContexts.class.getResourceAsStream("credentials-examples-v1.jsonld"))); + JsonDocument.of(MediaType.JSON_LD, Objects.requireNonNull(VerifiableCredentialContexts.class.getResourceAsStream("credentials-examples-v1.jsonld")))); CONTEXTS.put(JSONLD_CONTEXT_W3C_NS_ODRL, - JsonDocument.of(MediaType.JSON_LD, VerifiableCredentialContexts.class.getResourceAsStream("odrl.jsonld"))); + JsonDocument.of(MediaType.JSON_LD, Objects.requireNonNull(VerifiableCredentialContexts.class.getResourceAsStream("odrl.jsonld")))); CONTEXTS.put(JSONLD_CONTEXT_DANUBETECH_2020_CREDENTIALS_V1, - JsonDocument.of(MediaType.JSON_LD, VerifiableCredentialContexts.class.getResourceAsStream("danubetech-v1.jsonld"))); + JsonDocument.of(MediaType.JSON_LD, Objects.requireNonNull(VerifiableCredentialContexts.class.getResourceAsStream("danubetech-v1.jsonld")))); CONTEXTS.put(JSONLD_CONTEXT_W3ID_VC_REVOCATION_LIST_2020_V1, - JsonDocument.of(MediaType.JSON_LD, VerifiableCredentialContexts.class.getResourceAsStream("vc-revocation-list-2020-v1.jsonld"))); + JsonDocument.of(MediaType.JSON_LD, Objects.requireNonNull(VerifiableCredentialContexts.class.getResourceAsStream("vc-revocation-list-2020-v1.jsonld")))); CONTEXTS.put(JSONLD_CONTEXT_W3ID_VC_STATUS_LIST_2021_V1, - JsonDocument.of(MediaType.JSON_LD, VerifiableCredentialContexts.class.getResourceAsStream("vc-status-list-2021-v1.jsonld"))); + JsonDocument.of(MediaType.JSON_LD, Objects.requireNonNull(VerifiableCredentialContexts.class.getResourceAsStream("vc-status-list-2021-v1.jsonld")))); CONTEXTS.put(JSONLD_CONTEXT_DIF_PRESENTATION_EXCHANGE_SUBMISSIONS_V1, - JsonDocument.of(MediaType.JSON_LD, VerifiableCredentialContexts.class.getResourceAsStream("presentation-exchange-submissions-v1.jsonld"))); + JsonDocument.of(MediaType.JSON_LD, Objects.requireNonNull(VerifiableCredentialContexts.class.getResourceAsStream("presentation-exchange-submissions-v1.jsonld")))); for (Map.Entry context : CONTEXTS.entrySet()) { context.getValue().setDocumentUrl(context.getKey()); diff --git a/src/main/java/com/danubetech/verifiablecredentials/jwt/FromJwtConverter.java b/src/main/java/com/danubetech/verifiablecredentials/jwt/FromJwtConverter.java index b9d5081..dec7609 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/jwt/FromJwtConverter.java +++ b/src/main/java/com/danubetech/verifiablecredentials/jwt/FromJwtConverter.java @@ -4,6 +4,7 @@ import com.danubetech.verifiablecredentials.VerifiableCredential; import com.danubetech.verifiablecredentials.VerifiablePresentation; import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialKeywords; +import com.danubetech.verifiablecredentials.proof.BlockchainHashProof2020; import com.nimbusds.jwt.JWTClaimsSet; import foundation.identity.jsonld.JsonLDUtils; @@ -23,7 +24,7 @@ public static VerifiableCredential fromJwtVerifiableCredential(JwtVerifiableCred CredentialSubject payloadCredentialSubject = payloadVerifiableCredential.getCredentialSubject(); CredentialSubject.removeFromJsonLdObject(payloadVerifiableCredential); - VerifiableCredential.Builder verifiableCredentialBuilder = VerifiableCredential.builder() + VerifiableCredential.Builder> verifiableCredentialBuilder = VerifiableCredential.builder() .base(payloadVerifiableCredential) .defaultContexts(false) .defaultTypes(false); @@ -37,7 +38,7 @@ public static VerifiableCredential fromJwtVerifiableCredential(JwtVerifiableCred if (payloadCredentialSubject != null) { - CredentialSubject.Builder credentialSubjectBuilder = CredentialSubject.builder() + CredentialSubject.Builder> credentialSubjectBuilder = CredentialSubject.builder() .base(payloadCredentialSubject); String subject = payload.getSubject(); @@ -74,7 +75,7 @@ public static VerifiablePresentation fromJwtVerifiablePresentation(JwtVerifiable VerifiablePresentation payloadVerifiablePresentation = VerifiablePresentation.fromJson(jwtVerifiablePresentation.getPayloadObject().toString()); - VerifiablePresentation.Builder verifiablePresentationBuilder = VerifiablePresentation.builder() + VerifiablePresentation.Builder> verifiablePresentationBuilder = VerifiablePresentation.builder() .base(payloadVerifiablePresentation) .defaultContexts(false) .defaultTypes(false); diff --git a/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtJwtVerifiablePresentation.java b/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtJwtVerifiablePresentation.java index 9f17dd7..b3d6bb2 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtJwtVerifiablePresentation.java +++ b/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtJwtVerifiablePresentation.java @@ -19,7 +19,7 @@ private JwtJwtVerifiablePresentation(JWTClaimsSet payload, JwtVerifiableCredenti * Factory methods */ - public static JwtJwtVerifiablePresentation fromJwtVerifiableCredential(JwtVerifiableCredential jwtVerifiableCredential, String aud) throws IOException { + public static JwtJwtVerifiablePresentation fromJwtVerifiableCredential(JwtVerifiableCredential jwtVerifiableCredential, String aud) throws IOException { JwtVerifiableCredential payloadJwtVerifiableCredential = jwtVerifiableCredential; VerifiablePresentation verifiablePresentation = FromJwtConverter.fromJwtVerifiableCredentialToVerifiablePresentation(payloadJwtVerifiableCredential); @@ -28,7 +28,7 @@ public static JwtJwtVerifiablePresentation fromJwtVerifiableCredential(JwtVerifi Date issueTime = new Date(); - payloadBuilder.jwtID("urn:uuid:" + UUID.randomUUID().toString()); + payloadBuilder.jwtID("urn:uuid:" + UUID.randomUUID()); payloadBuilder.issuer(jwtVerifiableCredential.getPayload().getSubject()); payloadBuilder.issueTime(issueTime); payloadBuilder.notBeforeTime(issueTime); diff --git a/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtObject.java b/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtObject.java index dd3c34c..1f40caf 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtObject.java +++ b/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtObject.java @@ -324,8 +324,6 @@ public boolean verify_P_521_ES512(com.nimbusds.jose.jwk.ECKey publicKey) throws private static class EscapedSlashWorkaroundJWSObject extends JWSObject { - private static final long serialVersionUID = -587898962717783109L; - public EscapedSlashWorkaroundJWSObject(final JWSHeader jwsHeader, final JWTClaimsSet jwtClaimsSet, boolean canonicalize) { super(jwsHeader, makePayload(jwtClaimsSet, canonicalize)); } diff --git a/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtVerifiableCredential.java b/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtVerifiableCredential.java index eb548a6..9bf0e11 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtVerifiableCredential.java +++ b/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtVerifiableCredential.java @@ -2,7 +2,6 @@ import com.danubetech.verifiablecredentials.VerifiableCredential; import com.nimbusds.jose.JWSObject; -import com.nimbusds.jose.util.JSONObjectUtils; import com.nimbusds.jwt.JWTClaimsSet; import com.nimbusds.jwt.SignedJWT; diff --git a/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtVerifiablePresentation.java b/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtVerifiablePresentation.java index e30ab64..c34e679 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtVerifiablePresentation.java +++ b/src/main/java/com/danubetech/verifiablecredentials/jwt/JwtVerifiablePresentation.java @@ -1,6 +1,5 @@ package com.danubetech.verifiablecredentials.jwt; -import com.danubetech.verifiablecredentials.VerifiableCredential; import com.danubetech.verifiablecredentials.VerifiablePresentation; import com.nimbusds.jose.JWSObject; import com.nimbusds.jwt.JWTClaimsSet; diff --git a/src/main/java/com/danubetech/verifiablecredentials/proof/BlockchainHashProof2020.java b/src/main/java/com/danubetech/verifiablecredentials/proof/BlockchainHashProof2020.java index 7bd75db..f5a8ccb 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/proof/BlockchainHashProof2020.java +++ b/src/main/java/com/danubetech/verifiablecredentials/proof/BlockchainHashProof2020.java @@ -1,7 +1,6 @@ package com.danubetech.verifiablecredentials.proof; import com.apicatalog.jsonld.loader.DocumentLoader; -import com.danubetech.verifiablecredentials.CredentialSubject; import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialContexts; import com.danubetech.verifiablecredentials.jsonld.VerifiableCredentialKeywords; import com.fasterxml.jackson.annotation.JsonCreator; @@ -50,7 +49,7 @@ public BlockchainHashProof2020 build() { } public static Builder> builder() { - return new Builder(new BlockchainHashProof2020()); + return new Builder>(new BlockchainHashProof2020()); } public static BlockchainHashProof2020 fromJsonObject(Map jsonObject) { diff --git a/src/main/java/com/danubetech/verifiablecredentials/validation/Validation.java b/src/main/java/com/danubetech/verifiablecredentials/validation/Validation.java index 4165609..5aade17 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/validation/Validation.java +++ b/src/main/java/com/danubetech/verifiablecredentials/validation/Validation.java @@ -40,34 +40,34 @@ public static void validate(VerifiableCredential verifiableCredential) throws Il foundation.identity.jsonld.validation.Validation.validate(verifiableCredential); - validateRun(() -> { validateTrue(verifiableCredential.getJsonObject() != null); }, "Bad or missing JSON object."); - validateRun(() -> { validateTrue(verifiableCredential.getContexts().size() > 0); }, "Bad or missing '@context'."); - validateRun(() -> { validateUrl(verifiableCredential.getContexts().get(0)); }, "@context must be a valid URI: " + verifiableCredential.getContexts().get(0)); - validateRun(() -> { validateTrue(VerifiableCredential.DEFAULT_JSONLD_CONTEXTS[0].equals(verifiableCredential.getContexts().get(0))); }, "First value of @context must be " + VerifiableCredential.DEFAULT_JSONLD_CONTEXTS[0] + ": " + verifiableCredential.getContexts().get(0)); + validateRun(() -> validateTrue(verifiableCredential.getJsonObject() != null), "Bad or missing JSON object."); + validateRun(() -> validateTrue(!verifiableCredential.getContexts().isEmpty()), "Bad or missing '@context'."); + validateRun(() -> validateUrl(verifiableCredential.getContexts().get(0)), "@context must be a valid URI: " + verifiableCredential.getContexts().get(0)); + validateRun(() -> validateTrue(VerifiableCredential.DEFAULT_JSONLD_CONTEXTS[0].equals(verifiableCredential.getContexts().get(0))), "First value of @context must be " + VerifiableCredential.DEFAULT_JSONLD_CONTEXTS[0] + ": " + verifiableCredential.getContexts().get(0)); validateRun(() -> { if (verifiableCredential.getId() != null) validateUrl(verifiableCredential.getId()); }, "'id' must be a valid URI."); - validateRun(() -> { validateTrue(verifiableCredential.getTypes().size() > 0); }, "Bad or missing 'type'."); - validateRun(() -> { validateTrue(verifiableCredential.getTypes().contains(VerifiableCredential.DEFAULT_JSONLD_TYPES[0])); }, "'type' must contain 'VerifiableCredential': " + verifiableCredential.getTypes()); - validateRun(() -> { validateTrue(verifiableCredential.getIssuer() != null); }, "Bad or missing 'issuer'."); - validateRun(() -> { validateUrl(verifiableCredential.getIssuer()); }, "'issuer' must be a valid URI."); - validateRun(() -> { validateTrue(verifiableCredential.getIssuanceDate() != null); }, "Bad or missing 'issuanceDate'."); - validateRun(() -> { verifiableCredential.getExpirationDate(); }, "Bad 'expirationDate'."); - validateRun(() -> { verifiableCredential.getCredentialSubject(); }, "Bad 'credentialSubject'."); - validateRun(() -> { validateTrue(verifiableCredential.getCredentialSubject() != null); }, "Bad or missing 'credentialSubject'."); + validateRun(() -> validateTrue(!verifiableCredential.getTypes().isEmpty()), "Bad or missing 'type'."); + validateRun(() -> validateTrue(verifiableCredential.getTypes().contains(VerifiableCredential.DEFAULT_JSONLD_TYPES[0])), "'type' must contain 'VerifiableCredential': " + verifiableCredential.getTypes()); + validateRun(() -> validateTrue(verifiableCredential.getIssuer() != null), "Bad or missing 'issuer'."); + validateRun(() -> validateUrl(verifiableCredential.getIssuer()), "'issuer' must be a valid URI."); + validateRun(() -> validateTrue(verifiableCredential.getIssuanceDate() != null), "Bad or missing 'issuanceDate'."); + validateRun(verifiableCredential::getExpirationDate, "Bad 'expirationDate'."); + validateRun(verifiableCredential::getCredentialSubject, "Bad 'credentialSubject'."); + validateRun(() -> validateTrue(verifiableCredential.getCredentialSubject() != null), "Bad or missing 'credentialSubject'."); } public static void validate(VerifiablePresentation verifiablePresentation) throws IllegalStateException { foundation.identity.jsonld.validation.Validation.validate(verifiablePresentation); - validateRun(() -> { validateTrue(verifiablePresentation.getJsonObject() != null); }, "Bad or missing JSON object."); - validateRun(() -> { validateTrue(verifiablePresentation.getContexts().size() > 0); }, "Bad or missing '@context'."); - validateRun(() -> { validateUrl(verifiablePresentation.getContexts().get(0)); }, "@context must be a valid URI: " + verifiablePresentation.getContexts().get(0)); - validateRun(() -> { validateTrue(VerifiableCredential.DEFAULT_JSONLD_CONTEXTS[0].equals(verifiablePresentation.getContexts().get(0))); }, "First value of @context must be " + VerifiableCredential.DEFAULT_JSONLD_CONTEXTS[0] + ": " + verifiablePresentation.getContexts().get(0)); + validateRun(() -> validateTrue(verifiablePresentation.getJsonObject() != null), "Bad or missing JSON object."); + validateRun(() -> validateTrue(! verifiablePresentation.getContexts().isEmpty()), "Bad or missing '@context'."); + validateRun(() -> validateUrl(verifiablePresentation.getContexts().get(0)), "@context must be a valid URI: " + verifiablePresentation.getContexts().get(0)); + validateRun(() -> validateTrue(VerifiableCredential.DEFAULT_JSONLD_CONTEXTS[0].equals(verifiablePresentation.getContexts().get(0))), "First value of @context must be " + VerifiableCredential.DEFAULT_JSONLD_CONTEXTS[0] + ": " + verifiablePresentation.getContexts().get(0)); validateRun(() -> { if (verifiablePresentation.getId() != null) validateUrl(verifiablePresentation.getId()); }, "'id' must be a valid URI."); - validateRun(() -> { validateTrue(verifiablePresentation.getTypes().size() > 0); }, "Bad or missing 'type'."); - validateRun(() -> { validateTrue(verifiablePresentation.getTypes().contains(VerifiablePresentation.DEFAULT_JSONLD_TYPES[0])); }, "type must contain VerifiablePresentation: " + verifiablePresentation.getTypes()); - validateRun(() -> { validateTrue(verifiablePresentation.getVerifiableCredential() != null || verifiablePresentation.getJwtVerifiableCredentialString() != null); }, "Bad or missing 'verifiableCredential'."); + validateRun(() -> validateTrue(! verifiablePresentation.getTypes().isEmpty()), "Bad or missing 'type'."); + validateRun(() -> validateTrue(verifiablePresentation.getTypes().contains(VerifiablePresentation.DEFAULT_JSONLD_TYPES[0])), "type must contain VerifiablePresentation: " + verifiablePresentation.getTypes()); + validateRun(() -> validateTrue(verifiablePresentation.getVerifiableCredential() != null || verifiablePresentation.getJwtVerifiableCredentialString() != null), "Bad or missing 'verifiableCredential'."); } } diff --git a/src/main/java/com/danubetech/verifiablecredentials/w3ctestsuite/Generator.java b/src/main/java/com/danubetech/verifiablecredentials/w3ctestsuite/Generator.java index ea13aa8..265222b 100644 --- a/src/main/java/com/danubetech/verifiablecredentials/w3ctestsuite/Generator.java +++ b/src/main/java/com/danubetech/verifiablecredentials/w3ctestsuite/Generator.java @@ -42,13 +42,13 @@ public static void main(String[] args) throws Exception { String input = readInput(new File(argInput)); - if (input == null || input.trim().length() < 1) throw new NullPointerException(); + if (input.trim().isEmpty()) throw new NullPointerException(); // do the work try { - String output = null; + String output; if (argJwt == null) { @@ -165,7 +165,7 @@ static RSAKey readRSAKey(String jwt) throws ParseException, JOSEException { static String readInput(File input) throws Exception { BufferedReader reader = new BufferedReader(new FileReader(input)); - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); String line; while ((line = reader.readLine()) != null) buffer.append(line); diff --git a/src/test/java/com/danubetech/verifiablecredentials/JwtTest.java b/src/test/java/com/danubetech/verifiablecredentials/JwtTest.java index 03f209b..d8ed55b 100644 --- a/src/test/java/com/danubetech/verifiablecredentials/JwtTest.java +++ b/src/test/java/com/danubetech/verifiablecredentials/JwtTest.java @@ -16,7 +16,7 @@ public class JwtTest { - static RSAKey rsaKey; + static final RSAKey rsaKey; static { @@ -27,7 +27,7 @@ public class JwtTest { void testSign() throws Exception { Map claims = new LinkedHashMap<>(); - Map driversLicense = new LinkedHashMap(); + Map driversLicense = new LinkedHashMap<>(); driversLicense.put("licenseClass", "trucks"); driversLicense.put("suspended", Boolean.FALSE); claims.put("name", "M S"); diff --git a/src/test/java/com/danubetech/verifiablecredentials/SignCredentialTest.java b/src/test/java/com/danubetech/verifiablecredentials/SignCredentialTest.java index 6b5d0a1..76b05a4 100644 --- a/src/test/java/com/danubetech/verifiablecredentials/SignCredentialTest.java +++ b/src/test/java/com/danubetech/verifiablecredentials/SignCredentialTest.java @@ -11,6 +11,7 @@ import java.io.InputStreamReader; import java.net.URI; import java.util.Date; +import java.util.Objects; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -20,7 +21,7 @@ public class SignCredentialTest { @Test void testSign() throws Throwable { - VerifiableCredential verifiableCredential = VerifiableCredential.fromJson(new InputStreamReader(VerifyCredentialTest.class.getResourceAsStream("input.vc.jsonld"))); + VerifiableCredential verifiableCredential = VerifiableCredential.fromJson(new InputStreamReader(Objects.requireNonNull(VerifyCredentialTest.class.getResourceAsStream("input.vc.jsonld")))); URI verificationMethod = URI.create("did:sov:1yvXbmgPoUm4dl66D7KhyD#keys-1"); Date created = JsonLDUtils.DATE_FORMAT.parse("2018-01-01T21:19:10Z"); diff --git a/src/test/java/com/danubetech/verifiablecredentials/SignPresentationTest.java b/src/test/java/com/danubetech/verifiablecredentials/SignPresentationTest.java index 5af2f33..48cdfc4 100644 --- a/src/test/java/com/danubetech/verifiablecredentials/SignPresentationTest.java +++ b/src/test/java/com/danubetech/verifiablecredentials/SignPresentationTest.java @@ -11,6 +11,7 @@ import java.io.InputStreamReader; import java.net.URI; import java.util.Date; +import java.util.Objects; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -20,7 +21,7 @@ public class SignPresentationTest { @Test void testSign() throws Throwable { - VerifiablePresentation verifiablePresentation = VerifiablePresentation.fromJson(new InputStreamReader(VerifyCredentialTest.class.getResourceAsStream("input.vp.jsonld"))); + VerifiablePresentation verifiablePresentation = VerifiablePresentation.fromJson(new InputStreamReader(Objects.requireNonNull(VerifyCredentialTest.class.getResourceAsStream("input.vp.jsonld")))); URI verificationMethod = URI.create("did:sov:1yvXbmgPoUm4dl66D7KhyD#keys-1"); Date created = JsonLDUtils.DATE_FORMAT.parse("2018-01-01T21:19:10Z"); diff --git a/src/test/java/com/danubetech/verifiablecredentials/TestUtil.java b/src/test/java/com/danubetech/verifiablecredentials/TestUtil.java index a83a289..b7aeba1 100644 --- a/src/test/java/com/danubetech/verifiablecredentials/TestUtil.java +++ b/src/test/java/com/danubetech/verifiablecredentials/TestUtil.java @@ -30,45 +30,49 @@ public class TestUtil { "0343f9455cd248e24c262b1341bbe37cea360e1c5ce526e5d1a71373ba6e557018"; static final String testRSAPrivateKeyString = - "-----BEGIN PRIVATE KEY-----\n" + - "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC2lLVmZ9UpU/kq\n" + - "h8iEwE/S1JZziqWHp+baWtlKS4rFSMRpaPNlLOzvaAQgbGtpa6wx2hG5XnjGxZHJ\n" + - "/kp5lPRL4jk+uV7ch2LeAgKI7g3C8yTonBIFwlbCZIsUQrJRKcHYK1+IZzT/mtAK\n" + - "lwS38OfmIz4E2ft+qmgshuSzytcpQiPz6oxWqRNewQp4qKcTbe3XKQyV2w1po4f6\n" + - "G8a2Lkm3YMycfUmOhd0Nd/G9I//SCNRhvR6S251gVegDrB6SZDIl4ia+DHgzLPUj\n" + - "iIe2Rj8KnsngyfV6Nnoc2bK+hMT/g65jW4J5i/hTJcVzWzW5TJi2PjPnuqwcaxLh\n" + - "1DcDYwmzAgMBAAECggEAKp0KuZwCZGL1BLgsVM+N0edMNitl9wN5Hf2WOYDoIqOZ\n" + - "NAEKzdJuenIMhITJjRFUX05GVL138uyp2js/pqDdY9ipA7rAKThwGuDdNphZHech\n" + - "9ih3DGEPXs+YpmHqvIbCd3GoGm38MKwxYkddEpFnjo8rKna1/BpJthrFxjDRhw9D\n" + - "xJBycOdH2yWTyp62ZENPvneK40H2a57W4QScTgfecZqD59m2fGUaWaX5uUmIxaEm\n" + - "tGoJnd9RE4oywKhgN7/TK7wXRlqA4UoRPiH2ACrdU+/cLQL9Jc0u0GqZJK31LDbO\n" + - "eN95QgtSCc72k3Vtzy3CrVpp5TAA67s1Gj9Skn+CAQKBgQDkEZTVztp//mwXJ+xr\n" + - "6icgmCjkFm7y4e/PdTJvw4DRr4b1Q87VKEtiNfTBR+FlwUHt/A+2CaZgA3rAoZVx\n" + - "714wBtfg+WI+Tev4Fylm48qS4uT/AW+BYBDkerDaIS7BctXT97xzaBpS3+HIwLn6\n" + - "cVzi/QGa/o1Po9+vL5SsrcEpZwKBgQDM8P4H6eueDAX4730Ee9vjtcYpHs43wkIj\n" + - "onFq/MiS6wxcIHyszJhbzMuzrwvwksDNZnfigyrQU9SfKwHFzmdMXw1vgFnFNnn7\n" + - "1wd+gqthMjdhayZVbYWkIkUSMyzg1dnbw8GRL1vjON9LYqE12SYJ45hTS0mk1/CY\n" + - "5Mj3Sp5R1QKBgGia88P5I1ivbg5U3mhEtnuJrr+m1m6KWH6zx1VhuzTxqBnYZwZ3\n" + - "e9Po4YDBIk2UjVPFV8Nru6awEd5GfpAKdQ3cJannWDsxbDiXDwNFGYWzkcqwct9J\n" + - "G5Zf+7ugmpxZul+FcicQqXo3e4yjcOnAkxT9bH4VoOTVSeRFE5D8BOujAoGASwz1\n" + - "+m/vmTFN/pu1bK7vF7S5nNVrL4A0OFiEsGliCmuJWzOKdL14DiYxctvnw3H6qT2d\n" + - "KZZfV2tbse5N9+JecdldUjfuqAoLIe7dD7dKi42YOlTC9QXmqvTh1ohnJu8pmRFX\n" + - "EZQGUm/BVhoIb2/WPkjav6YSkguCUHt4HRd2YwECgYAGhy4I4Q6r6jIsMAvDMxdT\n" + - "yA5/cgvVDX8FbCx2gA2iHqLXv2mzGATgldOhZyldlBCq5vyeDATq5H1+l3ebo388\n" + - "vhPnm9sMPKM8qasva20LaA63H0quk+H5nstBGjgETjycckmvKy0od8WVofYbsnEc\n" + - "2AwFhUAPK203T2oShq/w6w==\n" + - "-----END PRIVATE KEY-----\n"; + """ + -----BEGIN PRIVATE KEY----- + MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC2lLVmZ9UpU/kq + h8iEwE/S1JZziqWHp+baWtlKS4rFSMRpaPNlLOzvaAQgbGtpa6wx2hG5XnjGxZHJ + /kp5lPRL4jk+uV7ch2LeAgKI7g3C8yTonBIFwlbCZIsUQrJRKcHYK1+IZzT/mtAK + lwS38OfmIz4E2ft+qmgshuSzytcpQiPz6oxWqRNewQp4qKcTbe3XKQyV2w1po4f6 + G8a2Lkm3YMycfUmOhd0Nd/G9I//SCNRhvR6S251gVegDrB6SZDIl4ia+DHgzLPUj + iIe2Rj8KnsngyfV6Nnoc2bK+hMT/g65jW4J5i/hTJcVzWzW5TJi2PjPnuqwcaxLh + 1DcDYwmzAgMBAAECggEAKp0KuZwCZGL1BLgsVM+N0edMNitl9wN5Hf2WOYDoIqOZ + NAEKzdJuenIMhITJjRFUX05GVL138uyp2js/pqDdY9ipA7rAKThwGuDdNphZHech + 9ih3DGEPXs+YpmHqvIbCd3GoGm38MKwxYkddEpFnjo8rKna1/BpJthrFxjDRhw9D + xJBycOdH2yWTyp62ZENPvneK40H2a57W4QScTgfecZqD59m2fGUaWaX5uUmIxaEm + tGoJnd9RE4oywKhgN7/TK7wXRlqA4UoRPiH2ACrdU+/cLQL9Jc0u0GqZJK31LDbO + eN95QgtSCc72k3Vtzy3CrVpp5TAA67s1Gj9Skn+CAQKBgQDkEZTVztp//mwXJ+xr + 6icgmCjkFm7y4e/PdTJvw4DRr4b1Q87VKEtiNfTBR+FlwUHt/A+2CaZgA3rAoZVx + 714wBtfg+WI+Tev4Fylm48qS4uT/AW+BYBDkerDaIS7BctXT97xzaBpS3+HIwLn6 + cVzi/QGa/o1Po9+vL5SsrcEpZwKBgQDM8P4H6eueDAX4730Ee9vjtcYpHs43wkIj + onFq/MiS6wxcIHyszJhbzMuzrwvwksDNZnfigyrQU9SfKwHFzmdMXw1vgFnFNnn7 + 1wd+gqthMjdhayZVbYWkIkUSMyzg1dnbw8GRL1vjON9LYqE12SYJ45hTS0mk1/CY + 5Mj3Sp5R1QKBgGia88P5I1ivbg5U3mhEtnuJrr+m1m6KWH6zx1VhuzTxqBnYZwZ3 + e9Po4YDBIk2UjVPFV8Nru6awEd5GfpAKdQ3cJannWDsxbDiXDwNFGYWzkcqwct9J + G5Zf+7ugmpxZul+FcicQqXo3e4yjcOnAkxT9bH4VoOTVSeRFE5D8BOujAoGASwz1 + +m/vmTFN/pu1bK7vF7S5nNVrL4A0OFiEsGliCmuJWzOKdL14DiYxctvnw3H6qT2d + KZZfV2tbse5N9+JecdldUjfuqAoLIe7dD7dKi42YOlTC9QXmqvTh1ohnJu8pmRFX + EZQGUm/BVhoIb2/WPkjav6YSkguCUHt4HRd2YwECgYAGhy4I4Q6r6jIsMAvDMxdT + yA5/cgvVDX8FbCx2gA2iHqLXv2mzGATgldOhZyldlBCq5vyeDATq5H1+l3ebo388 + vhPnm9sMPKM8qasva20LaA63H0quk+H5nstBGjgETjycckmvKy0od8WVofYbsnEc + 2AwFhUAPK203T2oShq/w6w== + -----END PRIVATE KEY----- + """; static final String testRSAPublicKeyString = - "-----BEGIN PUBLIC KEY-----\n" + - "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtpS1ZmfVKVP5KofIhMBP\n" + - "0tSWc4qlh6fm2lrZSkuKxUjEaWjzZSzs72gEIGxraWusMdoRuV54xsWRyf5KeZT0\n" + - "S+I5Prle3Idi3gICiO4NwvMk6JwSBcJWwmSLFEKyUSnB2CtfiGc0/5rQCpcEt/Dn\n" + - "5iM+BNn7fqpoLIbks8rXKUIj8+qMVqkTXsEKeKinE23t1ykMldsNaaOH+hvGti5J\n" + - "t2DMnH1JjoXdDXfxvSP/0gjUYb0ektudYFXoA6wekmQyJeImvgx4Myz1I4iHtkY/\n" + - "Cp7J4Mn1ejZ6HNmyvoTE/4OuY1uCeYv4UyXFc1s1uUyYtj4z57qsHGsS4dQ3A2MJ\n" + - "swIDAQAB\n" + - "-----END PUBLIC KEY-----\n"; + """ + -----BEGIN PUBLIC KEY----- + MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtpS1ZmfVKVP5KofIhMBP + 0tSWc4qlh6fm2lrZSkuKxUjEaWjzZSzs72gEIGxraWusMdoRuV54xsWRyf5KeZT0 + S+I5Prle3Idi3gICiO4NwvMk6JwSBcJWwmSLFEKyUSnB2CtfiGc0/5rQCpcEt/Dn + 5iM+BNn7fqpoLIbks8rXKUIj8+qMVqkTXsEKeKinE23t1ykMldsNaaOH+hvGti5J + t2DMnH1JjoXdDXfxvSP/0gjUYb0ektudYFXoA6wekmQyJeImvgx4Myz1I4iHtkY/ + Cp7J4Mn1ejZ6HNmyvoTE/4OuY1uCeYv4UyXFc1s1uUyYtj4z57qsHGsS4dQ3A2MJ + swIDAQAB + -----END PUBLIC KEY----- + """; static final byte[] testEd25519PrivateKey; static final byte[] testEd25519PublicKey; @@ -123,7 +127,7 @@ public class TestUtil { PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(encoded); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); - testRSAPrivateKey = new KeyPair(testRSAPublicKey, (RSAPrivateKey) keyFactory.generatePrivate(spec)); + testRSAPrivateKey = new KeyPair(testRSAPublicKey, keyFactory.generatePrivate(spec)); } catch (Exception ex) { throw new RuntimeException(ex.getMessage(), ex); @@ -133,10 +137,10 @@ public class TestUtil { static String read(InputStream inputStream) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); String line; - while ((line = reader.readLine()) != null) buffer.append(line + "\n"); + while ((line = reader.readLine()) != null) buffer.append(line).append("\n"); return buffer.toString(); } diff --git a/src/test/java/com/danubetech/verifiablecredentials/VerifyCredentialTest.java b/src/test/java/com/danubetech/verifiablecredentials/VerifyCredentialTest.java index 92c371b..a98a87b 100644 --- a/src/test/java/com/danubetech/verifiablecredentials/VerifyCredentialTest.java +++ b/src/test/java/com/danubetech/verifiablecredentials/VerifyCredentialTest.java @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test; import java.io.InputStreamReader; +import java.util.Objects; import static org.junit.jupiter.api.Assertions.*; @@ -13,7 +14,7 @@ public class VerifyCredentialTest { @Test void testVerify() throws Throwable { - VerifiableCredential verifiableCredential = VerifiableCredential.fromJson(new InputStreamReader(VerifyCredentialTest.class.getResourceAsStream("signed.good.vc.jsonld"))); + VerifiableCredential verifiableCredential = VerifiableCredential.fromJson(new InputStreamReader(Objects.requireNonNull(VerifyCredentialTest.class.getResourceAsStream("signed.good.vc.jsonld")))); Validation.validate(verifiableCredential); @@ -31,7 +32,7 @@ void testVerify() throws Throwable { @Test void testBadVerify() throws Throwable { - VerifiableCredential verifiableCredential = VerifiableCredential.fromJson(new InputStreamReader(VerifyCredentialTest.class.getResourceAsStream("signed.bad.vc.jsonld"))); + VerifiableCredential verifiableCredential = VerifiableCredential.fromJson(new InputStreamReader(Objects.requireNonNull(VerifyCredentialTest.class.getResourceAsStream("signed.bad.vc.jsonld")))); Validation.validate(verifiableCredential); diff --git a/src/test/java/com/danubetech/verifiablecredentials/VerifyPresentationTest.java b/src/test/java/com/danubetech/verifiablecredentials/VerifyPresentationTest.java index 7276c1d..39793c2 100644 --- a/src/test/java/com/danubetech/verifiablecredentials/VerifyPresentationTest.java +++ b/src/test/java/com/danubetech/verifiablecredentials/VerifyPresentationTest.java @@ -1,7 +1,5 @@ package com.danubetech.verifiablecredentials; -import com.danubetech.keyformats.crypto.provider.RandomProvider; -import com.danubetech.keyformats.crypto.provider.SHA256Provider; import com.danubetech.keyformats.crypto.provider.Ed25519Provider; import com.danubetech.keyformats.crypto.provider.RandomProvider; import com.danubetech.keyformats.crypto.provider.SHA256Provider; @@ -16,6 +14,7 @@ import java.io.InputStreamReader; import java.util.Map; +import java.util.Objects; import static org.junit.jupiter.api.Assertions.*; @@ -44,10 +43,10 @@ public class VerifyPresentationTest { publicKeyCredential1 = Base58.decode("5TVraf9itbKXrRvt2DSS95Gw4vqU3CHAdetoufdcKazA"); publicKeyCredential2 = Base58.decode("5yKdnU7ToTjAoRNDzfuzVTfWBH38qyhE1b9xh4v8JaWF"); - verifiablePresentationGood1 = VerifiablePresentation.fromJson(new InputStreamReader(VerifyPresentationTest.class.getResourceAsStream("signed.good.vp1.jsonld"))); - verifiablePresentationGood2 = VerifiablePresentation.fromJson(new InputStreamReader(VerifyPresentationTest.class.getResourceAsStream("signed.good.vp2.jsonld"))); - verifiablePresentationBad1 = VerifiablePresentation.fromJson(new InputStreamReader(VerifyPresentationTest.class.getResourceAsStream("signed.bad.vp1.jsonld"))); - verifiablePresentationBad2 = VerifiablePresentation.fromJson(new InputStreamReader(VerifyPresentationTest.class.getResourceAsStream("signed.bad.vp2.jsonld"))); + verifiablePresentationGood1 = VerifiablePresentation.fromJson(new InputStreamReader(Objects.requireNonNull(VerifyPresentationTest.class.getResourceAsStream("signed.good.vp1.jsonld")))); + verifiablePresentationGood2 = VerifiablePresentation.fromJson(new InputStreamReader(Objects.requireNonNull(VerifyPresentationTest.class.getResourceAsStream("signed.good.vp2.jsonld")))); + verifiablePresentationBad1 = VerifiablePresentation.fromJson(new InputStreamReader(Objects.requireNonNull(VerifyPresentationTest.class.getResourceAsStream("signed.bad.vp1.jsonld")))); + verifiablePresentationBad2 = VerifiablePresentation.fromJson(new InputStreamReader(Objects.requireNonNull(VerifyPresentationTest.class.getResourceAsStream("signed.bad.vp2.jsonld")))); verifiableCredentialGood1 = verifiablePresentationGood1.getVerifiableCredential(); verifiableCredentialGood2 = verifiablePresentationGood2.getVerifiableCredential(); verifiableCredentialBad1 = verifiablePresentationBad1.getVerifiableCredential();