diff --git a/src/main/java/tng/trustnetwork/keydistribution/service/did/DidTrustListService.java b/src/main/java/tng/trustnetwork/keydistribution/service/did/DidTrustListService.java index 673f132..eaf8543 100644 --- a/src/main/java/tng/trustnetwork/keydistribution/service/did/DidTrustListService.java +++ b/src/main/java/tng/trustnetwork/keydistribution/service/did/DidTrustListService.java @@ -171,7 +171,7 @@ public String generateTrustListVerificationId(SignerInformationEntity signerInfo } return getDocumentId(false) + stringBuilder + SEPARATOR_DID_ID - + encodeKid(signerInformationEntity.getKid()); + + signerInformationEntity.getKid(); } } @@ -266,7 +266,7 @@ public void job() { () -> signerInformationEntitiesList, Collections::emptyList, () -> new ArrayList<>( - signerInformationEntitiesList.stream().map(entity -> encodeKid(entity.getKid())) + signerInformationEntitiesList.stream().map(entity -> entity.getKid()) .collect(Collectors.toSet())))); }))); @@ -282,7 +282,7 @@ public void job() { () -> signerInformationEntitiesList, Collections::emptyList, () -> new ArrayList<>( - signerInformationEntitiesList.stream().map(entity -> encodeKid(entity.getKid())) + signerInformationEntitiesList.stream().map(entity -> entity.getKid()) .collect(Collectors.toSet())))); })); @@ -298,7 +298,7 @@ public void job() { () -> signerInformationEntitiesList, Collections::emptyList, () -> new ArrayList<>( - signerInformationEntitiesList.stream().map(entity -> encodeKid(entity.getKid())) + signerInformationEntitiesList.stream().map(entity -> entity.getKid()) .collect(Collectors.toSet())))); })); @@ -332,7 +332,7 @@ public void job() { Collections::emptyList, () -> new ArrayList<>( signerInformationEntitiesList.stream() - .map(entity -> encodeKid(entity.getKid())) + .map(entity -> entity.getKid()) .collect(Collectors.toSet())))); }); @@ -359,7 +359,7 @@ public void job() { signerInformationEntitiesList.forEach(entity -> { didSpecifications.add(new DidSpecification( List.of(domain, getParticipantCode(country), getMappedGroupName(group), - encodeKid(entity.getKid())), + entity.getKid()), () -> signerInformationService.getCertificatesByDomainParticipantGroupKid( domain, country, group, entity.getKid()), @@ -382,7 +382,7 @@ public void job() { didSpecifications.add(new DidSpecification( List.of(WILDCARD_CHAR, getParticipantCode(country), getMappedGroupName(group), - encodeKid(entity.getKid())), + entity.getKid()), () -> signerInformationService.getCertificatesByKidGroupCountry( country, group, entity.getKid()), @@ -402,7 +402,7 @@ public void job() { signerInformationEntitiesList.forEach(entity -> { didSpecifications.add(new DidSpecification( List.of(domain, WILDCARD_CHAR, getMappedGroupName(group), - encodeKid(entity.getKid())), + entity.getKid()), () -> signerInformationService.getCertificatesByDomainGroupKid( domain, group, entity.getKid()), @@ -421,7 +421,7 @@ public void job() { signerInformationEntitiesList.forEach(entity -> { didSpecifications.add(new DidSpecification( List.of(WILDCARD_CHAR, WILDCARD_CHAR, getMappedGroupName(group), - encodeKid(entity.getKid())), + entity.getKid()), () -> signerInformationService.getCertificatesByGroupKid(group, entity.getKid()), @@ -622,7 +622,7 @@ private void addTrustListEntry(DidTrustList trustList, trustListEntry.setType("JsonWebKey2020"); trustListEntry.setId(specification.generateTrustListVerificationId(signerInformationEntity)); trustListEntry.setController(specification.getControllerId(false)); - publicKeyJwk.setKid(encodeKid(signerInformationEntity.getKid())); + publicKeyJwk.setKid(signerInformationEntity.getKid()); trustListEntry.setPublicKeyJwk(publicKeyJwk); trustList.getVerificationMethod().add(trustListEntry); @@ -703,7 +703,4 @@ private String generateNonce() { return nonce.toString(); } - private String encodeKid(String kid) { - return Base64URL.encode(kid).toString(); - } } diff --git a/src/test/java/tng/trustnetwork/keydistribution/service/DidTrustListServiceTest.java b/src/test/java/tng/trustnetwork/keydistribution/service/DidTrustListServiceTest.java index 774dcbe..57c1e49 100644 --- a/src/test/java/tng/trustnetwork/keydistribution/service/DidTrustListServiceTest.java +++ b/src/test/java/tng/trustnetwork/keydistribution/service/DidTrustListServiceTest.java @@ -127,8 +127,8 @@ void testData(CertificateTestUtils.SignerType signerType) throws Exception { certDscEuKid = certificateUtils.getCertKid(certDscEu); certUploadDe = CertificateTestUtils.generateCertificate(keyPairGenerator.generateKeyPair(), "DE", - "Upload Test", certCscaDe, cscaDeKeyPair.getPrivate(), - signerType); + "Upload Test", certCscaDe, cscaDeKeyPair.getPrivate(), + signerType); certUploadDeKid = certificateUtils.getCertKid(certUploadDe); signerInformationRepository.save(new SignerInformationEntity( @@ -230,26 +230,26 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist", parsed.getController()); Assertions.assertEquals(4, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist" , encodeKid(certDscDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist" , certDscDeKid), certDscDeKid, certDscDe, certCscaDe, "did:web:abc:trustlist"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist" , encodeKid(certCscaDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist" , certCscaDeKid), certCscaDeKid, certCscaDe, null, "did:web:abc:trustlist"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist",encodeKid(certDscEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist",certDscEuKid), certDscEuKid, certDscEu, certCscaEu, "did:web:abc:trustlist"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist",encodeKid(certCscaEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist",certCscaEuKid), certCscaEuKid, certCscaEu, null, "did:web:abc:trustlist"); break; case "did:web:abc:trustlist:-": Assertions.assertEquals("did:web:abc:trustlist", parsed.getController()); Assertions.assertEquals(4, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-",encodeKid(certDscDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-",certDscDeKid), certDscDeKid, certDscDe, certCscaDe, "did:web:abc:trustlist:-"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-",encodeKid(certCscaDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-",certCscaDeKid), certCscaDeKid, certCscaDe, null, "did:web:abc:trustlist:-"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-",encodeKid(certDscEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-",certDscEuKid), certDscEuKid, certDscEu, certCscaEu, "did:web:abc:trustlist:-"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-",encodeKid(certCscaEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-",certCscaEuKid), certCscaEuKid, certCscaEu, null, "did:web:abc:trustlist:-"); break; @@ -257,9 +257,9 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:-", parsed.getController()); Assertions.assertEquals(4, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:-",encodeKid(certDscDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:-",certDscDeKid), certDscDeKid, certDscDe, certCscaDe, "did:web:abc:trustlist:-:-"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:-",encodeKid(certDscEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:-",certDscEuKid), certDscEuKid, certDscEu, certCscaEu, "did:web:abc:trustlist:-:-"); break; @@ -267,9 +267,9 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:DCC", parsed.getController()); Assertions.assertEquals(4, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:-",encodeKid(certDscDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:-",certDscDeKid), certDscDeKid, certDscDe, certCscaDe, "did:web:abc:trustlist:DCC:-"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:-",encodeKid(certDscEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:-",certDscEuKid), certDscEuKid, certDscEu, certCscaEu, "did:web:abc:trustlist:DCC:-"); break; @@ -278,7 +278,7 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:DCC:XEU", parsed.getController()); Assertions.assertEquals(1, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:XEU:DSC",encodeKid(certDscEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:XEU:DSC",certDscEuKid), certDscEuKid, certDscEu, certCscaEu, "did:web:abc:trustlist:DCC:XEU:DSC"); break; @@ -286,9 +286,9 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist", parsed.getController()); Assertions.assertEquals(4, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC", encodeKid(certDscDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC", certDscDeKid), certDscDeKid, certDscDe, certCscaDe, "did:web:abc:trustlist:DCC"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC", encodeKid(certDscEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC", certDscEuKid), certDscEuKid, certDscEu, certCscaEu, "did:web:abc:trustlist:DCC"); break; @@ -296,9 +296,9 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:-", parsed.getController()); Assertions.assertEquals(2, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:XEU",encodeKid(certCscaEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:XEU",certCscaEuKid), certCscaEuKid, certCscaEu, null, "did:web:abc:trustlist:-:XEU"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:XEU",encodeKid(certDscEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:XEU",certDscEuKid), certDscEuKid, certDscEu, certCscaEu, "did:web:abc:trustlist:-:XEU"); break; @@ -306,9 +306,9 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:-", parsed.getController()); Assertions.assertEquals(2, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:DEU",encodeKid(certDscDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:DEU",certDscDeKid), certDscDeKid, certDscDe, certCscaDe, "did:web:abc:trustlist:-:DEU"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:DEU",encodeKid(certCscaDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:DEU",certCscaDeKid), certCscaDeKid, certCscaDe, null, "did:web:abc:trustlist:-:DEU"); break; @@ -316,7 +316,7 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:DCC:XEU", parsed.getController()); Assertions.assertEquals(1, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:XEU:CSA",encodeKid(certCscaEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:XEU:CSA",certCscaEuKid), certCscaEuKid, certCscaEu, null, "did:web:abc:trustlist:DCC:XEU:CSA"); break; @@ -324,7 +324,7 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:DCC:DEU", parsed.getController()); Assertions.assertEquals(1, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:DEU:DSC",encodeKid(certDscDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:DEU:DSC",certDscDeKid), certDscDeKid, certDscDe, certCscaDe, "did:web:abc:trustlist:DCC:DEU:DSC"); break; @@ -332,7 +332,7 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:DCC:DEU", parsed.getController()); Assertions.assertEquals(1, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:DEU:CSA",encodeKid(certCscaDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:DEU:CSA",certCscaDeKid), certCscaDeKid, certCscaDe, null, "did:web:abc:trustlist:DCC:DEU:CSA"); break; @@ -341,9 +341,9 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:DCC", parsed.getController()); Assertions.assertEquals(2, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:DEU",encodeKid(certDscDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:DEU",certDscDeKid), certDscDeKid, certDscDe, certCscaDe, "did:web:abc:trustlist:DCC:DEU"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:DEU",encodeKid(certCscaDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:DEU",certCscaDeKid), certCscaDeKid, certCscaDe, null, "did:web:abc:trustlist:DCC:DEU"); break; @@ -351,9 +351,9 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:DCC", parsed.getController()); Assertions.assertEquals(2, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:XEU",encodeKid(certDscEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:XEU",certDscEuKid), certDscEuKid, certDscEu, certCscaEu, "did:web:abc:trustlist:DCC:XEU"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:XEU",encodeKid(certCscaEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:XEU",certCscaEuKid), certCscaEuKid, certCscaEu, null, "did:web:abc:trustlist:DCC:XEU"); break; @@ -361,7 +361,7 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:-:XEU", parsed.getController()); Assertions.assertEquals(1, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:XEU:DSC",encodeKid(certDscEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:XEU:DSC",certDscEuKid), certDscEuKid, certDscEu, certCscaEu, "did:web:abc:trustlist:-:XEU:DSC"); break; @@ -369,7 +369,7 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:-:DEU", parsed.getController()); Assertions.assertEquals(1, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:DEU:DSC",encodeKid(certDscDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:DEU:DSC",certDscDeKid), certDscDeKid, certDscDe, certCscaDe, "did:web:abc:trustlist:-:DEU:DSC"); break; @@ -377,7 +377,7 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:-:DEU", parsed.getController()); Assertions.assertEquals(1, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:DEU:CSA",encodeKid(certCscaDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:DEU:CSA",certCscaDeKid), certCscaDeKid, certCscaDe, null, "did:web:abc:trustlist:-:DEU:CSA"); break; @@ -385,9 +385,9 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:-:-", parsed.getController()); Assertions.assertEquals(2, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:-:CSA",encodeKid(certCscaEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:-:CSA",certCscaEuKid), certCscaEuKid, certCscaEu, null, "did:web:abc:trustlist:-:-:CSA"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:-:CSA",encodeKid(certCscaDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:-:CSA",certCscaDeKid), certCscaDeKid, certCscaDe, null, "did:web:abc:trustlist:-:-:CSA"); break; @@ -395,9 +395,9 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:-:-", parsed.getController()); Assertions.assertEquals(2, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:-:DSC",encodeKid(certDscEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:-:DSC",certDscEuKid), certDscEuKid, certDscEu, certCscaEu, "did:web:abc:trustlist:-:-:DSC"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:-:DSC",encodeKid(certDscDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:-:DSC",certDscDeKid), certDscDeKid, certDscDe, certCscaDe, "did:web:abc:trustlist:-:-:DSC"); break; @@ -405,7 +405,7 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:-:XEU", parsed.getController()); Assertions.assertEquals(1, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:XEU:CSA",encodeKid(certCscaEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:-:XEU:CSA",certCscaEuKid), certCscaEuKid, certCscaEu, null, "did:web:abc:trustlist:-:XEU:CSA"); break; @@ -413,9 +413,9 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:DCC:-", parsed.getController()); Assertions.assertEquals(2, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:-:DSC",encodeKid(certDscDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:-:DSC",certDscDeKid), certDscDeKid, certDscDe, certCscaDe, "did:web:abc:trustlist:DCC:-:DSC"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:-:DSC",encodeKid(certDscEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:-:DSC",certDscEuKid), certDscEuKid, certDscEu, certCscaEu, "did:web:abc:trustlist:DCC:-:DSC"); break; @@ -423,9 +423,9 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:DCC:-", parsed.getController()); Assertions.assertEquals(2, parsed.getVerificationMethod().size()); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:-:CSA",encodeKid(certCscaDeKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:-:CSA",certCscaDeKid), certCscaDeKid, certCscaDe, null, "did:web:abc:trustlist:DCC:-:CSA"); - assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:-:CSA",encodeKid(certCscaEuKid)), + assertVerificationMethod(getVerificationMethodByKid(parsed.getVerificationMethod(),"did:web:abc:trustlist:DCC:-:CSA",certCscaEuKid), certCscaEuKid, certCscaEu, null, "did:web:abc:trustlist:DCC:-:CSA"); break; @@ -438,7 +438,7 @@ void testTrustList(boolean isEcAlgorithm) throws Exception { Assertions.assertEquals("did:web:abc:trustlist:DCC", parsed.getController()); Assertions.assertEquals(0, parsed.getVerificationMethod().size()); break; - + case "did:web:abc:trustlist-ref:DCC:EU": Assertions.assertFalse(parsed.getVerificationMethod().contains("did:trusted:DE:issuer")); Assertions.assertTrue(parsed.getVerificationMethod().contains("did:trusted:EU:issuer")); @@ -502,7 +502,7 @@ private void assertVerificationMethod(Object in, String kid, X509Certificate dsc LinkedHashMap jsonNode = (LinkedHashMap) in; Assertions.assertEquals("JsonWebKey2020", jsonNode.get("type")); - Assertions.assertTrue(jsonNode.get("id").toString().contains(parentDidId) && jsonNode.get("id").toString().contains(encodeKid(kid)));; + Assertions.assertTrue(jsonNode.get("id").toString().contains(parentDidId) && jsonNode.get("id").toString().contains(kid)); LinkedHashMap publicKeyJwk = (LinkedHashMap) jsonNode.get("publicKeyJwk"); @@ -515,7 +515,7 @@ private void assertVerificationMethod(Object in, String kid, X509Certificate dsc Assertions.assertEquals(CertificateTestUtils.SignerType.EC.getSigningAlgorithm(), publicKeyJwk.get("kty").toString()); Assertions.assertEquals("P-256", publicKeyJwk.get("crv").toString()); - Assertions.assertEquals(encodeKid(kid), publicKeyJwk.get("kid")); + Assertions.assertEquals(kid, publicKeyJwk.get("kid")); } else { Assertions.assertEquals(((RSAPublicKey) dsc.getPublicKey()).getPublicExponent(), new BigInteger(Base64.getUrlDecoder().decode(publicKeyJwk.get("e").toString()))); @@ -523,7 +523,7 @@ private void assertVerificationMethod(Object in, String kid, X509Certificate dsc new BigInteger(Base64.getUrlDecoder().decode(publicKeyJwk.get("n").toString()))); Assertions.assertEquals(CertificateTestUtils.SignerType.RSA.getSigningAlgorithm(), publicKeyJwk.get("kty").toString()); - Assertions.assertEquals(encodeKid(kid), publicKeyJwk.get("kid")); + Assertions.assertEquals(kid, publicKeyJwk.get("kid")); } ArrayList x5c = ((ArrayList) publicKeyJwk.get("x5c")); Assertions.assertEquals(Base64.getEncoder().encodeToString(dsc.getEncoded()), x5c.get(0)); @@ -531,9 +531,6 @@ private void assertVerificationMethod(Object in, String kid, X509Certificate dsc Assertions.assertEquals(Base64.getEncoder().encodeToString(csca.getEncoded()), x5c.get(1)); } } - private String encodeKid(String kid) { - return Base64URL.encode(kid).toString(); - } @Getter @Setter