Skip to content

Commit

Permalink
feat: credential get api type filter support added
Browse files Browse the repository at this point in the history
  • Loading branch information
thackerronak committed Jun 2, 2023
1 parent 88651fa commit 9d6a49d
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
import org.eclipse.tractusx.ssi.lib.proof.LinkedDataProofValidation;
import org.eclipse.tractusx.ssi.lib.resolver.DidDocumentResolverRegistryImpl;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
Expand Down Expand Up @@ -133,16 +135,21 @@ public List<VerifiableCredential> getCredentials(String credentialId, String iss
if (StringUtils.hasText(credentialId)) {
filterRequest.appendNewCriteria("credentialId", Operator.EQUALS, credentialId);
}

Specification<Credential> sps = getSpecificationUtil().generateSpecification(filterRequest.getCriteria());
FilterRequest request = new FilterRequest();
if (!CollectionUtils.isEmpty(type)) {
filterRequest.appendNewCriteria("type", Operator.IN, type);
for (String str : type) {
request.appendNewCriteria("type", Operator.CONTAIN, str);
}
Specification<Credential> sp = getSpecificationUtil().generateOrSpecification(request.getCriteria());
sps = sp.and(sps);
}

Sort sort = new Sort();
sort.setColumn(sortColumn);
sort.setSortType(SortType.valueOf(sortType.toUpperCase()));
filterRequest.setSort(sort);
Page<Credential> filter = filter(filterRequest);
Page<Credential> filter = getRepository().findAll(sps, PageRequest.of(0, 1000));

List<VerifiableCredential> list = new ArrayList<>(filter.getContent().size());
for (Credential credential : filter.getContent()) {
Expand Down Expand Up @@ -294,10 +301,10 @@ public Map<String, Object> credentialsValidation(Map<String, Object> data) {
new DidWebDocumentResolver(httpClient, didParser, enforceHttps));

LinkedDataProofValidation proofValidation = LinkedDataProofValidation.newInstance(didDocumentResolverRegistry);
Boolean valid = proofValidation.checkProof(verifiableCredential); // TODO getting InvalidKeyException
Boolean valid = proofValidation.checkProof(verifiableCredential);
Map<String, Object> response = new HashMap<>();
response.put("valid", valid);
response.put("vp", verifiableCredential);
response.put("vc", verifiableCredential);

return response;
}
Expand Down

0 comments on commit 9d6a49d

Please sign in to comment.