Skip to content

Commit

Permalink
[INJIMOB-1588] extract data generation for mdoc to a separate function
Browse files Browse the repository at this point in the history
Signed-off-by: KiruthikaJeyashankar <[email protected]>
  • Loading branch information
KiruthikaJeyashankar committed Oct 8, 2024
1 parent ce54ddc commit 64c2b73
Showing 1 changed file with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,25 +250,11 @@ public VCResult<String> getVerifiableCredential(VCRequestDto vcRequestDto, Strin
throw new VCIExchangeException(ErrorConstants.VCI_EXCHANGE_FAILED);
}

log.info("Setting up the data for mDoc");
data.put("issue_date", "2024-01-12");
data.put("expiry_date", "2025-01-12");
data.put("family_name","Agatha");
data.put("given_name","Joseph");
data.put("birth_date", "1994-11-06");
data.put("issuing_country", "Island");
data.put("document_number",documentNumber);
data.put("driving_privileges",new HashMap<>(){{
put("vehicle_category_code","A");
put("issue_date","2023-01-01");
put("expiry_date","2043-01-01");
}});

if(vcRequestDto.getFormat().equals("mso_mdoc")){
VCResult<String> vcResult = new VCResult<>();
String mdocVc = null;
try {
mdocVc = new io.mosip.certify.mock.integration.mocks.MdocGenerator().generate(data,holderId, caKeyAndCertificate,issuerKeyAndCertificate);
mdocVc = new io.mosip.certify.mock.integration.mocks.MdocGenerator().generate(mockDataForMsoMdoc(documentNumber),holderId, caKeyAndCertificate,issuerKeyAndCertificate);
} catch (Exception e) {
log.error("Exception on mdoc creation", e);
throw new VCIExchangeException(ErrorConstants.VCI_EXCHANGE_FAILED);
Expand All @@ -281,6 +267,25 @@ public VCResult<String> getVerifiableCredential(VCRequestDto vcRequestDto, Strin
throw new VCIExchangeException(ErrorConstants.NOT_IMPLEMENTED);
}

private Map<String, Object> mockDataForMsoMdoc(String documentNumber) {
Map<String, Object> data = new HashMap<>();
log.info("Setting up the data for mDoc");
//TODO: Populate datetime in real time
data.put("issue_date", "2024-01-12");
data.put("expiry_date", "2025-01-12");
data.put("family_name","Agatha");
data.put("given_name","Joseph");
data.put("birth_date", "1994-11-06");
data.put("issuing_country", "Island");
data.put("document_number", documentNumber);
data.put("driving_privileges",new HashMap<>(){{
put("vehicle_category_code","A");
put("issue_date","2023-01-01");
put("expiry_date","2043-01-01");
}});
return data;
}

public OIDCTransaction getUserInfoTransaction(String accessTokenHash) {
return cacheManager.getCache(USERINFO_CACHE).get(accessTokenHash, OIDCTransaction.class);
}
Expand Down

0 comments on commit 64c2b73

Please sign in to comment.