Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP-32453: Fixed pdf generation issue #245

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@
<io.micrometer.prometheus.version>1.4.2</io.micrometer.prometheus.version>
<gson.version>2.8.4</gson.version>
<kernel.websub.version>1.3.0-SNAPSHOT</kernel.websub.version>
<itextcore.version>7.2.4</itextcore.version>
<itextcore.version>7.1.0</itextcore.version>
<itexthtml2pdf.version>2.0.0</itexthtml2pdf.version>
<itext.version>5.5.13</itext.version>
<itext.version>5.5.13.3</itext.version>
<commons-math3>3.6.1</commons-math3>
<commons-io>2.6</commons-io>
<commons-codec>1.11</commons-codec>
<bouncycastle.version>1.78</bouncycastle.version>
<bouncycastle.version>1.66</bouncycastle.version>
<jwt.version> 3.8.1</jwt.version>
<google.zxing.version>3.4.1</google.zxing.version>
</properties>
Expand Down Expand Up @@ -155,7 +155,12 @@
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15to18</artifactId>
<artifactId>bcprov-jdk15on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -240,18 +245,18 @@
<dependency>
<groupId>io.mosip.vercred</groupId>
<artifactId>vcverifier</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.13</version>
</dependency>
<!--<dependency>
<!-- <dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-auth-adapter</artifactId>
<version>1.2.1-java21-SNAPSHOT</version>
<version>1.2.1-SNAPSHOT</version>
</dependency>-->
</dependencies>

Expand Down
5 changes: 0 additions & 5 deletions src/main/java/io/mosip/print/PrintPDFApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ public CbeffUtil getCbeffUtil() {
return new CbeffImpl();
}

@Bean
public CredentialsVerifier credentialsVerifier() {
return new CredentialsVerifier();
}

@Bean
public ThreadPoolTaskScheduler taskScheduler() {
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
Expand Down
17 changes: 6 additions & 11 deletions src/main/java/io/mosip/print/service/impl/PrintServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import io.mosip.print.exception.*;
import io.mosip.vercred.CredentialsVerifier;
import io.mosip.vercred.exception.ProofDocumentNotFoundException;
import io.mosip.vercred.exception.ProofTypeNotFoundException;
import io.mosip.vercred.exception.PubicKeyNotFoundException;
import io.mosip.vercred.exception.ProofTypeNotSupportedException;
import io.mosip.vercred.exception.PublicKeyNotFoundException;
import io.mosip.vercred.exception.UnknownException;
import org.apache.commons.codec.binary.Base64;
import org.joda.time.DateTime;
Expand All @@ -49,7 +48,6 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import io.mosip.print.constant.CredentialStatusConstant;
import io.mosip.print.constant.EventId;
Expand Down Expand Up @@ -177,8 +175,7 @@ public class PrintServiceImpl implements PrintService {
@Autowired
private Environment env;

@Autowired
private CredentialsVerifier credentialsVerifier;
private CredentialsVerifier credentialsVerifier= new CredentialsVerifier();

@Value("${mosip.datashare.partner.id}")
private String partnerId;
Expand Down Expand Up @@ -241,17 +238,17 @@ private boolean hasPrintCredentialVerified(EventModel eventModel, String decoded
if (verifyCredentialsFlag) {
printLogger.info("Configured received credentials to be verified. Flag {}", verifyCredentialsFlag);
try {
boolean verified = credentialsVerifier.verifyPrintCredentials(decodedCredential);
boolean verified = credentialsVerifier.verifyCredentials(decodedCredential);
if (!verified) {
printLogger.error("Received Credentials failed in verifiable credential verify method. So, the credentials will not be printed." +
" Id: {}, Transaction Id: {}", eventModel.getEvent().getId(), eventModel.getEvent().getTransactionId());
return false;
}
} catch (ProofDocumentNotFoundException | ProofTypeNotFoundException e) {
} catch (ProofDocumentNotFoundException | ProofTypeNotSupportedException e) {
printLogger.error("Proof document is not available in the received credentials." +
" Id: {}, Transaction Id: {}", eventModel.getEvent().getId(), eventModel.getEvent().getTransactionId());
return false;
} catch (UnknownException | PubicKeyNotFoundException e) {
} catch (UnknownException | PublicKeyNotFoundException e) {
printLogger.error("Received Credentials failed in verifiable credential verify method. So, the credentials will not be printed." +
" Id: {}, Transaction Id: {}", eventModel.getEvent().getId(), eventModel.getEvent().getTransactionId());
return false;
Expand Down Expand Up @@ -394,8 +391,6 @@ private Map<String, byte[]> getDocuments(String credential, String credentialTyp
description.setMessage(PlatformErrorMessages.PRT_PRT_PDF_GENERATION_FAILED.getMessage());
description.setCode(PlatformErrorMessages.PRT_PRT_PDF_GENERATION_FAILED.getCode());
printLogger.error(ex.getMessage() ,ex);
throw new PDFGeneratorException(PDFGeneratorExceptionCodeConstant.PDF_EXCEPTION.getErrorCode(),
ex.getMessage() ,ex);

} finally {
String eventId = "";
Expand Down
Loading