Skip to content

Commit

Permalink
[INJIWEB-1167]: Multi-lingual support for credential download as pdf …
Browse files Browse the repository at this point in the history
…added to develop, Addressed Comments
  • Loading branch information
kamlesh012 committed Dec 24, 2024
1 parent fe66f1e commit 73b09cd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public ResponseEntity<?> downloadCredentialAsPDF(@RequestParam Map<String, Strin
String credentialType = params.get("credential");
String credentialValidity = params.get("vcStorageExpiryLimitInTimes");
String locale = params.get("locale");

log.info("Initiated Token Call");
TokenResponseDTO response = credentialService.getTokenResponse(params, issuerId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public ByteArrayInputStream downloadCredentialAsPDF(String issuerId, String cred
boolean verificationStatus = issuerId.toLowerCase().contains("mock") || verifyCredential(vcCredentialResponse);
if(verificationStatus) {
String dataShareUrl = QRCodeType.OnlineSharing.equals(issuerConfig.getQr_code_type()) ? dataShareService.storeDataInDataShare(objectMapper.writeValueAsString(vcCredentialResponse), credentialValidity) : "";
return generatePdfForVerifiableCredentials(issuerId, credentialType,vcCredentialResponse, issuerConfig, credentialsSupportedResponse, dataShareUrl, credentialValidity, locale);
return generatePdfForVerifiableCredentials(vcCredentialResponse, issuerConfig, credentialsSupportedResponse, dataShareUrl, credentialValidity, locale);
}
throw new VCVerificationException(SIGNATURE_VERIFICATION_EXCEPTION.getErrorCode(),
SIGNATURE_VERIFICATION_EXCEPTION.getErrorMessage());
Expand Down Expand Up @@ -158,10 +158,10 @@ public VCCredentialRequest generateVCCredentialRequest(IssuerDTO issuerDTO, Cred
.build();
}

public ByteArrayInputStream generatePdfForVerifiableCredentials(String issuerId, String credentialType, VCCredentialResponse vcCredentialResponse, IssuerDTO issuerDTO, CredentialsSupportedResponse credentialsSupportedResponse, String dataShareUrl, String credentialValidity, String locale) throws Exception {
public ByteArrayInputStream generatePdfForVerifiableCredentials(VCCredentialResponse vcCredentialResponse, IssuerDTO issuerDTO, CredentialsSupportedResponse credentialsSupportedResponse, String dataShareUrl, String credentialValidity, String locale) throws Exception {
LinkedHashMap<String, Object> displayProperties = loadDisplayPropertiesFromWellknown(vcCredentialResponse, credentialsSupportedResponse, locale);
Map<String, Object> data = getPdfResourceFromVcProperties(displayProperties, credentialsSupportedResponse, vcCredentialResponse, issuerDTO, dataShareUrl, credentialValidity, locale);
return renderVCInCredentialTemplate(data, issuerId, credentialType);
return renderVCInCredentialTemplate(data);
}

public Boolean verifyCredential(VCCredentialResponse vcCredentialResponse) throws VCVerificationException, JsonProcessingException {
Expand Down Expand Up @@ -242,8 +242,8 @@ private Map<String, Object> getPdfResourceFromVcProperties(LinkedHashMap<String,
}

@NotNull
private ByteArrayInputStream renderVCInCredentialTemplate(Map<String, Object> data, String issuerId, String credentialType) throws IOException {
String credentialTemplate = utilities.getCredentialSupportedTemplateString(issuerId, credentialType);
private ByteArrayInputStream renderVCInCredentialTemplate(Map<String, Object> data) throws IOException {
String credentialTemplate = utilities.getCredentialSupportedTemplateString();
Properties props = new Properties();
props.setProperty("resource.loader", "class");
props.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/mosip/mimoto/util/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,12 @@ public String getIssuersConfigJsonValue() {
public String getTrustedVerifiersJsonValue() {
return getJson(trustedVerifiersJsonString, trustedVerifiersPath);
}
public String getCredentialSupportedTemplateString(String issuerId, String credentialType) {
public String getCredentialSupportedTemplateString() {
if(activeProfile.equals("local")) {
return credentialTemplateHtmlString;
}
return getJson(configServerFileStorageURL, String.format("%s-%s-template.html", issuerId, credentialType));
return (credentialTemplateHtmlString != null && !credentialTemplateHtmlString.isEmpty()) ?
credentialTemplateHtmlString : getJson(configServerFileStorageURL,credentialTemplatePath );
}
public static String[] handleExceptionWithErrorCode(Exception exception) {
String errorMessage = exception.getMessage();
Expand Down

0 comments on commit 73b09cd

Please sign in to comment.