certificateEntry;
+
+ /**
+ * Key creation time
+ */
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ @ApiModelProperty(notes = "Timestamp of issuance of public key", required = true)
+ private LocalDateTime issuedAt;
+
+ /**
+ * Key expiry time
+ */
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ @ApiModelProperty(notes = "Timestamp of expiry of public key", required = true)
+ private LocalDateTime expiryAt;
+
+ /**
+ * The string keystore provider name
+ */
+ private String providerName;
+
+
+ @Override
+ public String toString() {
+ return "SignatureCertificate [alias=" + alias + ", certificateEntry=" + certificateEntry + ", issuedAt="
+ + issuedAt + ", expiryAt=" + expiryAt + "]";
+ }
+
+}
diff --git a/src/main/java/io/mosip/print/entity/MspCardEntity.java b/src/main/java/io/mosip/print/entity/MspCardEntity.java
new file mode 100644
index 00000000..197e8f29
--- /dev/null
+++ b/src/main/java/io/mosip/print/entity/MspCardEntity.java
@@ -0,0 +1,84 @@
+package io.mosip.print.entity;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.springframework.stereotype.Component;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * The persistent class Processed RegPrc print List database table.
+ *
+ * @author Thamaraikannan
+ * @since 1.0.0
+ */
+
+@Component
+@Entity
+@NoArgsConstructor
+@Getter
+@Setter
+@Table(name = "msp_card", schema = "print")
+public class MspCardEntity implements Serializable {
+ /**
+ * The Id.
+ */
+ @Id
+ @Column(name = "id")
+ private String id;
+
+ /**
+ * The Json Data.
+ */
+ @Column(name = "json_data")
+ private String jsonData;
+
+ /**
+ * The Province.
+ */
+ @Column(name = "province")
+ private String province;
+
+ @Column(name = "city")
+ private String city;
+
+ @Column(name = "zone")
+ private String zone;
+
+ @Column(name = "agegroup")
+ private Integer ageGroup;
+
+ @Column(name = "introducer")
+ private String introducer;
+
+ @Column(name = "resident")
+ private String resident;
+
+ @Column(name = "registration_center_id")
+ private String registrationCenterId;
+
+ @Column(name = "registration_date")
+ private LocalDateTime registrationDate;
+
+ @Column(name = "download_date")
+ private LocalDateTime downloadDate;
+
+ @Column(name = "request_id")
+ private String requestId;
+
+ @Column(name = "status")
+ private Integer status;
+
+ @Column(name = "request_id1")
+ private String requestId1;
+
+ @Column(name = "birthdate")
+ private Date birthDate;
+}
diff --git a/src/main/java/io/mosip/print/exception/AccessDeniedException.java b/src/main/java/io/mosip/print/exception/AccessDeniedException.java
index b56b738f..5ec74f50 100644
--- a/src/main/java/io/mosip/print/exception/AccessDeniedException.java
+++ b/src/main/java/io/mosip/print/exception/AccessDeniedException.java
@@ -1,6 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseUncheckedException;
public class AccessDeniedException extends BaseUncheckedException {
diff --git a/src/main/java/io/mosip/print/exception/ApiNotAccessibleException.java b/src/main/java/io/mosip/print/exception/ApiNotAccessibleException.java
new file mode 100644
index 00000000..702c707a
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/ApiNotAccessibleException.java
@@ -0,0 +1,32 @@
+package io.mosip.print.exception;
+
+
+
+public class ApiNotAccessibleException extends BaseCheckedException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public ApiNotAccessibleException() {
+ super(PlatformErrorMessages.API_NOT_ACCESSIBLE_EXCEPTION.getCode(),
+ PlatformErrorMessages.API_NOT_ACCESSIBLE_EXCEPTION.getMessage());
+ }
+
+ public ApiNotAccessibleException(String message) {
+ super(PlatformErrorMessages.API_NOT_ACCESSIBLE_EXCEPTION.getCode(),
+ message);
+ }
+
+ public ApiNotAccessibleException(Throwable e) {
+ super(PlatformErrorMessages.API_NOT_ACCESSIBLE_EXCEPTION.getCode(),
+ PlatformErrorMessages.API_NOT_ACCESSIBLE_EXCEPTION.getMessage(), e);
+ }
+
+ public ApiNotAccessibleException(String errorMessage, Throwable t) {
+ super(PlatformErrorMessages.API_NOT_ACCESSIBLE_EXCEPTION.getCode(), errorMessage, t);
+ }
+
+
+}
diff --git a/src/main/java/io/mosip/print/exception/ApisResourceAccessException.java b/src/main/java/io/mosip/print/exception/ApisResourceAccessException.java
index 4f22cc2a..753b5df0 100644
--- a/src/main/java/io/mosip/print/exception/ApisResourceAccessException.java
+++ b/src/main/java/io/mosip/print/exception/ApisResourceAccessException.java
@@ -1,6 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseCheckedException;
/**
* The Class ApisResourceAccessException.
diff --git a/src/main/java/io/mosip/print/exception/BaseCheckedException.java b/src/main/java/io/mosip/print/exception/BaseCheckedException.java
new file mode 100644
index 00000000..7a4fa78f
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/BaseCheckedException.java
@@ -0,0 +1,144 @@
+package io.mosip.print.exception;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * This is the base class for all MOSIP checked exceptions.
+ *
+ * The class and its subclasses are a form that indicates conditions that a
+ * reasonable application might want to catch.
+ *
+ *
+ * The class {@code BaseCheckedException} and any subclasses that are not also
+ * subclasses of {@link BaseUncheckedException} are checked exceptions.
+ * Checked exceptions need to be declared in a method or constructor's
+ * {@code throws} clause if they can be thrown by the execution of the method or
+ * constructor and propagate outside the method or constructor boundary.
+ *
+ * @author Shashank Agrawal
+ * @since 1.0
+ *
+ */
+public class BaseCheckedException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -924722202100630614L;
+
+ private final List infoItems = new ArrayList<>();
+
+ /**
+ * Constructs a new checked exception
+ */
+ public BaseCheckedException() {
+ super();
+ }
+
+ /**
+ * Constructs a new checked exception with errorMessage
+ *
+ * @param errorMessage the detail message.
+ */
+ public BaseCheckedException(String errorMessage) {
+ super(errorMessage);
+ }
+
+ /**
+ * Constructs a new checked exception with the specified detail message and
+ * error code.
+ *
+ * @param errorCode the error code
+ * @param errorMessage the detail message.
+ */
+ public BaseCheckedException(String errorCode, String errorMessage) {
+ super(errorCode + " --> " + errorMessage);
+ addInfo(errorCode, errorMessage);
+ }
+
+ /**
+ * Constructs a new checked exception with the specified detail message and
+ * error code and specified cause.
+ *
+ * @param errorCode the error code
+ * @param errorMessage the detail message.
+ * @param rootCause the specified cause
+ *
+ */
+ public BaseCheckedException(String errorCode, String errorMessage, Throwable rootCause) {
+ super(errorCode + " --> " + errorMessage, rootCause);
+ addInfo(errorCode, errorMessage);
+ if (rootCause instanceof BaseCheckedException) {
+ BaseCheckedException bce = (BaseCheckedException) rootCause;
+ infoItems.addAll(bce.infoItems);
+ }
+ }
+
+ /**
+ * This method add error code and error message.
+ *
+ * @param errorCode the error code
+ * @param errorText the detail message.
+ *
+ * @return the current instance of BaseCheckedException
+ */
+ public BaseCheckedException addInfo(String errorCode, String errorText) {
+ this.infoItems.add(new InfoItem(errorCode, errorText));
+ return this;
+ }
+
+ /*
+ * Returns a String object that can be used to get the exception message.
+ *
+ * @see java.lang.Throwable#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return ExceptionUtils.buildMessage(super.getMessage(), getCause());
+ }
+
+ /**
+ * Returns the list of exception codes.
+ *
+ * @return list of exception codes
+ */
+ public List getCodes() {
+ List codes = new ArrayList<>();
+ for (int i = this.infoItems.size() - 1; i >= 0; i--)
+ codes.add(this.infoItems.get(i).errorCode);
+ return codes;
+ }
+
+ /**
+ * Returns the list of exception messages.
+ *
+ * @return list of exception messages
+ */
+ public List getErrorTexts() {
+ List errorTexts = new ArrayList<>();
+ for (int i = this.infoItems.size() - 1; i >= 0; i--)
+ errorTexts.add(this.infoItems.get(i).errorText);
+ return errorTexts;
+ }
+
+ /**
+ * Return the last error code.
+ *
+ * @return the last error code
+ */
+ public String getErrorCode() {
+ return infoItems.get(0).errorCode;
+ }
+
+ /**
+ * Return the last exception message.
+ *
+ * @return the last exception message
+ */
+ public String getErrorText() {
+ return infoItems.get(0).errorText;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/io/mosip/print/exception/BaseUncheckedException.java b/src/main/java/io/mosip/print/exception/BaseUncheckedException.java
new file mode 100644
index 00000000..89f68de6
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/BaseUncheckedException.java
@@ -0,0 +1,149 @@
+package io.mosip.print.exception;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * This is the base class for all MOSIP unchecked exceptions.
+ *
+ * {@code BaseUncheckedException} is the superclass of those exceptions that can
+ * be thrown during the normal operation of the Java Virtual Machine.
+ *
+ *
+ * {@code RuntimeException} and its subclasses are unchecked
+ * exceptions. Unchecked exceptions do not need to be declared in
+ * a method or constructor's {@code throws} clause if they can be thrown by the
+ * execution of the method or constructor and propagate outside the method or
+ * constructor boundary.
+ *
+ * @author Shashank Agrawal Compile-Time Checking of Exceptions
+ * @since 1.0
+ */
+public class BaseUncheckedException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -875003872780128394L;
+ public static final String EMPTY_SPACE = " ";
+ private final List infoItems = new ArrayList<>();
+
+ /**
+ * Constructs a new unchecked exception
+ */
+ public BaseUncheckedException() {
+ super();
+ }
+
+ /**
+ * Constructs a new checked exception with errorMessage
+ *
+ * @param errorMessage the detail message.
+ */
+ public BaseUncheckedException(String errorMessage) {
+ super(errorMessage);
+ }
+
+ /**
+ * Constructs a new unchecked exception with the specified detail message and
+ * error code.
+ *
+ * @param errorMessage the detail message.
+ * @param errorCode the error code.
+ *
+ */
+ public BaseUncheckedException(String errorCode, String errorMessage) {
+ super(errorCode + " --> " + errorMessage);
+ addInfo(errorCode, errorMessage);
+ }
+
+ /**
+ * Constructs a new unchecked exception with the specified detail message and
+ * error code and error cause.
+ *
+ *
+ * @param errorCode the error code
+ * @param errorMessage the detail message.
+ * @param rootCause the specified cause
+ */
+ public BaseUncheckedException(String errorCode, String errorMessage, Throwable rootCause) {
+ super(errorCode + " --> " + errorMessage, rootCause);
+ addInfo(errorCode, errorMessage);
+ if (rootCause instanceof BaseUncheckedException) {
+ BaseUncheckedException bue = (BaseUncheckedException) rootCause;
+ infoItems.addAll(bue.infoItems);
+ }
+ }
+
+ /*
+ * Returns a String object that can be used to get the exception message.
+ *
+ * @see java.lang.Throwable#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return ExceptionUtils.buildMessage(super.getMessage(), getCause());
+ }
+
+ /**
+ * This method add the information of error code and error message.
+ *
+ * @param errorCode the error code
+ * @param errorText the detail message.
+ * @return the instance of current BaseCheckedException
+ */
+ public BaseUncheckedException addInfo(String errorCode, String errorText) {
+ this.infoItems.add(new InfoItem(errorCode, errorText));
+ return this;
+ }
+
+ /**
+ * Returns the list of error codes.
+ *
+ * @return the list of error codes
+ */
+ public List getCodes() {
+ List codes = new ArrayList<>();
+
+ for (int i = this.infoItems.size() - 1; i >= 0; i--) {
+ codes.add(this.infoItems.get(i).errorCode);
+ }
+
+ return codes;
+ }
+
+ /**
+ * Returns the list of exception messages.
+ *
+ * @return the list of exception messages
+ */
+ public List getErrorTexts() {
+ List errorTexts = new ArrayList<>();
+
+ for (int i = this.infoItems.size() - 1; i >= 0; i--) {
+ errorTexts.add(this.infoItems.get(i).errorText);
+ }
+
+ return errorTexts;
+ }
+
+ /**
+ * Return the last error code.
+ *
+ * @return the last error code
+ */
+ public String getErrorCode() {
+ return infoItems.get(0).errorCode;
+ }
+
+ /**
+ * Return the last exception message.
+ *
+ * @return the last exception message
+ */
+ public String getErrorText() {
+ return infoItems.get(0).errorText;
+ }
+
+}
diff --git a/src/main/java/io/mosip/print/exception/BiometricException.java b/src/main/java/io/mosip/print/exception/BiometricException.java
new file mode 100644
index 00000000..84041eea
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/BiometricException.java
@@ -0,0 +1,37 @@
+package io.mosip.print.exception;
+
+
+/**
+ * The Class BiometricException.
+ *
+ * @author Sanjay Murali
+ */
+public class BiometricException extends BaseCheckedException {
+
+ /** The Constant serialVersionUID. */
+ private static final long serialVersionUID = -9125558120446752522L;
+
+ /**
+ * Instantiates a new biometric exception.
+ *
+ * @param errorCode the error code
+ * @param errorMessage the error message
+ * @param rootCause the root cause
+ */
+ public BiometricException(String errorCode, String errorMessage, Throwable rootCause) {
+ super(errorCode, errorMessage, rootCause);
+
+ }
+
+ /**
+ * Instantiates a new biometric exception.
+ *
+ * @param errorCode the error code
+ * @param errorMessage the error message
+ */
+ public BiometricException(String errorCode, String errorMessage) {
+ super(errorCode, errorMessage);
+
+ }
+
+}
diff --git a/src/main/java/io/mosip/print/exception/BiometricTagMatchException.java b/src/main/java/io/mosip/print/exception/BiometricTagMatchException.java
index 67a6f8aa..1e2b8ed3 100644
--- a/src/main/java/io/mosip/print/exception/BiometricTagMatchException.java
+++ b/src/main/java/io/mosip/print/exception/BiometricTagMatchException.java
@@ -1,6 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseUncheckedException;
public class BiometricTagMatchException extends BaseUncheckedException {
diff --git a/src/main/java/io/mosip/print/exception/CbeffException.java b/src/main/java/io/mosip/print/exception/CbeffException.java
new file mode 100644
index 00000000..c85a5d78
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/CbeffException.java
@@ -0,0 +1,19 @@
+/**
+ *
+ */
+package io.mosip.print.exception;
+
+/**
+ * @author Ramadurai Pandian
+ *
+ * A Custom exception class
+ */
+public class CbeffException extends Exception {
+
+ private static final long serialVersionUID = 9190616446912282298L;
+
+ public CbeffException(String message) {
+ super(message);
+ }
+
+}
diff --git a/src/main/java/io/mosip/print/exception/CryptoManagerException.java b/src/main/java/io/mosip/print/exception/CryptoManagerException.java
new file mode 100644
index 00000000..1401d075
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/CryptoManagerException.java
@@ -0,0 +1,39 @@
+package io.mosip.print.exception;
+
+
+public class CryptoManagerException extends BaseUncheckedException {
+
+ /** The Constant serialVersionUID. */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Instantiates a new access denied exception.
+ */
+ public CryptoManagerException() {
+ super();
+
+ }
+
+ /**
+ * Instantiates a new access denied exception.
+ *
+ * @param message the message
+ */
+ public CryptoManagerException(String message) {
+ super(PlatformErrorMessages.PRT_AUT_ACCESS_DENIED.getCode(), message);
+ }
+
+ public CryptoManagerException(String message, String message1) {
+ super(PlatformErrorMessages.PRT_AUT_ACCESS_DENIED.getCode(), message);
+ }
+
+ /**
+ * Instantiates a new access denied exception.
+ *
+ * @param message the message
+ * @param cause the cause
+ */
+ public CryptoManagerException(String message, String message1, Throwable cause) {
+ super(PlatformErrorMessages.PRT_AUT_ACCESS_DENIED.getCode(), message, cause);
+ }
+}
diff --git a/src/main/java/io/mosip/print/exception/DataShareException.java b/src/main/java/io/mosip/print/exception/DataShareException.java
new file mode 100644
index 00000000..499226a8
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/DataShareException.java
@@ -0,0 +1,30 @@
+package io.mosip.print.exception;
+
+
+public class DataShareException extends BaseCheckedException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public DataShareException() {
+ super(PlatformErrorMessages.DATASHARE_EXCEPTION.getCode(),
+ PlatformErrorMessages.DATASHARE_EXCEPTION.getMessage());
+ }
+
+ public DataShareException(String message) {
+ super(PlatformErrorMessages.DATASHARE_EXCEPTION.getCode(),
+ message);
+ }
+
+ public DataShareException(Throwable e) {
+ super(PlatformErrorMessages.DATASHARE_EXCEPTION.getCode(),
+ PlatformErrorMessages.DATASHARE_EXCEPTION.getMessage(), e);
+ }
+
+ public DataShareException(String errorMessage, Throwable t) {
+ super(PlatformErrorMessages.DATASHARE_EXCEPTION.getCode(), errorMessage, t);
+ }
+
+}
diff --git a/src/main/java/io/mosip/print/exception/DigitalSignatureException.java b/src/main/java/io/mosip/print/exception/DigitalSignatureException.java
index ae279095..4ee7d357 100644
--- a/src/main/java/io/mosip/print/exception/DigitalSignatureException.java
+++ b/src/main/java/io/mosip/print/exception/DigitalSignatureException.java
@@ -1,6 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseUncheckedException;
public class DigitalSignatureException extends BaseUncheckedException {
diff --git a/src/main/java/io/mosip/print/exception/ExceptionUtils.java b/src/main/java/io/mosip/print/exception/ExceptionUtils.java
new file mode 100644
index 00000000..d77d6938
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/ExceptionUtils.java
@@ -0,0 +1,81 @@
+package io.mosip.print.exception;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * This utils contains exception utilities.
+ *
+ * @author Shashank Agrawal
+ * @author Ritesh Sinha
+ * @since 1.0.0
+ *
+ */
+public final class ExceptionUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger(ExceptionUtils.class);
+
+ private ExceptionUtils() {
+
+ }
+
+ /**
+ * Returns an String object that can be used after building the exception stack
+ * trace.
+ *
+ * @param message the exception message
+ * @param cause the cause
+ * @return the exception stack
+ */
+ public static String buildMessage(String message, Throwable cause) {
+ if (cause != null) {
+ StringBuilder sb = new StringBuilder();
+ if (message != null) {
+ sb.append(message).append("; ");
+ }
+ sb.append("\n");
+ sb.append("nested exception is ").append(cause);
+ return sb.toString();
+ } else {
+ return message;
+ }
+ }
+
+ /**
+ * This method returns the stack trace
+ *
+ * @param throwable the exception to be added to the list of exception
+ * @return the stack trace
+ */
+ public static String getStackTrace(Throwable throwable) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw, true);
+ throwable.printStackTrace(pw);
+ return sw.getBuffer().toString();
+ }
+
+
+ /**
+ * This method provide jsonvalue based on propname mention.
+ *
+ * @param node the jsonnode.
+ * @param propName the property name.
+ * @return the property value.
+ */
+ private static String getJsonValue(JsonNode node, String propName) {
+ if (node.get(propName) != null) {
+ return node.get(propName).asText();
+ }
+ return null;
+ }
+
+ public static void logRootCause(Throwable exception) {
+ logger.error("Exception Root Cause: {} ", exception.getMessage());
+ logger.debug("Exception Root Cause:", exception);
+ }
+}
diff --git a/src/main/java/io/mosip/print/exception/FieldNotFoundException.java b/src/main/java/io/mosip/print/exception/FieldNotFoundException.java
index 17ee9d4c..254d0fb8 100644
--- a/src/main/java/io/mosip/print/exception/FieldNotFoundException.java
+++ b/src/main/java/io/mosip/print/exception/FieldNotFoundException.java
@@ -1,6 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseUncheckedException;
/**
* The Class FieldNotFoundException.
diff --git a/src/main/java/io/mosip/print/exception/IdRepoAppException.java b/src/main/java/io/mosip/print/exception/IdRepoAppException.java
index 523f15da..dbf0550e 100644
--- a/src/main/java/io/mosip/print/exception/IdRepoAppException.java
+++ b/src/main/java/io/mosip/print/exception/IdRepoAppException.java
@@ -1,6 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseUncheckedException;
public class IdRepoAppException extends BaseUncheckedException {
diff --git a/src/main/java/io/mosip/print/exception/IdentityNotFoundException.java b/src/main/java/io/mosip/print/exception/IdentityNotFoundException.java
index 90be38f0..e10ab0cf 100644
--- a/src/main/java/io/mosip/print/exception/IdentityNotFoundException.java
+++ b/src/main/java/io/mosip/print/exception/IdentityNotFoundException.java
@@ -1,6 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseUncheckedException;
/**
* The Class IdentityNotFoundException.
diff --git a/src/main/java/io/mosip/print/exception/IllegalArgumentException.java b/src/main/java/io/mosip/print/exception/IllegalArgumentException.java
new file mode 100644
index 00000000..7da4c963
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/IllegalArgumentException.java
@@ -0,0 +1,27 @@
+package io.mosip.print.exception;
+
+/**
+ * Base class for all preconditions violation exceptions.
+ *
+ * @author Ritesh Sinha
+ * @author Sidhant Agarwal
+ * @author Sagar Mahapatra
+ * @author Ravi Balaji
+ * @author Priya Soni
+ * @since 1.0.0
+ */
+public class IllegalArgumentException extends BaseUncheckedException {
+ /** Serializable version Id. */
+ private static final long serialVersionUID = 924722202110630628L;
+
+ public IllegalArgumentException(String errorCode, String errorMessage) {
+ super(errorCode, errorMessage);
+
+ }
+
+ public IllegalArgumentException(String errorCode, String errorMessage, Throwable cause) {
+ super(errorCode, errorMessage, cause);
+
+ }
+
+}
diff --git a/src/main/java/io/mosip/print/exception/InfoItem.java b/src/main/java/io/mosip/print/exception/InfoItem.java
new file mode 100644
index 00000000..ef2422ca
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/InfoItem.java
@@ -0,0 +1,31 @@
+package io.mosip.print.exception;
+
+import java.io.Serializable;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * This class is the entity class for the BaseUncheckedException and
+ * BaseCheckedException class.
+ *
+ * @author Shashank Agrawal
+ * @since 1.0
+ */
+@AllArgsConstructor
+@NoArgsConstructor
+class InfoItem implements Serializable {
+
+ private static final long serialVersionUID = -779695043380592601L;
+
+ @Getter
+ @Setter
+ public String errorCode = null;
+
+ @Getter
+ @Setter
+ public String errorText = null;
+
+}
diff --git a/src/main/java/io/mosip/print/exception/InstantanceCreationException.java b/src/main/java/io/mosip/print/exception/InstantanceCreationException.java
index 0ffe3572..8fa8f0f7 100644
--- a/src/main/java/io/mosip/print/exception/InstantanceCreationException.java
+++ b/src/main/java/io/mosip/print/exception/InstantanceCreationException.java
@@ -1,6 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseUncheckedException;
/**
* The Class InstantanceCreationException.
diff --git a/src/main/java/io/mosip/print/exception/InvalidInputException.java b/src/main/java/io/mosip/print/exception/InvalidInputException.java
new file mode 100644
index 00000000..a45f4d06
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/InvalidInputException.java
@@ -0,0 +1,28 @@
+package io.mosip.print.exception;
+
+
+/**
+ * Class which covers the range of exception which occurs when invalid input
+ *
+ * @author Urvil Joshi
+ *
+ * @since 1.0.0
+ */
+public class InvalidInputException extends BaseUncheckedException {
+
+ /**
+ * Unique id for serialization
+ */
+ private static final long serialVersionUID = -5350213197226295789L;
+
+ /**
+ * Constructor with errorCode, and errorMessage
+ *
+ * @param errorCode The error code for this exception
+ * @param errorMessage The error message for this exception
+ */
+ public InvalidInputException(String errorCode, String errorMessage) {
+ super(errorCode, errorMessage);
+ }
+
+}
diff --git a/src/main/java/io/mosip/print/exception/InvalidTokenException.java b/src/main/java/io/mosip/print/exception/InvalidTokenException.java
index 475ec267..c7daa880 100644
--- a/src/main/java/io/mosip/print/exception/InvalidTokenException.java
+++ b/src/main/java/io/mosip/print/exception/InvalidTokenException.java
@@ -1,6 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseUncheckedException;
public class InvalidTokenException extends BaseUncheckedException {
diff --git a/src/main/java/io/mosip/print/exception/NullPointerException.java b/src/main/java/io/mosip/print/exception/NullPointerException.java
new file mode 100644
index 00000000..d45e87b8
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/NullPointerException.java
@@ -0,0 +1,37 @@
+package io.mosip.print.exception;
+
+/**
+ * Exception to be thrown when a null argument found.
+ *
+ * @author Urvil Joshi
+ * @author Ritesh Sinha
+ * @author Sagar Mahapatra
+ * @author Priya Soni
+ * @since 1.0.0
+ */
+public class NullPointerException extends BaseUncheckedException {
+
+ /** Serializable version Id. */
+ private static final long serialVersionUID = 784321102100630614L;
+
+ /**
+ * Constructor with errorCode, and rootCause
+ *
+ * @param errorCode The error code for this exception
+ * @param errorMessage The error message for this exception
+ */
+ public NullPointerException(String errorCode, String errorMessage) {
+ super(errorCode, errorMessage);
+ }
+
+ /**
+ * @param arg0 Error Code Corresponds to Particular Exception
+ * @param arg1 Message providing the specific context of the error.
+ * @param arg2 Cause of exception
+ */
+ public NullPointerException(String arg0, String arg1, Throwable arg2) {
+ super(arg0, arg1, arg2);
+
+ }
+
+}
diff --git a/src/main/java/io/mosip/print/exception/PDFGeneratorException.java b/src/main/java/io/mosip/print/exception/PDFGeneratorException.java
new file mode 100644
index 00000000..08ef7f27
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/PDFGeneratorException.java
@@ -0,0 +1,35 @@
+package io.mosip.print.exception;
+
+/**
+ *
+ *
+ * @author M1046571
+ * @since 1.0.0
+ *
+ */
+
+public class PDFGeneratorException extends BaseUncheckedException {
+
+ private static final long serialVersionUID = -6138841548758442351L;
+
+ /**
+ * Constructor for PDFGeneratorGenericException
+ *
+ * @param errorCode The errorcode
+ * @param errorMessage The errormessage
+ * @param cause The cause
+ */
+ public PDFGeneratorException(String errorCode, String errorMessage, Throwable cause) {
+ super(errorCode, errorMessage, cause);
+ }
+
+ /**
+ * Constructor for PDFGeneratorGenericException
+ *
+ * @param errorCode The errorcode
+ * @param errorMessage The errormessage
+ */
+ public PDFGeneratorException(String errorCode, String errorMessage) {
+ super(errorCode, errorMessage);
+ }
+}
diff --git a/src/main/java/io/mosip/print/exception/PDFSignatureException.java b/src/main/java/io/mosip/print/exception/PDFSignatureException.java
index 35b8261d..06cbd888 100644
--- a/src/main/java/io/mosip/print/exception/PDFSignatureException.java
+++ b/src/main/java/io/mosip/print/exception/PDFSignatureException.java
@@ -1,6 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseUncheckedException;
public class PDFSignatureException extends BaseUncheckedException{
diff --git a/src/main/java/io/mosip/print/exception/ParseException.java b/src/main/java/io/mosip/print/exception/ParseException.java
new file mode 100644
index 00000000..c38d0e0e
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/ParseException.java
@@ -0,0 +1,22 @@
+package io.mosip.print.exception;
+
+/**
+ * Signals that an error has been reached unexpectedly while parsing.
+ *
+ * @author Bal Vikash Sharma
+ * @since 1.0.0
+ */
+public class ParseException extends BaseUncheckedException {
+ private static final long serialVersionUID = 924722202110630628L;
+
+ public ParseException(String errorCode, String errorMessage) {
+ super(errorCode, errorMessage);
+
+ }
+
+ public ParseException(String errorCode, String errorMessage, Throwable cause) {
+ super(errorCode, errorMessage, cause);
+
+ }
+
+}
diff --git a/src/main/java/io/mosip/print/exception/ParsingException.java b/src/main/java/io/mosip/print/exception/ParsingException.java
index 758d5c62..4ec1ca66 100644
--- a/src/main/java/io/mosip/print/exception/ParsingException.java
+++ b/src/main/java/io/mosip/print/exception/ParsingException.java
@@ -1,6 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseUncheckedException;
/**
* The Class ParsingException.
diff --git a/src/main/java/io/mosip/print/exception/PlatformErrorMessages.java b/src/main/java/io/mosip/print/exception/PlatformErrorMessages.java
index 7fbb0d7e..530bebe7 100644
--- a/src/main/java/io/mosip/print/exception/PlatformErrorMessages.java
+++ b/src/main/java/io/mosip/print/exception/PlatformErrorMessages.java
@@ -65,9 +65,14 @@ public enum PlatformErrorMessages {
PRT_PIS_IDENTITY_NOT_FOUND(PlatformConstants.PRT_PRINT_PREFIX + "002",
"Unable to Find Identity Field in ID JSON"),
/** Access denied for the token present. */
- PRT_AUT_ACCESS_DENIED(PlatformConstants.PRT_PRINT_PREFIX + "02", "Access Denied For Role - %s");
+ PRT_AUT_ACCESS_DENIED(PlatformConstants.PRT_PRINT_PREFIX + "02", "Access Denied For Role - %s"),
+ DATASHARE_EXCEPTION(PlatformConstants.PRT_PRINT_PREFIX + "025", "Data share api failure"),
+ API_NOT_ACCESSIBLE_EXCEPTION(PlatformConstants.PRT_PRINT_PREFIX + "026", "Api not accessible failure"),
+ CERTIFICATE_THUMBPRINT_ERROR(PlatformConstants.PRT_PRINT_PREFIX + "026", "certificate thumbprint failure"),
+ PRT_INVALID_KEY_EXCEPTION(PlatformConstants.PRT_PRINT_PREFIX + "027", "invalid key");
+
/** The error message. */
private final String errorMessage;
diff --git a/src/main/java/io/mosip/print/exception/QrcodeGenerationException.java b/src/main/java/io/mosip/print/exception/QrcodeGenerationException.java
new file mode 100644
index 00000000..43d41e80
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/QrcodeGenerationException.java
@@ -0,0 +1,29 @@
+package io.mosip.print.exception;
+
+/**
+ * A base class which covers the range of exceptions which may occur when
+ * encoding a QRcode using the Writer framework.
+ *
+ * @author Urvil Joshi
+ *
+ * @since 1.0.0
+ */
+public class QrcodeGenerationException extends BaseCheckedException {
+
+ /**
+ * Unique id for serialization
+ */
+ private static final long serialVersionUID = 473719335574042491L;
+
+ /**
+ * Constructor with errorCode, errorMessage, and rootCause
+ *
+ * @param errorCode The error code for this exception
+ * @param errorMessage The error message for this exception
+ * @param rootCause Cause of this exception
+ */
+ public QrcodeGenerationException(String errorCode, String errorMessage, Throwable rootCause) {
+ super(errorCode, errorMessage, rootCause);
+ }
+
+}
diff --git a/src/main/java/io/mosip/print/exception/RegPrintAppException.java b/src/main/java/io/mosip/print/exception/RegPrintAppException.java
index f174dfb2..4bd20d90 100644
--- a/src/main/java/io/mosip/print/exception/RegPrintAppException.java
+++ b/src/main/java/io/mosip/print/exception/RegPrintAppException.java
@@ -1,6 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseCheckedException;
/**
* The Class RegPrintAppException.
diff --git a/src/main/java/io/mosip/print/exception/RegStatusAppException.java b/src/main/java/io/mosip/print/exception/RegStatusAppException.java
index e4e4731d..265a7303 100644
--- a/src/main/java/io/mosip/print/exception/RegStatusAppException.java
+++ b/src/main/java/io/mosip/print/exception/RegStatusAppException.java
@@ -1,7 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseCheckedException;
-import io.mosip.print.exception.PlatformErrorMessages;
/**
* The Class RegStatusAppException.
diff --git a/src/main/java/io/mosip/print/exception/TemplateMethodInvocationException.java b/src/main/java/io/mosip/print/exception/TemplateMethodInvocationException.java
new file mode 100644
index 00000000..74aa4564
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/TemplateMethodInvocationException.java
@@ -0,0 +1,37 @@
+package io.mosip.print.exception;
+
+
+/**
+ * TemplateMethodInvocationException when reference method in template could not
+ * be invoked.
+ *
+ * @author Abhishek Kumar
+ * @version 1.0.0
+ * @since 2018-10-1
+ */
+public class TemplateMethodInvocationException extends BaseUncheckedException {
+
+ private static final long serialVersionUID = 6360842063626691912L;
+
+ /**
+ * Constructor for set error code and message
+ *
+ * @param errorCode the error code
+ * @param errorMessage the error message
+ */
+ public TemplateMethodInvocationException(String errorCode, String errorMessage) {
+ super(errorCode, errorMessage);
+ }
+
+ /**
+ * Constructor for setting error code, message and cause
+ *
+ * @param errorCode the error code
+ * @param errorMessage the error message
+ * @param rootCause the specified cause
+ */
+ public TemplateMethodInvocationException(String errorCode, String errorMessage, Throwable rootCause) {
+ super(errorCode, errorMessage, rootCause);
+ }
+
+}
diff --git a/src/main/java/io/mosip/print/exception/TemplateParsingException.java b/src/main/java/io/mosip/print/exception/TemplateParsingException.java
new file mode 100644
index 00000000..0974704e
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/TemplateParsingException.java
@@ -0,0 +1,40 @@
+package io.mosip.print.exception;
+
+
+/**
+ * this exception thrown when a resource of any type has a syntax or other error
+ * which prevents it from being parsed.
+ * When this resource is thrown, a best effort will be made to have useful
+ * information in the exception's message. For complete information, consult the
+ * runtime log.
+ *
+ * @author Abhishek Kumar
+ * @version 1.0.0
+ * @since 2018-10-4
+ */
+public class TemplateParsingException extends BaseUncheckedException {
+
+ private static final long serialVersionUID = 1368132089641129425L;
+
+ /**
+ * Constructor for set error code and message
+ *
+ * @param errorCode the error code
+ * @param errorMessage the error message
+ */
+ public TemplateParsingException(String errorCode, String errorMessage) {
+ super(errorCode, errorMessage);
+ }
+
+ /**
+ * Constructor for setting error code, message and cause
+ *
+ * @param errorCode the error code
+ * @param errorMessage the error message
+ * @param rootCause the specified cause
+ */
+ public TemplateParsingException(String errorCode, String errorMessage, Throwable rootCause) {
+ super(errorCode, errorMessage, rootCause);
+ }
+
+}
diff --git a/src/main/java/io/mosip/print/exception/TemplateProcessingFailureException.java b/src/main/java/io/mosip/print/exception/TemplateProcessingFailureException.java
index 904cd5ec..37524871 100644
--- a/src/main/java/io/mosip/print/exception/TemplateProcessingFailureException.java
+++ b/src/main/java/io/mosip/print/exception/TemplateProcessingFailureException.java
@@ -1,6 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseUncheckedException;
/**
* The Class TemplateProcessingFailureException.
diff --git a/src/main/java/io/mosip/print/exception/TemplateResourceNotFoundException.java b/src/main/java/io/mosip/print/exception/TemplateResourceNotFoundException.java
new file mode 100644
index 00000000..2e112c09
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/TemplateResourceNotFoundException.java
@@ -0,0 +1,38 @@
+package io.mosip.print.exception;
+
+
+/**
+ * this exception thrown when a resource of any type isn't found by the template
+ * manager.
+ * When this exception is thrown, a best effort will be made to have useful
+ * information in the exception's message. For complete information, consult the
+ * runtime log.
+ *
+ * @author Abhishek Kumar
+ * @version 1.0.0
+ * @since 2018-10-1
+ */
+public class TemplateResourceNotFoundException extends BaseUncheckedException {
+
+ private static final long serialVersionUID = 3070414901455295210L;
+
+ /**
+ * Constructor for set error code and message
+ *
+ * @param errorCode the error code
+ * @param errorMessage the error message
+ */
+ public TemplateResourceNotFoundException(String errorCode, String errorMessage) {
+ super(errorCode, errorMessage);
+ }
+
+ /**
+ * @param errorCode the error code
+ * @param errorMessage the error message
+ * @param rootCause cause of the error
+ */
+ public TemplateResourceNotFoundException(String errorCode, String errorMessage, Throwable rootCause) {
+ super(errorCode, errorMessage, rootCause);
+ }
+
+}
diff --git a/src/main/java/io/mosip/print/exception/TokenGenerationFailedException.java b/src/main/java/io/mosip/print/exception/TokenGenerationFailedException.java
index 495a1834..6a626632 100644
--- a/src/main/java/io/mosip/print/exception/TokenGenerationFailedException.java
+++ b/src/main/java/io/mosip/print/exception/TokenGenerationFailedException.java
@@ -1,7 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseUncheckedException;
-
public class TokenGenerationFailedException extends BaseUncheckedException {
/** The Constant serialVersionUID. */
diff --git a/src/main/java/io/mosip/print/exception/UINNotFoundInDatabase.java b/src/main/java/io/mosip/print/exception/UINNotFoundInDatabase.java
index 94176b1a..abc1b138 100644
--- a/src/main/java/io/mosip/print/exception/UINNotFoundInDatabase.java
+++ b/src/main/java/io/mosip/print/exception/UINNotFoundInDatabase.java
@@ -1,6 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseUncheckedException;
public class UINNotFoundInDatabase extends BaseUncheckedException{
diff --git a/src/main/java/io/mosip/print/exception/VidCreationException.java b/src/main/java/io/mosip/print/exception/VidCreationException.java
index 6ac61a2c..636d19b1 100644
--- a/src/main/java/io/mosip/print/exception/VidCreationException.java
+++ b/src/main/java/io/mosip/print/exception/VidCreationException.java
@@ -1,6 +1,5 @@
package io.mosip.print.exception;
-import io.mosip.kernel.core.exception.BaseCheckedException;
public class VidCreationException extends BaseCheckedException {
diff --git a/src/main/java/io/mosip/print/exception/WebSubClientException.java b/src/main/java/io/mosip/print/exception/WebSubClientException.java
new file mode 100644
index 00000000..3eba6323
--- /dev/null
+++ b/src/main/java/io/mosip/print/exception/WebSubClientException.java
@@ -0,0 +1,35 @@
+package io.mosip.print.exception;
+
+/**
+ * This class act as a generic exception for this api.
+ *
+ * @author Urvil Joshi
+ *
+ */
+public class WebSubClientException extends BaseUncheckedException {
+
+ /**
+ * Generated serial version id
+ */
+ private static final long serialVersionUID = 8621530697947108810L;
+
+ /**
+ * Constructor the initialize Handler exception
+ *
+ * @param errorCode The errorcode for this exception
+ * @param errorMessage The error message for this exception
+ */
+ public WebSubClientException(String errorCode, String errorMessage) {
+ super(errorCode, errorMessage);
+ }
+
+ /**
+ * @param errorCode The errorcode for this exception
+ * @param errorMessage The error message for this exception
+ * @param rootCause cause of the error occoured
+ */
+ public WebSubClientException(String errorCode, String errorMessage, Throwable rootCause) {
+ super(errorCode, errorMessage, rootCause);
+ }
+
+}
diff --git a/src/main/java/io/mosip/print/idrepo/dto/IdResponseDTO1.java b/src/main/java/io/mosip/print/idrepo/dto/IdResponseDTO1.java
index f256ca6f..363c7be0 100644
--- a/src/main/java/io/mosip/print/idrepo/dto/IdResponseDTO1.java
+++ b/src/main/java/io/mosip/print/idrepo/dto/IdResponseDTO1.java
@@ -1,6 +1,6 @@
package io.mosip.print.idrepo.dto;
-import io.mosip.registration.print.core.http.ResponseWrapper;
+import io.mosip.print.core.http.ResponseWrapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
diff --git a/src/main/java/io/mosip/print/init/SetupPrint.java b/src/main/java/io/mosip/print/init/SetupPrint.java
index 8e8b6ec3..23ef6fbf 100644
--- a/src/main/java/io/mosip/print/init/SetupPrint.java
+++ b/src/main/java/io/mosip/print/init/SetupPrint.java
@@ -2,6 +2,7 @@
import java.util.Date;
+import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
@@ -9,7 +10,6 @@
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Component;
-import io.mosip.kernel.core.logger.spi.Logger;
import io.mosip.print.constant.LoggerFileConstant;
import io.mosip.print.logger.PrintLogger;
import io.mosip.print.util.WebSubSubscriptionHelper;
@@ -18,12 +18,12 @@
public class SetupPrint
implements ApplicationListener {
- private static Logger logger = PrintLogger.getLogger(SetupPrint.class);
+ private Logger logger = PrintLogger.getLogger(SetupPrint.class);
@Autowired
private ThreadPoolTaskScheduler taskScheduler;
- @Value("${mosip.event.delay :60000}")
+ @Value("${mosip.event.delay}")
private int taskSubsctiptionDelay;
@Autowired
diff --git a/src/main/java/io/mosip/print/logger/PrintLogger.java b/src/main/java/io/mosip/print/logger/PrintLogger.java
index 2038d22e..fc23281a 100644
--- a/src/main/java/io/mosip/print/logger/PrintLogger.java
+++ b/src/main/java/io/mosip/print/logger/PrintLogger.java
@@ -1,8 +1,7 @@
package io.mosip.print.logger;
-import io.mosip.kernel.core.logger.spi.Logger;
-import io.mosip.kernel.logger.logback.appender.RollingFileAppender;
-import io.mosip.kernel.logger.logback.factory.Logfactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -11,25 +10,6 @@
*/
public final class PrintLogger {
- /** The mosip rolling file appender. */
- private static RollingFileAppender mosipRollingFileAppender;
-
- static {
- mosipRollingFileAppender = new RollingFileAppender();
- mosipRollingFileAppender.setAppend(true);
- mosipRollingFileAppender.setAppenderName("fileappender");
- mosipRollingFileAppender.setFileName("/home/logs/print.log");
- mosipRollingFileAppender.setFileNamePattern("/home/logs/print-%d{yyyy-MM-dd}-%i.log");
- mosipRollingFileAppender.setImmediateFlush(true);
- mosipRollingFileAppender.setMaxFileSize("1mb");
- mosipRollingFileAppender.setMaxHistory(3);
- mosipRollingFileAppender.setPrudent(false);
- mosipRollingFileAppender.setTotalCap("10mb");
- }
-
- /**
- * Instantiates a new reg processor logger.
- */
private PrintLogger() {
}
@@ -40,6 +20,6 @@ private PrintLogger() {
* @return the logger
*/
public static Logger getLogger(Class> clazz) {
- return Logfactory.getDefaultRollingFileLogger(mosipRollingFileAppender, clazz);
+ return LoggerFactory.getLogger(clazz);
}
}
diff --git a/src/main/java/io/mosip/print/model/CertificateEntry.java b/src/main/java/io/mosip/print/model/CertificateEntry.java
new file mode 100644
index 00000000..b5613559
--- /dev/null
+++ b/src/main/java/io/mosip/print/model/CertificateEntry.java
@@ -0,0 +1,31 @@
+package io.mosip.print.model;
+
+import java.util.Arrays;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * Certificate Key Entry from SoftHsm
+ *
+ * @author Urvil Joshi
+ *
+ * @param Certificate Type
+ * @param PrivateKey Type
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class CertificateEntry {
+
+ private C[] chain;
+
+ private P privateKey;
+
+ @Override
+ public String toString() {
+ return "CertificateEntry [chain=" + Arrays.toString(chain) + ", privateKey=" + privateKey + "]";
+ }
+
+}
diff --git a/src/main/java/io/mosip/print/model/CompositeScore.java b/src/main/java/io/mosip/print/model/CompositeScore.java
new file mode 100644
index 00000000..08f119cc
--- /dev/null
+++ b/src/main/java/io/mosip/print/model/CompositeScore.java
@@ -0,0 +1,14 @@
+package io.mosip.print.model;
+
+import lombok.Data;
+
+/** Added for backward compatibility 0.7 */
+@Data
+public class CompositeScore {
+
+ private float scaledScore;
+ private long internalScore;
+ private Score[] individualScores;
+ private KeyValuePair[] analyticsInfo;
+
+}
diff --git a/src/main/java/io/mosip/print/model/KeyValuePair.java b/src/main/java/io/mosip/print/model/KeyValuePair.java
new file mode 100644
index 00000000..b187cb3c
--- /dev/null
+++ b/src/main/java/io/mosip/print/model/KeyValuePair.java
@@ -0,0 +1,14 @@
+package io.mosip.print.model;
+
+import lombok.Data;
+
+/**
+ * The Class KeyValuePair.
+ *
+ * @author Sanjay Murali
+ */
+@Data
+public class KeyValuePair {
+ private String key;
+ private String value;
+}
diff --git a/src/main/java/io/mosip/print/model/MatchDecision.java b/src/main/java/io/mosip/print/model/MatchDecision.java
new file mode 100644
index 00000000..296127c4
--- /dev/null
+++ b/src/main/java/io/mosip/print/model/MatchDecision.java
@@ -0,0 +1,18 @@
+package io.mosip.print.model;
+
+import lombok.Data;
+
+/**
+ * The Class Score.
+ *
+ * @author Manoj SP
+ */
+@Data
+public class MatchDecision {
+
+ /** The match - true or false indicates matchers decision. */
+ private boolean match;
+
+ /** The analytics info - detailed breakdown and other information. */
+ private KeyValuePair[] analyticsInfo;
+}
diff --git a/src/main/java/io/mosip/print/model/PrintcardMCE.java b/src/main/java/io/mosip/print/model/PrintcardMCE.java
new file mode 100644
index 00000000..f7db5f7f
--- /dev/null
+++ b/src/main/java/io/mosip/print/model/PrintcardMCE.java
@@ -0,0 +1,58 @@
+package io.mosip.print.model;
+
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.sql.Timestamp;
+import java.util.Date;
+
+@Entity
+@Table(name = "msp_card")
+@Getter
+@Setter
+public class PrintcardMCE {
+
+ @Id
+ @Column(name = "id")
+ private String id;
+
+ @Column(name = "json_data ")
+ private String name;
+ @Column(name = "province")
+ private String province;
+ @Column(name = "city")
+ private String city;
+ @Column(name = "zone")
+ private String zone;
+ @Column(name = "zip")
+ private String zip;
+ @Column(name = "download_date")
+ private Date downloadDate;
+ @Column(name = "request_id")
+ private String requestId;
+ @Column(name = "registration_date")
+ private Timestamp registrationDate;
+ @Column(name = "registration_center_id")
+ private String registrationCenterId;
+ @Column(name = "status")
+ private int status;
+ @Column(name = "request_id1")
+ private String requestId1;
+ @Column(name = "resident")
+ private String resident;
+ @Column(name = "introducer")
+ private String introducer;
+ @Column(name = "birthdate")
+ private Date birthdate;
+
+ public PrintcardMCE() {
+
+ }
+
+
+}
diff --git a/src/main/java/io/mosip/print/model/QualityScore.java b/src/main/java/io/mosip/print/model/QualityScore.java
new file mode 100644
index 00000000..ab9dec08
--- /dev/null
+++ b/src/main/java/io/mosip/print/model/QualityScore.java
@@ -0,0 +1,21 @@
+package io.mosip.print.model;
+
+import lombok.Data;
+
+/**
+ * The Class QualityScore.
+ *
+ * @author Sanjay Murali
+ */
+@Data
+public class QualityScore {
+
+ /** The score - 0 - 100 score that represents quality as a percentage */
+ private float score;
+
+ /** Added for backward compatibility 0.7 */
+ private long internalScore;
+
+ /** The analytics info - detailed breakdown and other information */
+ private KeyValuePair[] analyticsInfo;
+}
\ No newline at end of file
diff --git a/src/main/java/io/mosip/print/model/Rectangle.java b/src/main/java/io/mosip/print/model/Rectangle.java
new file mode 100644
index 00000000..b176df7a
--- /dev/null
+++ b/src/main/java/io/mosip/print/model/Rectangle.java
@@ -0,0 +1,37 @@
+package io.mosip.print.model;
+
+import lombok.Data;
+
+/**
+ * Rectangle model for pdf generator
+ *
+ * @author Urvil Joshi
+ *
+ */
+@Data
+public class Rectangle {
+
+ public Rectangle(float llx, float lly, float urx, float ury) {
+ this.llx = llx;
+ this.lly = lly;
+ this.urx = urx;
+ this.ury = ury;
+ }
+ /**
+ * The lower left x value of rectangle.
+ */
+ private float llx;
+ /**
+ * The lower left y value of rectangle.
+ */
+ private float lly;
+ /**
+ * The upper right x value of rectangle.
+ */
+ private float urx;
+ /**
+ * The upper right y value of rectangle.
+ */
+ private float ury;
+
+}
\ No newline at end of file
diff --git a/src/main/java/io/mosip/print/model/Response.java b/src/main/java/io/mosip/print/model/Response.java
new file mode 100644
index 00000000..ceef8b27
--- /dev/null
+++ b/src/main/java/io/mosip/print/model/Response.java
@@ -0,0 +1,22 @@
+package io.mosip.print.model;
+
+import lombok.Data;
+
+/**
+ * The Class Response.
+ *
+ * @author Manoj SP
+ * @param the generic type
+ */
+@Data
+public class Response {
+
+ /** The status code. */
+ private Integer statusCode;
+
+ /** The status message. */
+ private String statusMessage;
+
+ /** The response. */
+ private T response;
+}
diff --git a/src/main/java/io/mosip/print/model/Score.java b/src/main/java/io/mosip/print/model/Score.java
new file mode 100644
index 00000000..ca57602d
--- /dev/null
+++ b/src/main/java/io/mosip/print/model/Score.java
@@ -0,0 +1,13 @@
+package io.mosip.print.model;
+
+import lombok.Data;
+
+/** Added for backward compatibility 0.7 */
+@Data
+public class Score {
+
+ private float scaleScore;
+ private long internalScore;
+ private KeyValuePair[] analyticsInfo;
+
+}
diff --git a/src/main/java/io/mosip/print/repository/MspCardRepository.java b/src/main/java/io/mosip/print/repository/MspCardRepository.java
new file mode 100644
index 00000000..883da03a
--- /dev/null
+++ b/src/main/java/io/mosip/print/repository/MspCardRepository.java
@@ -0,0 +1,10 @@
+package io.mosip.print.repository;
+
+import io.mosip.kernel.core.dataaccess.spi.repository.BaseRepository;
+import io.mosip.print.entity.MspCardEntity;
+import org.springframework.stereotype.Repository;
+
+@Repository("mspCardRepository")
+public interface MspCardRepository extends BaseRepository {
+
+}
diff --git a/src/main/java/io/mosip/print/service/CbeffContainerI.java b/src/main/java/io/mosip/print/service/CbeffContainerI.java
new file mode 100644
index 00000000..d1b1aac5
--- /dev/null
+++ b/src/main/java/io/mosip/print/service/CbeffContainerI.java
@@ -0,0 +1,22 @@
+/**
+ *
+ */
+package io.mosip.print.service;
+
+import java.util.List;
+
+/**
+ * @author Ramadurai Pandian
+ *
+ * Container Interface to be used for create and update
+ *
+ */
+public abstract class CbeffContainerI {
+
+ public abstract U createBIRType(List bir) throws Exception;
+
+ public abstract U updateBIRType(List bir, byte[] fileBytes) throws Exception;
+
+ public abstract boolean validateXML(byte[] fileBytes, byte[] xsdBytes) throws Exception;
+
+}
diff --git a/src/main/java/io/mosip/print/service/PrintDBService.java b/src/main/java/io/mosip/print/service/PrintDBService.java
new file mode 100644
index 00000000..0671b7c4
--- /dev/null
+++ b/src/main/java/io/mosip/print/service/PrintDBService.java
@@ -0,0 +1,54 @@
+package io.mosip.print.service;
+
+import io.mosip.kernel.core.logger.spi.Logger;
+import io.mosip.print.constant.LoggerFileConstant;
+import io.mosip.print.logger.PrintLogger;
+import io.mosip.print.model.PrintcardMCE;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.transaction.Transactional;
+
+@Repository
+@Transactional
+public class PrintDBService {
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ public synchronized void savePrintdata(PrintcardMCE obj) {
+ try {
+ long taskStart = System.currentTimeMillis();
+ PrintcardMCE card = new PrintcardMCE();
+ card.setId(obj.getId());
+ card.setName(obj.getName());
+// card.setProvince(obj.getProvince());
+// card.setCity(obj.getCity());
+// card.setZip(obj.getZip());
+// card.setZone(obj.getZone());
+ card.setRequestId(obj.getRequestId());
+// card.setRequestId1(obj.getRequestId1());
+// card.setDownloadDate(new Date());
+// card.setRegistrationDate(obj.getRegistrationDate());
+// card.setRegistrationCenterId(obj.getRegistrationCenterId());
+// card.setResident(obj.getResident());
+// card.setIntroducer(obj.getIntroducer());
+// card.setRid(obj.getRid());
+
+// card.setId(obj.getId());
+// card.setBirthdate(obj.getBirthdate());
+ entityManager.persist(card);
+
+ } catch (Exception e) {
+
+ }
+ }
+
+
+ ;
+
+ // Map getDocuments(String credentialSubject, String sign,
+ // String cardType,
+ // boolean isPasswordProtected);
+
+}
diff --git a/src/main/java/io/mosip/print/service/PrintRepository.java b/src/main/java/io/mosip/print/service/PrintRepository.java
new file mode 100644
index 00000000..f2088f06
--- /dev/null
+++ b/src/main/java/io/mosip/print/service/PrintRepository.java
@@ -0,0 +1,25 @@
+package io.mosip.print.service;
+
+import io.mosip.print.model.PrintcardMCE;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.repository.query.Param;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface PrintRepository extends CrudRepository {
+ @Query("SELECT max(p.id) FROM PrintcardMCE p")
+ public Integer sno();
+ @Query("SELECT count(p.id) FROM PrintcardMCE p where p.requestId= ?1 ")
+ public Integer countById(@Param("requestId") String printid) ;
+
+ @Query("SELECT count(p.id) FROM PrintcardMCE p where p.requestId1= ?1 ")
+ public Integer countByRequestId1(@Param("requestId1") String rid) ;
+
+ @Query("SELECT p.id FROM PrintcardMCE p where p.requestId1= ?1 ")
+ public Integer findIdByRequestId1(@Param("requestId1") String rid);
+ @Modifying
+ @Query("update PrintcardMCE p set p.status=?3 where p.requestId1= ?1 and p.status=?2 ")
+ public Integer updateExistingId(@Param("requestId1") String rid,@Param("status") int status,@Param("status") int newstatus);
+}
diff --git a/src/main/java/io/mosip/print/service/PrintService.java b/src/main/java/io/mosip/print/service/PrintService.java
index f83c0edf..a39a1977 100644
--- a/src/main/java/io/mosip/print/service/PrintService.java
+++ b/src/main/java/io/mosip/print/service/PrintService.java
@@ -1,22 +1,18 @@
package io.mosip.print.service;
-public interface PrintService {
+import io.mosip.print.model.EventModel;
+
+public interface PrintService {
/**
- * Gets the documents.
- *
- * @param type
- * the type
- * @param idValue
- * the id value
- * @param cardType
- * the card type
- * @param isPasswordProtected
- * the is password protected
- * @return the documents
+ * Get the card
+ *
+ *
+ * @param eventModel
+ * @return
+ * @throws Exception
*/
- public T getDocuments(String credentialSubject, String requestId, String sign, String cardType,
- boolean isPasswordProtected);
+ public void generateCard(EventModel eventModel) throws Exception;
// Map getDocuments(String credentialSubject, String sign,
// String cardType,
diff --git a/src/main/java/io/mosip/print/service/impl/BioApiImpl.java b/src/main/java/io/mosip/print/service/impl/BioApiImpl.java
new file mode 100644
index 00000000..6208245f
--- /dev/null
+++ b/src/main/java/io/mosip/print/service/impl/BioApiImpl.java
@@ -0,0 +1,131 @@
+package io.mosip.print.service.impl;
+
+import java.security.SecureRandom;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Objects;
+import java.util.Optional;
+
+import org.springframework.stereotype.Component;
+
+import io.mosip.kernel.core.bioapi.model.CompositeScore;
+import io.mosip.kernel.core.bioapi.model.KeyValuePair;
+import io.mosip.kernel.core.bioapi.model.QualityScore;
+import io.mosip.kernel.core.bioapi.model.Score;
+import io.mosip.kernel.core.cbeffutil.entity.BDBInfo;
+import io.mosip.kernel.core.cbeffutil.entity.BIR;
+import io.mosip.kernel.core.cbeffutil.jaxbclasses.QualityType;
+import io.mosip.print.spi.IBioApi;
+
+
+
+/**
+ * The Class BioApiImpl.
+ *
+ * @author Sanjay Murali
+ * @author Manoj SP
+ *
+ */
+@Component
+public class BioApiImpl implements IBioApi {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * io.mosip.kernel.core.bioapi.spi.IBioApi#checkQuality(io.mosip.kernel.core.
+ * bioapi.model.BIR, io.mosip.kernel.core.bioapi.model.KeyValuePair[])
+ */
+ @Override
+ public QualityScore checkQuality(BIR sample, KeyValuePair[] flags) {
+ QualityScore qualityScore = new QualityScore();
+ int major = Optional.ofNullable(sample.getBdbInfo()).map(BDBInfo::getQuality).map(QualityType::getScore)
+ .orElse(0L).intValue();
+ qualityScore.setInternalScore(major);
+ return qualityScore;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * io.mosip.kernel.core.bioapi.spi.IBioApi#match(io.mosip.kernel.core.bioapi.
+ * model.BIR, io.mosip.kernel.core.bioapi.model.BIR[],
+ * io.mosip.kernel.core.bioapi.model.KeyValuePair[])
+ */
+ @Override
+ public Score[] match(BIR sample, BIR[] gallery, KeyValuePair[] flags) {
+ Score matchingScore[] = new Score[gallery.length];
+ int count = 0;
+ for (BIR recordedValue : gallery) {
+ matchingScore[count] = new Score();
+ if (Objects.nonNull(recordedValue) && Objects.nonNull(recordedValue.getBdb())
+ && recordedValue.getBdb().length != 0 && Arrays.equals(recordedValue.getBdb(), sample.getBdb())) {
+ matchingScore[count].setInternalScore(90);
+ matchingScore[count].setScaleScore(90);
+ } else {
+ int randomNumebr = new SecureRandom().nextInt(50);
+ matchingScore[count].setInternalScore(randomNumebr);
+ matchingScore[count].setScaleScore(randomNumebr);
+ }
+ count++;
+ }
+ return matchingScore;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * io.mosip.kernel.core.bioapi.spi.IBioApi#compositeMatch(io.mosip.kernel.core.
+ * bioapi.model.BIR[], io.mosip.kernel.core.bioapi.model.BIR[],
+ * io.mosip.kernel.core.bioapi.model.KeyValuePair[])
+ */
+
+ @Override
+ public CompositeScore compositeMatch(BIR[] sampleList, BIR[] recordList, KeyValuePair[] flags) {
+ Score matchingScore[] = new Score[sampleList.length];
+ int count = 0;
+ for (BIR sampleValue : sampleList) {
+ Score[] match = match(sampleValue, recordList, flags);
+ Optional max = Arrays.stream(match).max(Comparator.comparing(Score::getInternalScore));
+ if (max.isPresent()) {
+ matchingScore[count] = max.get();
+ count++;
+ }
+ }
+ double sum = Arrays.stream(matchingScore).mapToDouble(Score::getInternalScore).sum();
+ CompositeScore compositeScore = new CompositeScore();
+ compositeScore.setIndividualScores(matchingScore);
+ long compositeMatchScore = (long) (sum / matchingScore.length);
+ compositeScore.setInternalScore(compositeMatchScore);
+ compositeScore.setScaledScore(compositeMatchScore);
+ return compositeScore;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * io.mosip.kernel.core.bioapi.spi.IBioApi#extractTemplate(io.mosip.kernel.core.
+ * bioapi.model.BIR, io.mosip.kernel.core.bioapi.model.KeyValuePair[])
+ */
+ @Override
+ public BIR extractTemplate(BIR sample, KeyValuePair[] flags) {
+ return sample;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * io.mosip.kernel.core.bioapi.spi.IBioApi#segment(io.mosip.kernel.core.bioapi.
+ * model.BIR, io.mosip.kernel.core.bioapi.model.KeyValuePair[])
+ */
+ @Override
+ public BIR[] segment(BIR sample, KeyValuePair[] flags) {
+ BIR[] bir = new BIR[1];
+ bir[0] = sample;
+ return bir;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/io/mosip/print/service/impl/CbeffContainerImpl.java b/src/main/java/io/mosip/print/service/impl/CbeffContainerImpl.java
new file mode 100644
index 00000000..f020714c
--- /dev/null
+++ b/src/main/java/io/mosip/print/service/impl/CbeffContainerImpl.java
@@ -0,0 +1,95 @@
+/**
+ *
+ */
+package io.mosip.print.service.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import io.mosip.kernel.core.cbeffutil.common.CbeffValidator;
+import io.mosip.kernel.core.cbeffutil.common.CbeffXSDValidator;
+import io.mosip.kernel.core.cbeffutil.entity.BIR;
+import io.mosip.kernel.core.cbeffutil.jaxbclasses.BIRInfoType;
+import io.mosip.kernel.core.cbeffutil.jaxbclasses.BIRType;
+import io.mosip.print.service.CbeffContainerI;
+
+/**
+ * @author Ramadurai Pandian
+ *
+ * A Container Class where the BIR is created and updated
+ *
+ */
+public class CbeffContainerImpl extends CbeffContainerI {
+
+ private BIRType birType;
+
+ /**
+ * Method where the initialization of BIR happens
+ *
+ * @param birList List of BIR data
+ * @return BIRType data with all images
+ */
+ @Override
+ public BIRType createBIRType(List birList) {
+ load();
+ List birTypeList = new ArrayList<>();
+ if (birList != null && birList.size() > 0) {
+ for (BIR bir : birList) {
+ birTypeList.add(bir.toBIRType(bir));
+ }
+ }
+ birType.setBir(birTypeList);
+ return birType;
+ }
+
+ private void load() {
+ // Creating first version of Cbeff
+ birType = new BIRType();
+ // Initial Version
+// VersionType versionType = new VersionType();
+// versionType.setMajor(1);
+// versionType.setMinor(1);
+// VersionType cbeffVersion = new VersionType();
+// cbeffVersion.setMajor(1);
+// cbeffVersion.setMinor(1);
+// birType.setVersion(versionType);
+// birType.setCBEFFVersion(cbeffVersion);
+ BIRInfoType birInfo = new BIRInfoType();
+ birInfo.setIntegrity(false);
+ birType.setBIRInfo(birInfo);
+ }
+
+ /**
+ * Method to the update of BIR
+ *
+ * @param birList List of BIR data
+ *
+ * @param fileBytes Cbeff XML data as bytes
+ *
+ * @return birType BIR data with all images
+ */
+ @Override
+ public BIRType updateBIRType(List birList, byte[] fileBytes) throws Exception {
+ BIRType birType = CbeffValidator.getBIRFromXML(fileBytes);
+ // birType.getVersion().setMajor(birType.getVersion().getMajor() + 1);
+ // birType.getCBEFFVersion().setMajor(birType.getCBEFFVersion().getMajor());
+ for (BIR bir : birList) {
+ birType.getBIR().add(bir.toBIRType(bir));
+ }
+ return birType;
+ }
+
+ /**
+ * Method to the validate the BIR
+ *
+ * @param xmlBytes Cbeff XML data as bytes array
+ *
+ * @param xsdBytes Cbeff XSD data as bytes array
+ *
+ * @return boolean of validated XML against XSD
+ */
+ @Override
+ public boolean validateXML(byte[] xmlBytes, byte[] xsdBytes) throws Exception {
+ return CbeffXSDValidator.validateXML(xsdBytes, xmlBytes);
+ }
+}
diff --git a/src/main/java/io/mosip/print/service/impl/CbeffImpl.java b/src/main/java/io/mosip/print/service/impl/CbeffImpl.java
new file mode 100644
index 00000000..0296dd86
--- /dev/null
+++ b/src/main/java/io/mosip/print/service/impl/CbeffImpl.java
@@ -0,0 +1,207 @@
+package io.mosip.print.service.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+
+import org.apache.commons.io.IOUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import io.mosip.kernel.core.cbeffutil.common.CbeffValidator;
+import io.mosip.kernel.core.cbeffutil.entity.BIR;
+import io.mosip.kernel.core.cbeffutil.jaxbclasses.BIRType;
+import io.mosip.print.spi.CbeffUtil;
+
+/**
+ * This class is used to create,update, validate and search Cbeff data.
+ *
+ * @author Ramadurai Pandian
+ */
+@Component
+public class CbeffImpl implements CbeffUtil {
+
+ /*
+ * XSD storage path from config server
+ */
+
+ /** The config server file storage URL. */
+ @Value("${mosip.kernel.xsdstorage-uri}")
+ private String configServerFileStorageURL;
+
+ /*
+ * XSD file name
+ */
+
+ /** The schema name. */
+ @Value("${mosip.kernel.xsdfile}")
+ private String schemaName;
+
+ /** The xsd. */
+ private byte[] xsd;
+
+ /**
+ * Load XSD.
+ *
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ @PostConstruct
+ public void loadXSD() throws IOException {
+ try (InputStream xsdBytes = new URL(configServerFileStorageURL + schemaName).openStream()) {
+ xsd = IOUtils.toByteArray(xsdBytes);
+ }
+ }
+
+ /**
+ * Method used for creating Cbeff XML.
+ *
+ * @param birList pass List of BIR for creating Cbeff data
+ * @return return byte array of XML data
+ * @throws Exception exception
+ */
+ @Override
+ public byte[] createXML(List birList) throws Exception {
+ CbeffContainerImpl cbeffContainer = new CbeffContainerImpl();
+ BIRType bir = cbeffContainer.createBIRType(birList);
+ return CbeffValidator.createXMLBytes(bir, xsd);
+ }
+
+ /**
+ * Method used for creating Cbeff XML with xsd.
+ *
+ * @param birList pass List of BIR for creating Cbeff data
+ * @param xsd byte array of XSD data
+ * @return return byte array of XML data
+ * @throws Exception Exception
+ */
+
+ @Override
+ public byte[] createXML(List birList, byte[] xsd) throws Exception {
+ CbeffContainerImpl cbeffContainer = new CbeffContainerImpl();
+ BIRType bir = cbeffContainer.createBIRType(birList);
+ return CbeffValidator.createXMLBytes(bir, xsd);
+ }
+
+ /**
+ * Method used for updating Cbeff XML.
+ *
+ * @param birList pass List of BIR for creating Cbeff data
+ * @param fileBytes the file bytes
+ * @return return byte array of XML data
+ * @throws Exception Exception
+ */
+ @Override
+ public byte[] updateXML(List birList, byte[] fileBytes) throws Exception {
+ CbeffContainerImpl cbeffContainer = new CbeffContainerImpl();
+ BIRType bir = cbeffContainer.updateBIRType(birList, fileBytes);
+ return CbeffValidator.createXMLBytes(bir, xsd);
+ }
+
+ /**
+ * Method used for validating XML against XSD.
+ *
+ * @param xmlBytes byte array of XML data
+ * @param xsdBytes byte array of XSD data
+ * @return boolean if data is valid or not
+ * @throws Exception Exception
+ */
+ @Override
+ public boolean validateXML(byte[] xmlBytes, byte[] xsdBytes) throws Exception {
+ CbeffContainerImpl cbeffContainer = new CbeffContainerImpl();
+ return cbeffContainer.validateXML(xmlBytes, xsdBytes);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see io.mosip.kernel.core.cbeffutil.spi.CbeffUtil#validateXML(byte[])
+ */
+ @Override
+ public boolean validateXML(byte[] xmlBytes) throws Exception {
+ return validateXML(xmlBytes, xsd);
+ }
+
+ /**
+ * Method used for validating XML against XSD.
+ *
+ * @param fileBytes byte array of XML data
+ * @param type to be searched
+ * @param subType to be searched
+ * @return bdbMap Map of type and String of encoded biometric data
+ * @throws Exception Exception
+ */
+ @Override
+ public Map getBDBBasedOnType(byte[] fileBytes, String type, String subType) throws Exception {
+ BIRType bir = CbeffValidator.getBIRFromXML(fileBytes);
+ return CbeffValidator.getBDBBasedOnTypeAndSubType(bir, type, subType);
+ }
+
+ /**
+ * Method used for getting list of BIR from XML bytes.
+ *
+ * @param xmlBytes byte array of XML data
+ * @return List of BIR data extracted from XML
+ * @throws Exception Exception
+ */
+ @Override
+ public List getBIRDataFromXML(byte[] xmlBytes) throws Exception {
+ BIRType bir = CbeffValidator.getBIRFromXML(xmlBytes);
+ return bir.getBIR();
+ }
+
+ /**
+ * Method used for getting Map of BIR from XML bytes with type and subType.
+ *
+ * @param xmlBytes byte array of XML data
+ * @param type type
+ * @param subType subType
+ * @return bdbMap Map of BIR data extracted from XML
+ * @throws Exception Exception
+ */
+ @Override
+ public Map getAllBDBData(byte[] xmlBytes, String type, String subType) throws Exception {
+ BIRType bir = CbeffValidator.getBIRFromXML(xmlBytes);
+ return CbeffValidator.getAllBDBData(bir, type, subType);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * io.mosip.kernel.core.cbeffutil.spi.CbeffUtil#convertBIRTypeToBIR(java.util.
+ * List)
+ */
+ @Override
+ public List convertBIRTypeToBIR(List birType) {
+ return CbeffValidator.convertBIRTypeToBIR(birType);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * io.mosip.kernel.core.cbeffutil.spi.CbeffUtil#getBIRDataFromXMLType(byte[],
+ * java.lang.String)
+ */
+ @Override
+ public List getBIRDataFromXMLType(byte[] xmlBytes, String type) throws Exception {
+ return CbeffValidator.getBIRDataFromXMLType(xmlBytes, type);
+ }
+
+ //TODO for testing, will be removed later
+// public static void main(String arg[]) throws Exception
+// {
+// Map test= new CbeffImpl().getBDBBasedOnType(readCreatedXML(),"Iris",null);
+// System.out.println(test.size());
+//
+// }
+//
+// private static byte[] readCreatedXML() throws IOException {
+// byte[] fileContent = Files.readAllBytes(Paths.get("C:\\Users\\M1046464\\Downloads\\cbeff1.xml"));
+// return fileContent;
+// }
+}
diff --git a/src/main/java/io/mosip/print/service/impl/PDFGeneratorImpl.java b/src/main/java/io/mosip/print/service/impl/PDFGeneratorImpl.java
new file mode 100644
index 00000000..5b6dca41
--- /dev/null
+++ b/src/main/java/io/mosip/print/service/impl/PDFGeneratorImpl.java
@@ -0,0 +1,328 @@
+package io.mosip.print.service.impl;
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.security.GeneralSecurityException;
+import java.security.PrivateKey;
+import java.security.Provider;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import com.itextpdf.html2pdf.ConverterProperties;
+import com.itextpdf.html2pdf.HtmlConverter;
+import com.itextpdf.html2pdf.css.media.MediaDeviceDescription;
+import com.itextpdf.html2pdf.css.media.MediaType;
+import com.itextpdf.html2pdf.css.util.CssUtils;
+import com.itextpdf.html2pdf.resolver.font.DefaultFontProvider;
+import com.itextpdf.io.image.ImageDataFactory;
+import com.itextpdf.kernel.geom.PageSize;
+import com.itextpdf.kernel.pdf.PdfDocument;
+import com.itextpdf.kernel.pdf.PdfWriter;
+import com.itextpdf.layout.Document;
+import com.itextpdf.layout.element.Image;
+import com.itextpdf.text.DocumentException;
+import com.itextpdf.text.Rectangle;
+import com.itextpdf.text.pdf.PdfCopy;
+import com.itextpdf.text.pdf.PdfReader;
+import com.itextpdf.text.pdf.PdfSignatureAppearance;
+import com.itextpdf.text.pdf.PdfStamper;
+import com.itextpdf.text.pdf.security.BouncyCastleDigest;
+import com.itextpdf.text.pdf.security.CertificateUtil;
+import com.itextpdf.text.pdf.security.CrlClient;
+import com.itextpdf.text.pdf.security.CrlClientOnline;
+import com.itextpdf.text.pdf.security.ExternalDigest;
+import com.itextpdf.text.pdf.security.ExternalSignature;
+import com.itextpdf.text.pdf.security.MakeSignature;
+import com.itextpdf.text.pdf.security.MakeSignature.CryptoStandard;
+import com.itextpdf.text.pdf.security.OcspClient;
+import com.itextpdf.text.pdf.security.OcspClientBouncyCastle;
+import com.itextpdf.text.pdf.security.PrivateKeySignature;
+import com.itextpdf.text.pdf.security.TSAClient;
+import com.itextpdf.text.pdf.security.TSAClientBouncyCastle;
+
+import io.mosip.print.constant.PDFGeneratorExceptionCodeConstant;
+import io.mosip.print.exception.PDFGeneratorException;
+import io.mosip.print.logger.PrintLogger;
+import io.mosip.print.model.CertificateEntry;
+import io.mosip.print.spi.PDFGenerator;
+import io.mosip.print.util.EmptyCheckUtils;
+
+/**
+ * The PdfGeneratorImpl is the class you will use most when converting processed
+ * Template to PDF. It contains a series of methods that accept processed
+ * Template as a {@link String}, {@link File}, or {@link InputStream}, and
+ * convert it to PDF in the form of an {@link OutputStream}, {@link File}
+ *
+ * @author Urvil Joshi
+ * @author Uday Kumar
+ * @author Neha
+ *
+ * @since 1.0.0
+ *
+ */
+@Component
+public class PDFGeneratorImpl implements PDFGenerator {
+ private static final Logger LOGGER = PrintLogger.getLogger(PDFGeneratorImpl.class);
+
+ private static final String SHA256 = "SHA256";
+
+ private static final String OUTPUT_FILE_EXTENSION = ".pdf";
+
+ @Value("${mosip.kernel.pdf_owner_password}")
+ private String pdfOwnerPassword;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see io.mosip.kernel.core.pdfgenerator.spi.PDFGenerator#generate(java.io.
+ * InputStream)
+ */
+ @Override
+ public OutputStream generate(InputStream is) throws IOException {
+ isValidInputStream(is);
+ OutputStream os = new ByteArrayOutputStream();
+ try {
+ HtmlConverter.convertToPdf(is, os);
+ } catch (Exception e) {
+ throw new PDFGeneratorException(PDFGeneratorExceptionCodeConstant.PDF_EXCEPTION.getErrorCode(),
+ e.getMessage());
+ }
+ return os;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * io.mosip.kernel.core.pdfgenerator.spi.PDFGenerator#generate(java.lang.String)
+ */
+ @Override
+ public OutputStream generate(String template) throws IOException {
+ OutputStream os = new ByteArrayOutputStream();
+ try {
+ HtmlConverter.convertToPdf(template, os);
+ } catch (Exception e) {
+ throw new PDFGeneratorException(PDFGeneratorExceptionCodeConstant.PDF_EXCEPTION.getErrorCode(),
+ PDFGeneratorExceptionCodeConstant.PDF_EXCEPTION.getErrorMessage(), e);
+ }
+ return os;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * io.mosip.kernel.core.pdfgenerator.spi.PDFGenerator#generate(java.lang.String,
+ * java.lang.String, java.lang.String)
+ */
+ @Override
+ public void generate(String templatePath, String outpuFilePath, String outputFileName) throws IOException {
+ File outputFile = new File(outpuFilePath + outputFileName + OUTPUT_FILE_EXTENSION);
+ try {
+ HtmlConverter.convertToPdf(new File(templatePath), outputFile);
+ } catch (Exception e) {
+ throw new PDFGeneratorException(PDFGeneratorExceptionCodeConstant.PDF_EXCEPTION.getErrorCode(),
+ PDFGeneratorExceptionCodeConstant.PDF_EXCEPTION.getErrorMessage(), e);
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see io.mosip.kernel.core.pdfgenerator.spi.PDFGenerator#generate(java.io.
+ * InputStream, java.lang.String)
+ */
+ @Override
+ public OutputStream generate(InputStream is, String resourceLoc) throws IOException {
+ isValidInputStream(is);
+ OutputStream os = new ByteArrayOutputStream();
+ PdfWriter pdfWriter = new PdfWriter(os);
+ PdfDocument pdfDoc = new PdfDocument(pdfWriter);
+ ConverterProperties converterProperties = new ConverterProperties();
+ pdfDoc.setTagged();
+ PageSize pageSize = PageSize.A4.rotate();
+ pdfDoc.setDefaultPageSize(pageSize);
+ float screenWidth = CssUtils.parseAbsoluteLength("" + pageSize.getWidth());
+ MediaDeviceDescription mediaDescription = new MediaDeviceDescription(MediaType.SCREEN);
+ mediaDescription.setWidth(screenWidth);
+ DefaultFontProvider dfp = new DefaultFontProvider(true, true, false);
+ converterProperties.setMediaDeviceDescription(mediaDescription);
+ converterProperties.setFontProvider(dfp);
+ converterProperties.setBaseUri(resourceLoc);
+ converterProperties.setCreateAcroForm(true);
+ try {
+ HtmlConverter.convertToPdf(is, pdfDoc, converterProperties);
+ } catch (Exception e) {
+ throw new PDFGeneratorException(PDFGeneratorExceptionCodeConstant.PDF_EXCEPTION.getErrorCode(),
+ e.getMessage());
+ }
+ return os;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see io.mosip.kernel.core.pdfgenerator.spi.PDFGenerator#asPDF(java.util.List)
+ */
+ @Override
+ public byte[] asPDF(List bufferedImages) throws IOException {
+ byte[] scannedPdfFile = null;
+
+ try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
+
+ PdfWriter pdfWriter = new PdfWriter(byteArrayOutputStream);
+ Document document = new Document(new PdfDocument(pdfWriter));
+
+ for (BufferedImage bufferedImage : bufferedImages) {
+ Image image = new Image(ImageDataFactory.create(getImageBytesFromBufferedImage(bufferedImage)));
+ image.scaleToFit(600, 750);
+ document.add(image);
+ }
+
+ document.close();
+ pdfWriter.close();
+ scannedPdfFile = byteArrayOutputStream.toByteArray();
+ } catch (IOException e) {
+ throw new PDFGeneratorException(PDFGeneratorExceptionCodeConstant.PDF_EXCEPTION.getErrorCode(),
+ e.getMessage());
+ }
+ return scannedPdfFile;
+ }
+
+ private byte[] getImageBytesFromBufferedImage(BufferedImage bufferedImage) throws IOException {
+ byte[] imageInByte;
+
+ ByteArrayOutputStream imagebyteArray = new ByteArrayOutputStream();
+ ImageIO.write(bufferedImage, "jpg", imagebyteArray);
+ imagebyteArray.flush();
+ imageInByte = imagebyteArray.toByteArray();
+ imagebyteArray.close();
+
+ return imageInByte;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * io.mosip.kernel.core.pdfgenerator.spi.PDFGenerator#mergePDF(java.util.List)
+ */
+ @Override
+ public byte[] mergePDF(List pdfFiles) throws IOException {
+ try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
+ com.itextpdf.text.Document document = new com.itextpdf.text.Document();
+ PdfCopy pdfCopy = new PdfCopy(document, byteArrayOutputStream);
+ document.open();
+ for (URL file : pdfFiles) {
+ PdfReader reader = new PdfReader(file);
+ pdfCopy.addDocument(reader);
+ pdfCopy.freeReader(reader);
+ reader.close();
+ }
+ document.close();
+ return byteArrayOutputStream.toByteArray();
+ } catch (IOException | DocumentException e) {
+ throw new PDFGeneratorException(PDFGeneratorExceptionCodeConstant.PDF_EXCEPTION.getErrorCode(),
+ e.getMessage());
+ }
+ }
+
+ @Override
+ public OutputStream signAndEncryptPDF(byte[] pdf, io.mosip.print.model.Rectangle rectangle,
+ String reason, int pageNumber, Provider provider,
+ CertificateEntry certificateEntry, String password)
+ throws IOException, GeneralSecurityException {
+ OutputStream outputStream = new ByteArrayOutputStream();
+ PdfReader pdfReader = null;
+ PdfStamper pdfStamper = null;
+ try {
+ pdfReader = new PdfReader(pdf);
+ pdfStamper = PdfStamper.createSignature(pdfReader, outputStream, '\0');
+
+ if (password != null && !password.trim().isEmpty()) {
+ pdfStamper.setEncryption(password.getBytes(), pdfOwnerPassword.getBytes(),
+ com.itextpdf.text.pdf.PdfWriter.ALLOW_PRINTING,
+ com.itextpdf.text.pdf.PdfWriter.ENCRYPTION_AES_256);
+ }
+ PdfSignatureAppearance signAppearance = pdfStamper.getSignatureAppearance();
+
+ signAppearance.setReason(reason);
+ // comment next line to have an invisible signature
+ signAppearance.setVisibleSignature(
+ new Rectangle(rectangle.getLlx(), rectangle.getLly(), rectangle.getUrx(), rectangle.getUry()),
+ pageNumber, null);
+
+ OcspClient ocspClient = new OcspClientBouncyCastle(null);
+ TSAClient tsaClient = null;
+ for (X509Certificate certificate : certificateEntry.getChain()) {
+ String tsaUrl = CertificateUtil.getTSAURL(certificate);
+ if (tsaUrl != null) {
+ tsaClient = new TSAClientBouncyCastle(tsaUrl);
+ break;
+ }
+ signAppearance.setCertificate(certificate);
+ }
+
+ List crlList = new ArrayList<>();
+ crlList.add(new CrlClientOnline(certificateEntry.getChain()));
+
+ ExternalSignature pks = new PrivateKeySignature(certificateEntry.getPrivateKey(), "SHA256",
+ provider.getName());
+ ExternalDigest digest = new BouncyCastleDigest();
+
+ // Sign the document using the detached mode, CMS or CAdES equivalent.
+ MakeSignature.signDetached(signAppearance, digest, pks, certificateEntry.getChain(), crlList, ocspClient,
+ tsaClient, 0, CryptoStandard.CMS);
+
+ pdfStamper.close();
+
+ } catch (DocumentException e) {
+ throw new PDFGeneratorException(PDFGeneratorExceptionCodeConstant.PDF_EXCEPTION.getErrorCode(),
+ e.getMessage(), e);
+ } finally {
+ outputStream.close();
+ if (pdfStamper != null) {
+ closeQuietly(pdfStamper);
+ }
+ if (pdfReader != null) {
+ pdfReader.close();
+ }
+ }
+ return outputStream;
+ }
+
+ /*
+
+ */
+
+ // Quietly close the pdfStamper.
+ private void closeQuietly(final PdfStamper pdfStamper) throws IOException {
+ try {
+ pdfStamper.close();
+ } catch (DocumentException e) {
+ throw new PDFGeneratorException(PDFGeneratorExceptionCodeConstant.PDF_EXCEPTION.getErrorCode(),
+ e.getMessage(), e);
+ }
+ }
+
+ private void isValidInputStream(InputStream dataInputStream) {
+ if (EmptyCheckUtils.isNullEmpty(dataInputStream)) {
+ throw new PDFGeneratorException(
+ PDFGeneratorExceptionCodeConstant.INPUTSTREAM_NULL_EMPTY_EXCEPTION.getErrorCode(),
+ PDFGeneratorExceptionCodeConstant.INPUTSTREAM_NULL_EMPTY_EXCEPTION.getErrorMessage());
+ }
+ }
+}
diff --git a/src/main/java/io/mosip/print/service/impl/PrintCardImpl.java b/src/main/java/io/mosip/print/service/impl/PrintCardImpl.java
new file mode 100644
index 00000000..887c98d3
--- /dev/null
+++ b/src/main/java/io/mosip/print/service/impl/PrintCardImpl.java
@@ -0,0 +1,43 @@
+package io.mosip.print.service.impl;
+
+import io.mosip.print.service.PrintRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.transaction.Transactional;
+
+@Service
+@Transactional
+public class PrintCardImpl implements PrintImpl {
+ @Autowired
+ PrintRepository printRepository;
+ @Override
+ public Integer sno() {
+ return printRepository.sno();
+ }
+ @Override
+ public Integer countById(String printId) {
+ return printRepository.countById(printId);
+ }
+ @Override
+ public Integer countByRequestId1(String printId) {
+ return printRepository.countByRequestId1(printId);
+ }
+ @Override
+ public Integer findIdByRequestId1(String id) {
+ return printRepository.findIdByRequestId1(id);
+ }
+
+ @Override
+ public Integer updateExistingId(String id,int status,int newstatus) {
+ return printRepository.updateExistingId(id,status,newstatus);
+ }
+}
+
+
+
+
+
+
+
+
diff --git a/src/main/java/io/mosip/print/service/impl/PrintImpl.java b/src/main/java/io/mosip/print/service/impl/PrintImpl.java
new file mode 100644
index 00000000..64fc3bc3
--- /dev/null
+++ b/src/main/java/io/mosip/print/service/impl/PrintImpl.java
@@ -0,0 +1,22 @@
+package io.mosip.print.service.impl;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public interface PrintImpl {
+
+ public Integer sno();
+
+ public Integer countById(String printId) ;
+ public Integer countByRequestId1(String printId);
+ public Integer findIdByRequestId1(String rid) ;
+ public Integer updateExistingId(String rid,int status,int newstatus) ;
+}
+
+
+
+
+
+
+
+
diff --git a/src/main/java/io/mosip/print/service/impl/PrintRestClientServiceImpl.java b/src/main/java/io/mosip/print/service/impl/PrintRestClientServiceImpl.java
index b7fb798b..f945bd22 100644
--- a/src/main/java/io/mosip/print/service/impl/PrintRestClientServiceImpl.java
+++ b/src/main/java/io/mosip/print/service/impl/PrintRestClientServiceImpl.java
@@ -2,6 +2,7 @@
import java.util.List;
+import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.MediaType;
@@ -10,11 +11,10 @@
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
-import io.mosip.kernel.core.exception.ExceptionUtils;
-import io.mosip.kernel.core.logger.spi.Logger;
import io.mosip.print.constant.ApiName;
import io.mosip.print.constant.LoggerFileConstant;
import io.mosip.print.exception.ApisResourceAccessException;
+import io.mosip.print.exception.ExceptionUtils;
import io.mosip.print.exception.PlatformErrorMessages;
import io.mosip.print.logger.PrintLogger;
import io.mosip.print.service.PrintRestClientService;
@@ -29,8 +29,7 @@
public class PrintRestClientServiceImpl implements PrintRestClientService