From d8faaed8993e6eef2dbd4a9e30dc12695686851e Mon Sep 17 00:00:00 2001 From: Vishwa Date: Fri, 17 Nov 2023 10:56:44 +0530 Subject: [PATCH 1/2] Merge pull request #1774 from MonobikashDas/MOSIP-28121 MOSIP-28121 : rename print stage to credential requestor stage --- registration-processor/pom.xml | 1129 ++++++++--------- registration-processor/post-processor/pom.xml | 44 +- .../Dockerfile-not-used | 110 +- .../README.md | 4 +- .../pom.xml | 218 ++-- .../CredentialRequestorStageApplication.java} | 8 +- .../config/CredentialRequestorConfigBean.java | 15 + .../dto/CredentialPartner.java | 16 + .../dto/CredentialPartnersList.java | 10 + .../stage/CredentialRequestorStage.java} | 925 +++++++------- .../exception/VidNotAvailableException.java | 54 +- .../util/CredentialPartnerUtil.java | 225 ++++ .../src/main/resources/bootstrap.properties | 58 +- .../src/main/resources/logback.xml | 0 .../test/CredentialRequestorStageTest.java} | 911 ++++++------- .../processor/core/code/ApiName.java | 3 +- .../core/constant/ProviderStageName.java | 3 +- .../exception/util/PlatformErrorMessages.java | 5 + .../pom.xml | 146 +-- 19 files changed, 2112 insertions(+), 1772 deletions(-) rename registration-processor/post-processor/{registration-processor-printing-stage => registration-processor-credential-requestor-stage}/Dockerfile-not-used (85%) rename registration-processor/post-processor/{registration-processor-printing-stage => registration-processor-credential-requestor-stage}/README.md (57%) rename registration-processor/post-processor/{registration-processor-printing-stage => registration-processor-credential-requestor-stage}/pom.xml (94%) rename registration-processor/post-processor/{registration-processor-printing-stage/src/main/java/io/mosip/registration/processor/print/PrintStageApplication.java => registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/CredentialRequestorStageApplication.java} (68%) create mode 100644 registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/config/CredentialRequestorConfigBean.java create mode 100644 registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/dto/CredentialPartner.java create mode 100644 registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/dto/CredentialPartnersList.java rename registration-processor/post-processor/{registration-processor-printing-stage/src/main/java/io/mosip/registration/processor/print/stage/PrintingStage.java => registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/stage/CredentialRequestorStage.java} (67%) rename registration-processor/post-processor/{registration-processor-printing-stage/src/main/java/io/mosip/registration/processor/print => registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor}/stage/exception/VidNotAvailableException.java (85%) create mode 100644 registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/util/CredentialPartnerUtil.java rename registration-processor/post-processor/{registration-processor-printing-stage => registration-processor-credential-requestor-stage}/src/main/resources/bootstrap.properties (50%) rename registration-processor/post-processor/{registration-processor-printing-stage => registration-processor-credential-requestor-stage}/src/main/resources/logback.xml (100%) rename registration-processor/post-processor/{registration-processor-printing-stage/src/test/java/io/mosip/registrationprocessor/print/stage/test/PrintingStageTest.java => registration-processor-credential-requestor-stage/src/test/java/io/mosip/registrationprocessor/credentialrequestor/test/CredentialRequestorStageTest.java} (87%) diff --git a/registration-processor/pom.xml b/registration-processor/pom.xml index a649d38190e..4197c1f9c75 100644 --- a/registration-processor/pom.xml +++ b/registration-processor/pom.xml @@ -1,567 +1,562 @@ - - - 4.0.0 - - - io.mosip - registration - 1.2.0.1-B3 - - - - - MPL 2.0 - https://www.mozilla.org/en-US/MPL/2.0/ - - - - scm:git:git://github.com/mosip/registration.git - scm:git:ssh://github.com:mosip/registration.git - https://github.com/mosip/registration - HEAD - - - - Mosip - mosip.emailnotifier@gmail.com - io.mosip - https://github.com/mosip/registration - - - io.mosip.registrationprocessor - registration-processor - 1.2.0.1-B3 - pom - - registration-processor - Parent project of MOSIP Registration processor - - - none - UTF-8 - 11 - 11 - 3.8.0 - 3.0.2 - 3.1.0 - 2.22.0 - 0.8.5 - 3.7.0.1746 - 3.2.0 - 3.3.0 - - - 5.0.6.RELEASE - 5.0.4.RELEASE - 2.0.2.RELEASE - 2.0.9.RELEASE - 2.0.0.RELEASE - - 4.0.1.RELEASE - 2.0.0.RELEASE - - - 3.0.0 - 2.0.1.Final - 2.12.0 - 2.12.0 - 6.0.12.Final - 2.1.1 - 1.7.25 - 4.5.6 - - - 2.9.2 - - - 2.5.0 - 5.1.46 - 1.4.195 - 42.2.2 - - - 1.18.8 - - - 2.3.0 - - - 1.60 - 1.6 - - - 3.6.1 - 3.7 - 2.6 - 1.10 - 1.9.2 - 2.2 - 2.6 - 1.7 - 2.0 - - - 4.12 - 1.2.3 - 1.7.19 - 3.4.4 - 2.0.7 - 2.0.7 - 3.1.0 - 1.1.1 - 1.9 - - 1.11.368 - 0.2.4 - - - 3.9.1 - 2.23.0 - 1.0.0 - - 1.1.1 - - - 2.8.1 - - - 0.1.55 - - - 1.2.0.1-B3 - 1.2.0.1-B3 - 1.2.0.1-B3 - 1.2.0.1-B3 - 1.2.0.1-B3 - 1.2.0.1-B3 - 1.2.0.1-B3 - - - 1.2.0.1-B2 - 1.2.0.1-B2 - 1.2.0.1-B2 - 1.2.0.1-B2 - 1.2.0.1-B2 - 1.2.0.1-B2 - 1.2.0.1-B3 - 1.2.0.1-B2 - 1.2.0.1-B2 - 1.2.0.1-B2 - 1.2.0.1-B2 - 1.2.0.1-B2 - 1.2.0.1-B2 - 1.2.0.1-B3 - 1.2.0.1-B2 - 1.2.0.1-B2 - **/dto/**, - **/exception/*Exception.java, - **/config/*Config.java, - **/handler/*ExceptionHandler.java, - **/**/*Application.java, - **/utilities/*.java, - **/validator/*Validator.java, - **/utils/*.java, - **/util/*.java, - **/code/*.java, - **/entity/*.java, - **/config/*.java, - - **/core/code/*.java, - **/packet/storage/entity/*.java, - **/manager/exception/systemexception/*.java, - **/registration/processor/rest/client/*.java, - **/registration/processor/rest/client/audit/builder/*.java, - - **/registration/processor/packet/receiver/*.java, - **/registration/processor/packet/receiver/exception/systemexception/*.java, - **/registration/processor/failoverstage/*.java, - **/registration/processor/stages/*.java, - **/registration/processor/retry/verticle/*.java, - **/registration/processor/retry/verticle/stages/*.java, - **/registration/processor/retry/verticle/constants/*.java, - **/registration/processor/packet/decrypter/job/stage/*.java, - **/registration/processor/packet/decryptor/job/exception/constant/*.java, - - **/registration/processor/virus/scanner/job/exceptions/*.java, - - - **/registration/processor/stages/app/*.java, - **/registration/processor/stages/executor/*.java, - **/registration/processor/camel/bridge/processor/*.java, - **/registration/processor/core/constant/*.java, - **/registration/processor/core/packet/dto/demographicinfo/*.java, - **/registration/processor/core/packet/dto/demographicinfo/identify/*.java, - **/registration/processor/core/packet/dto/regcentermachine/*.java, - - **/registration/processor/quality/check/client/*.java, - **/registration/processor/quality/check/code/*.java, - **/registration/processor/quality/check/entity/*.java, - **/registration/processor/quality/check/exception/*.java, - **/registration/processor/quality/check/*.java, - **/registration/processor/message/sender/*.java, - **/registration/processor/message/sender/utility/*.java, - **/registration/processor/core/logger/*.java, - **/registration/processor/core/notification/template/mapping/*.java, - **/registration/processor/bio/dedupe/service/*.java, - **/registration/processor/bio/dedupe/exception/*.java, - - **/registration/processor/packet/storage/storage/*.java, - **/registration/processor/packet/storage/exception/*.java, - **/registration/processor/status/repositary/*.java, - **/registration/processor/status/entity/*.java, - **/registration/processor/virus/scanner/job/*.java, - - - **/registration/processor/packet/uploader/*.java, - **/registration/processor/biodedupe/*.java, - - - **/registration/processor/abis/config/*.java, - **/registration/processor/abis/controller/*.java, - **/registration/processor/abis/exception/*.java, - **/registration/processor/abis/messagequeue/*.java, - **/registration/processor/abis/service/*.java, - **/registration/processor/abis/service/impl/*.java, - - - **/registration/processor/abis/handler/*.java, - **/registration/processor/abis/handler/config/*.java, - - **/registration/processor/packet/service/**/*.java, - **/registration/processor/packet/upload/**/*.java, - - **/registration/processor/status/code/*.java, - **/registration/processor/rest/client/config/RestConfigBean.java, - **/registration/processor/bio/dedupe/api/BioDedupeApiApp.java, - **/registration/processor/manual/verification/response/builder/*.java, - **/registration/processor/manual/verification/config/*.java, - **/registration/processor/stages/config/OSIConfigBean.java, - **/registration/processor/stages/demo/dedupe/StatusMessage.java, - **/registration/processor/stages/demo/dedupe/DemodedupeStage.java, - **/registration/processor/stages/demo/dedupe/BiometricValidation.java, - **/registration/processor/core/exception/ExceptionJSONInfo.java, - **/registration/processor/core/config/CoreConfigBean.java, - **/registration/processor/core/kernel/beans/KernelConfig.java, - **/registration/processor/core/abstractverticle/MosipVerticleAPIManager.java, - **/registration/processor/core/abstractverticle/WorkflowInternalActionDTO.java, - **/registration/processor/core/http/*.java, - **/registration/processor/core/queue/factory/*.java, - **/registration/processor/core/queue/impl/*.java, - **/registration/processor/core/tracing/*.java, - **/registration/processor/message/sender/config/MsgNotificationBeanCofig.java, - **/registration/processor/print/exception/QueueConnectionNotFound.java, - **/registration/processor/stages/demodedupe/StatusMessage.java, - **/registration/processor/print/service/utility/UINCardConstant.java, - **/registration/processor/stages/demodedupe/BiometricValidation.java, - **/registration/processor/camel/bridge/MosipBridgeFactory.java, - **/registration/processor/manual/verification/stage/ManualVerificationStage.java, - **/registration/processor/packet/receiver/builder/PacketReceiverResponseBuilder.java, - **/registration/processor/packet/receiver/stage/PacketReceiverStage.java, - **/registration/processor/camel/bridge/**/*.java, - **/registration/processor/stages/connector/stage/**/*.java, - **/registration/processor/stages/demodedupe/DemoDedupeStage.java, - - **/registration/processor/packet/storage/mapper/PacketInfoMapper.java, - **/registration/processor/packet/storage/dao/PacketInfoDao.java, - **/registration/processor/packet/uploader/constants/*.java, - **/registration/processor/packet/manager/constant/*.java, - **/registration/processor/print/exception/PrintGlobalExceptionHandler.java, - **/registration/processor/packet/receiver/constants/*.java, - **/registration/processor/print/service/exception/*.java, - **/registration/processor/print/exception/*.java, - **/registration/processor/packet/uploader/constants/*.java, - **/registration/processor/packet/uploader/decryptor/*.java, - **/registration/processor/core/abstractverticle/MosipRouter.java, - **/registration/processor/packet/uploader/decryptor/*.java, - - **/registration/processor/print/service/impl/PrintPostServiceImpl.java, - - **/registration/processor/message/sender/constants/*.java, - **/registration/processor/core/abstractverticle/BaseHealthCheckModel.java, - **/registration/processor/core/**/TokenValidator.java, - **/registration/processor/core/abstractverticle/StageHealthCheckHandler.java, - **/registration/processor/core/abstractverticle/MessageDTO.java, - **/registration/processor/request/handler/**/*.java - - **/dto/**,**/entity/**,**/config/**,**/handler/**,**/utilities/**, - **/validator/**, **/utils/**,**/util/**,**/code/** - none - - - - - ossrh - CentralRepository - https://oss.sonatype.org/content/repositories/snapshots - default - - true - - - - central - MavenCentral - default - https://repo1.maven.org/maven2 - - false - - - - - - - - org.mockito - mockito-core - 3.4.4 - test - - - - net.bytebuddy - byte-buddy - 1.10.13 - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - org.projectlombok - lombok - 1.18.8 - provided - - - org.powermock - powermock-core - 2.0.7 - test - - - javax.xml.bind - jaxb-api - 2.3.1 - - - org.javassist - javassist - 3.27.0-GA - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson.version} - - - - - - registration-processor-core - registration-processor-rest-client - registration-processor-packet-manager - registration-processor-common-camel-bridge - registration-processor-bio-dedupe-service-impl - registration-processor-info-storage-service - registration-processor-registration-status-service-impl - registration-processor-message-sender-impl - registration-processor-notification-service - init - pre-processor - core-processor - post-processor - mosip-stage-executor - stage-groups - workflow-engine - registration-processor-landing-zone - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven.surefire.plugin.version} - - ${skipTests} - false - - ${argLine} --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --illegal-access=permit - - - - - org.jacoco - jacoco-maven-plugin - ${maven.jacoco.version} - - - - prepare-agent - - - - report - prepare-package - - report - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven.compiler.version} - - ${maven.compiler.source} - ${maven.compiler.target} - - - - org.apache.maven.plugins - maven-jar-plugin - ${maven.jar.plugin.version} - - - - true - true - - - ${project.name} - ${project.version} - ${user.name} - ${os.name} - ${maven.build.timestamp} - ${env.BUILD_NUMBER} - ${env.BUILD_ID} - ${env.BUILD_URL} - - - - - - pl.project13.maven - git-commit-id-plugin - 3.0.1 - - - get-the-git-infos - - revision - - validate - - - - true - ${project.build.outputDirectory}/git.properties - - ^git.build.(time|version)$ - ^git.commit.id.(abbrev|full)$ - - full - ${project.basedir}/.git - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - --pinentry-mode - loopback - - - - - - - org.apache.maven.plugins - maven-war-plugin - ${maven.war.plugin.version} - - - - true - true - - - ${project.name} - ${project.version} - ${user.name} - ${os.name} - ${maven.build.timestamp} - ${env.BUILD_NUMBER} - ${env.BUILD_ID} - ${env.BUILD_URL} - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - ${maven.javadoc.version} - - true - none - - - - - - - sonar - - . - src/main/java/**,src/main/resources/** - ${sonar.coverage.exclusions} - https://sonarcloud.io - - - false - - - - - org.sonarsource.scanner.maven - sonar-maven-plugin - ${maven.sonar.plugin.version} - - - verify - - sonar - - - - - - - - - + + + 4.0.0 + + + io.mosip + registration + 1.2.0.1-B3 + + + + + MPL 2.0 + https://www.mozilla.org/en-US/MPL/2.0/ + + + + scm:git:git://github.com/mosip/registration.git + scm:git:ssh://github.com:mosip/registration.git + https://github.com/mosip/registration + HEAD + + + + Mosip + mosip.emailnotifier@gmail.com + io.mosip + https://github.com/mosip/registration + + + io.mosip.registrationprocessor + registration-processor + 1.2.0.1-B3 + pom + + registration-processor + Parent project of MOSIP Registration processor + + + none + UTF-8 + 11 + 11 + 3.8.0 + 3.0.2 + 3.1.0 + 2.22.0 + 0.8.5 + 3.7.0.1746 + 3.2.0 + 3.3.0 + + + 5.0.6.RELEASE + 5.0.4.RELEASE + 2.0.2.RELEASE + 2.0.9.RELEASE + 2.0.0.RELEASE + + 4.0.1.RELEASE + 2.0.0.RELEASE + + + 3.0.0 + 2.0.1.Final + 2.12.0 + 2.12.0 + 6.0.12.Final + 2.1.1 + 1.7.25 + 4.5.6 + + + 2.9.2 + + + 2.5.0 + 5.1.46 + 1.4.195 + 42.2.2 + + + 1.18.8 + + + 2.3.0 + + + 1.60 + 1.6 + + + 3.6.1 + 3.7 + 2.6 + 1.10 + 1.9.2 + 2.2 + 2.6 + 1.7 + 2.0 + + + 4.12 + 1.2.3 + 1.7.19 + 3.4.4 + 2.0.7 + 2.0.7 + 3.1.0 + 1.1.1 + 1.9 + + 1.11.368 + 0.2.4 + + + 3.9.1 + 2.23.0 + 1.0.0 + + 1.1.1 + + + 2.8.1 + + + 0.1.55 + + + 1.2.0.1-B3 + 1.2.0.1-B3 + 1.2.0.1-B3 + 1.2.0.1-B3 + 1.2.0.1-B3 + 1.2.0.1-B3 + 1.2.0.1-B3 + + + 1.2.0.1-B2 + 1.2.0.1-B2 + 1.2.0.1-B2 + 1.2.0.1-B2 + 1.2.0.1-B2 + 1.2.0.1-B2 + 1.2.0.1-B3 + 1.2.0.1-B2 + 1.2.0.1-B2 + 1.2.0.1-B2 + 1.2.0.1-B2 + 1.2.0.1-B2 + 1.2.0.1-B2 + 1.2.0.1-B3 + 1.2.0.1-B2 + 1.2.0.1-B2 + **/dto/**, + **/exception/*Exception.java, + **/config/*Config.java, + **/handler/*ExceptionHandler.java, + **/**/*Application.java, + **/utilities/*.java, + **/validator/*Validator.java, + **/utils/*.java, + **/util/*.java, + **/code/*.java, + **/entity/*.java, + **/config/*.java, + + **/core/code/*.java, + **/packet/storage/entity/*.java, + **/manager/exception/systemexception/*.java, + **/registration/processor/rest/client/*.java, + **/registration/processor/rest/client/audit/builder/*.java, + + **/registration/processor/packet/receiver/*.java, + **/registration/processor/packet/receiver/exception/systemexception/*.java, + **/registration/processor/failoverstage/*.java, + **/registration/processor/stages/*.java, + **/registration/processor/retry/verticle/*.java, + **/registration/processor/retry/verticle/stages/*.java, + **/registration/processor/retry/verticle/constants/*.java, + **/registration/processor/packet/decrypter/job/stage/*.java, + **/registration/processor/packet/decryptor/job/exception/constant/*.java, + + **/registration/processor/virus/scanner/job/exceptions/*.java, + + + **/registration/processor/stages/app/*.java, + **/registration/processor/stages/executor/*.java, + **/registration/processor/camel/bridge/processor/*.java, + **/registration/processor/core/constant/*.java, + **/registration/processor/core/packet/dto/demographicinfo/*.java, + **/registration/processor/core/packet/dto/demographicinfo/identify/*.java, + **/registration/processor/core/packet/dto/regcentermachine/*.java, + + **/registration/processor/quality/check/client/*.java, + **/registration/processor/quality/check/code/*.java, + **/registration/processor/quality/check/entity/*.java, + **/registration/processor/quality/check/exception/*.java, + **/registration/processor/quality/check/*.java, + **/registration/processor/message/sender/*.java, + **/registration/processor/message/sender/utility/*.java, + **/registration/processor/core/logger/*.java, + **/registration/processor/core/notification/template/mapping/*.java, + **/registration/processor/bio/dedupe/service/*.java, + **/registration/processor/bio/dedupe/exception/*.java, + + **/registration/processor/packet/storage/storage/*.java, + **/registration/processor/packet/storage/exception/*.java, + **/registration/processor/status/repositary/*.java, + **/registration/processor/status/entity/*.java, + **/registration/processor/virus/scanner/job/*.java, + + + **/registration/processor/packet/uploader/*.java, + **/registration/processor/biodedupe/*.java, + + + **/registration/processor/abis/config/*.java, + **/registration/processor/abis/controller/*.java, + **/registration/processor/abis/exception/*.java, + **/registration/processor/abis/messagequeue/*.java, + **/registration/processor/abis/service/*.java, + **/registration/processor/abis/service/impl/*.java, + + + **/registration/processor/abis/handler/*.java, + **/registration/processor/abis/handler/config/*.java, + + **/registration/processor/packet/service/**/*.java, + **/registration/processor/packet/upload/**/*.java, + + **/registration/processor/status/code/*.java, + **/registration/processor/rest/client/config/RestConfigBean.java, + **/registration/processor/bio/dedupe/api/BioDedupeApiApp.java, + **/registration/processor/manual/verification/response/builder/*.java, + **/registration/processor/manual/verification/config/*.java, + **/registration/processor/stages/config/OSIConfigBean.java, + **/registration/processor/stages/demo/dedupe/StatusMessage.java, + **/registration/processor/stages/demo/dedupe/DemodedupeStage.java, + **/registration/processor/stages/demo/dedupe/BiometricValidation.java, + **/registration/processor/core/exception/ExceptionJSONInfo.java, + **/registration/processor/core/config/CoreConfigBean.java, + **/registration/processor/core/kernel/beans/KernelConfig.java, + **/registration/processor/core/abstractverticle/MosipVerticleAPIManager.java, + **/registration/processor/core/abstractverticle/WorkflowInternalActionDTO.java, + **/registration/processor/core/http/*.java, + **/registration/processor/core/queue/factory/*.java, + **/registration/processor/core/queue/impl/*.java, + **/registration/processor/core/tracing/*.java, + **/registration/processor/message/sender/config/MsgNotificationBeanCofig.java, + **/registration/processor/abis/exception/QueueConnectionNotFound.java, + **/registration/processor/stages/demodedupe/StatusMessage.java, + **/registration/processor/stages/demodedupe/BiometricValidation.java, + **/registration/processor/camel/bridge/MosipBridgeFactory.java, + **/registration/processor/manual/verification/stage/ManualVerificationStage.java, + **/registration/processor/packet/receiver/builder/PacketReceiverResponseBuilder.java, + **/registration/processor/packet/receiver/stage/PacketReceiverStage.java, + **/registration/processor/camel/bridge/**/*.java, + **/registration/processor/stages/connector/stage/**/*.java, + **/registration/processor/stages/demodedupe/DemoDedupeStage.java, + + **/registration/processor/packet/storage/mapper/PacketInfoMapper.java, + **/registration/processor/packet/storage/dao/PacketInfoDao.java, + **/registration/processor/packet/uploader/constants/*.java, + **/registration/processor/packet/manager/constant/*.java, + **/registration/processor/packet/receiver/constants/*.java, + **/registration/processor/credentialrequestor/stage/exception/*.java, + **/registration/processor/packet/uploader/constants/*.java, + **/registration/processor/packet/uploader/decryptor/*.java, + **/registration/processor/core/abstractverticle/MosipRouter.java, + **/registration/processor/packet/uploader/decryptor/*.java, + + **/registration/processor/message/sender/constants/*.java, + **/registration/processor/core/abstractverticle/BaseHealthCheckModel.java, + **/registration/processor/core/**/TokenValidator.java, + **/registration/processor/core/abstractverticle/StageHealthCheckHandler.java, + **/registration/processor/core/abstractverticle/MessageDTO.java, + **/registration/processor/request/handler/**/*.java + + **/dto/**,**/entity/**,**/config/**,**/handler/**,**/utilities/**, + **/validator/**, **/utils/**,**/util/**,**/code/** + none + + + + + ossrh + CentralRepository + https://oss.sonatype.org/content/repositories/snapshots + default + + true + + + + central + MavenCentral + default + https://repo1.maven.org/maven2 + + false + + + + + + + + org.mockito + mockito-core + 3.4.4 + test + + + + net.bytebuddy + byte-buddy + 1.10.13 + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + org.projectlombok + lombok + 1.18.8 + provided + + + org.powermock + powermock-core + 2.0.7 + test + + + javax.xml.bind + jaxb-api + 2.3.1 + + + org.javassist + javassist + 3.27.0-GA + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + + + + registration-processor-core + registration-processor-rest-client + registration-processor-packet-manager + registration-processor-common-camel-bridge + registration-processor-bio-dedupe-service-impl + registration-processor-info-storage-service + registration-processor-registration-status-service-impl + registration-processor-message-sender-impl + registration-processor-notification-service + init + pre-processor + core-processor + post-processor + mosip-stage-executor + stage-groups + workflow-engine + registration-processor-landing-zone + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven.surefire.plugin.version} + + ${skipTests} + false + + ${argLine} --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --illegal-access=permit + + + + + org.jacoco + jacoco-maven-plugin + ${maven.jacoco.version} + + + + prepare-agent + + + + report + prepare-package + + report + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.version} + + ${maven.compiler.source} + ${maven.compiler.target} + + + + org.apache.maven.plugins + maven-jar-plugin + ${maven.jar.plugin.version} + + + + true + true + + + ${project.name} + ${project.version} + ${user.name} + ${os.name} + ${maven.build.timestamp} + ${env.BUILD_NUMBER} + ${env.BUILD_ID} + ${env.BUILD_URL} + + + + + + pl.project13.maven + git-commit-id-plugin + 3.0.1 + + + get-the-git-infos + + revision + + validate + + + + true + ${project.build.outputDirectory}/git.properties + + ^git.build.(time|version)$ + ^git.commit.id.(abbrev|full)$ + + full + ${project.basedir}/.git + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven.war.plugin.version} + + + + true + true + + + ${project.name} + ${project.version} + ${user.name} + ${os.name} + ${maven.build.timestamp} + ${env.BUILD_NUMBER} + ${env.BUILD_ID} + ${env.BUILD_URL} + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven.javadoc.version} + + true + none + + + + + + + sonar + + . + src/main/java/**,src/main/resources/** + ${sonar.coverage.exclusions} + https://sonarcloud.io + + + false + + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + ${maven.sonar.plugin.version} + + + verify + + sonar + + + + + + + + + diff --git a/registration-processor/post-processor/pom.xml b/registration-processor/post-processor/pom.xml index 0a55dd17040..325ff6ddac3 100644 --- a/registration-processor/post-processor/pom.xml +++ b/registration-processor/post-processor/pom.xml @@ -1,22 +1,22 @@ - - - 4.0.0 - pom - - io.mosip.registrationprocessor - registration-processor - 1.2.0.1-B3 - - 1.2.0.1-B3 - post-processor - post-processor - - UTF-8 - - - registration-processor-message-sender-stage - registration-processor-printing-stage - registration-processor-registration-transaction-service - - + + + 4.0.0 + pom + + io.mosip.registrationprocessor + registration-processor + 1.2.0.1-B3 + + 1.2.0.1-B3 + post-processor + post-processor + + UTF-8 + + + registration-processor-message-sender-stage + registration-processor-credential-requestor-stage + registration-processor-registration-transaction-service + + diff --git a/registration-processor/post-processor/registration-processor-printing-stage/Dockerfile-not-used b/registration-processor/post-processor/registration-processor-credential-requestor-stage/Dockerfile-not-used similarity index 85% rename from registration-processor/post-processor/registration-processor-printing-stage/Dockerfile-not-used rename to registration-processor/post-processor/registration-processor-credential-requestor-stage/Dockerfile-not-used index 2c43739a850..2767feb48d7 100644 --- a/registration-processor/post-processor/registration-processor-printing-stage/Dockerfile-not-used +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/Dockerfile-not-used @@ -1,55 +1,55 @@ -FROM openjdk:11 - -#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image -#FROM openjdk:8-jdk-alpine - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG spring_config_label - -# can be passed during Docker build as build time environment for spring profiles active -ARG active_profile - -# can be passed during Docker build as build time environment for config server URL -ARG spring_config_url - -# can be passed during Docker build as build time environment for glowroot -ARG is_glowroot - -# can be passed during Docker build as build time environment for artifactory URL -ARG artifactory_url - -# environment variable to pass active profile such as DEV, QA etc at docker runtime -ENV active_profile_env=${active_profile} - -# environment variable to pass github branch to pickup configuration from, at docker runtime -ENV spring_config_label_env=${spring_config_label} - -# environment variable to pass github branch to pickup configuration from, at docker runtime -ENV spring_config_label_env=${spring_config_label} - -# environment variable to pass glowroot, at docker runtime -ENV is_glowroot_env=${is_glowroot} - -# environment variable to pass artifactory url, at docker runtime -ENV artifactory_url_env=${artifactory_url} - -# change volume to whichever storage directory you want to use for this container. -VOLUME /home/logs - -COPY ./target/registration-processor-printing-stage-*.jar registration-processor-printing-stage.jar - -CMD if [ "$is_glowroot_env" = "present" ]; then \ - wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ - apt-get update && apt-get install -y unzip ; \ - unzip glowroot.zip ; \ - rm -rf glowroot.zip ; \ - - sed -i 's//registration-processor-printing-stage/g' glowroot/glowroot.properties ; \ - java -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -jar -javaagent:glowroot/glowroot.jar registration-processor-printing-stage.jar ; \ - else \ - java -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -jar registration-processor-printing-stage.jar ; \ - fi - - -#CMD ["java","-Dspring.cloud.config.label=${spring_config_label_env}","-Dspring.profiles.active=${active_profile_env}","-Dspring.cloud.config.uri=${spring_config_url_env}","-jar","registration-processor-printing-stage.jar"] - +FROM openjdk:11 + +#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image +#FROM openjdk:8-jdk-alpine + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG spring_config_label + +# can be passed during Docker build as build time environment for spring profiles active +ARG active_profile + +# can be passed during Docker build as build time environment for config server URL +ARG spring_config_url + +# can be passed during Docker build as build time environment for glowroot +ARG is_glowroot + +# can be passed during Docker build as build time environment for artifactory URL +ARG artifactory_url + +# environment variable to pass active profile such as DEV, QA etc at docker runtime +ENV active_profile_env=${active_profile} + +# environment variable to pass github branch to pickup configuration from, at docker runtime +ENV spring_config_label_env=${spring_config_label} + +# environment variable to pass github branch to pickup configuration from, at docker runtime +ENV spring_config_label_env=${spring_config_label} + +# environment variable to pass glowroot, at docker runtime +ENV is_glowroot_env=${is_glowroot} + +# environment variable to pass artifactory url, at docker runtime +ENV artifactory_url_env=${artifactory_url} + +# change volume to whichever storage directory you want to use for this container. +VOLUME /home/logs + +COPY ./target/registration-processor-credential-requestor-stage-*.jar registration-processor-credential-requestor-stage.jar + +CMD if [ "$is_glowroot_env" = "present" ]; then \ + wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ + apt-get update && apt-get install -y unzip ; \ + unzip glowroot.zip ; \ + rm -rf glowroot.zip ; \ + + sed -i 's//registration-processor-credential-requestor-stage/g' glowroot/glowroot.properties ; \ + java -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -jar -javaagent:glowroot/glowroot.jar registration-processor-credential-requestor-stage.jar ; \ + else \ + java -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -jar registration-processor-credential-requestor-stage.jar ; \ + fi + + +#CMD ["java","-Dspring.cloud.config.label=${spring_config_label_env}","-Dspring.profiles.active=${active_profile_env}","-Dspring.cloud.config.uri=${spring_config_url_env}","-jar","registration-processor-credential-requestor-stage.jar"] + diff --git a/registration-processor/post-processor/registration-processor-printing-stage/README.md b/registration-processor/post-processor/registration-processor-credential-requestor-stage/README.md similarity index 57% rename from registration-processor/post-processor/registration-processor-printing-stage/README.md rename to registration-processor/post-processor/registration-processor-credential-requestor-stage/README.md index 71b6369e3b6..320dffd6672 100644 --- a/registration-processor/post-processor/registration-processor-printing-stage/README.md +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/README.md @@ -1,7 +1,7 @@ -# Priting Stage +# Credential Requestor Stage ## About -Creates Credential Request for printing systems. +Creates Credential Request for internal/external systems. ## Default context, path, port Refert to [bootstrap properties](src/main/resources/bootstrap.properties) diff --git a/registration-processor/post-processor/registration-processor-printing-stage/pom.xml b/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml similarity index 94% rename from registration-processor/post-processor/registration-processor-printing-stage/pom.xml rename to registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml index 5fe9b79df20..e716cc6f348 100644 --- a/registration-processor/post-processor/registration-processor-printing-stage/pom.xml +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml @@ -1,107 +1,111 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - post-processor - 1.2.0.1-B3 - - registration-processor-printing-stage - 1.2.0.1-B3 - - UTF-8 - UTF-8 - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - ${h2.version} - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - org.springframework - spring-tx - ${spring-framework.version} - - - io.vertx - vertx-unit - ${vertx.version} - test - - - io.vertx - vertx-web-client - ${vertx.version} - - - org.apache.httpcomponents - httpmime - 4.3.1 - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - - junit - junit - test - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + post-processor + 1.2.0.1-B3 + + registration-processor-credential-requestor-stage + 1.2.0.1-B3 + + UTF-8 + UTF-8 + + + + + org.springframework.cloud + spring-cloud-starter-config + ${spring-cloud-config.version} + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + ${h2.version} + + + + + + org.springframework + spring-context + ${spring-framework.version} + + + org.springframework + spring-tx + ${spring-framework.version} + + + io.vertx + vertx-unit + ${vertx.version} + test + + + io.vertx + vertx-web-client + ${vertx.version} + + + org.apache.httpcomponents + httpmime + 4.3.1 + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + org.mvel + mvel2 + 2.4.12.Final + + + junit + junit + test + + + org.powermock + powermock-module-junit4 + ${powermock.module.junit4.version} + test + + + org.powermock + powermock-api-mockito2 + ${powermock.api.mockito.version} + test + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + + + + + diff --git a/registration-processor/post-processor/registration-processor-printing-stage/src/main/java/io/mosip/registration/processor/print/PrintStageApplication.java b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/CredentialRequestorStageApplication.java similarity index 68% rename from registration-processor/post-processor/registration-processor-printing-stage/src/main/java/io/mosip/registration/processor/print/PrintStageApplication.java rename to registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/CredentialRequestorStageApplication.java index 742d6a00973..25c6ce2c4be 100644 --- a/registration-processor/post-processor/registration-processor-printing-stage/src/main/java/io/mosip/registration/processor/print/PrintStageApplication.java +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/CredentialRequestorStageApplication.java @@ -1,14 +1,14 @@ -package io.mosip.registration.processor.print; +package io.mosip.registration.processor.credentialrequestor; import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import io.mosip.registration.processor.print.stage.PrintingStage; +import io.mosip.registration.processor.credentialrequestor.stage.CredentialRequestorStage; /** * @author M1048399 * */ -public class PrintStageApplication { +public class CredentialRequestorStageApplication { public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); @@ -19,7 +19,7 @@ public static void main(String[] args) { "io.mosip.registration.processor.packet.storage.config"); ctx.refresh(); - PrintingStage printStage = ctx.getBean(PrintingStage.class); + CredentialRequestorStage printStage = ctx.getBean(CredentialRequestorStage.class); printStage.deployVerticle(); } diff --git a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/config/CredentialRequestorConfigBean.java b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/config/CredentialRequestorConfigBean.java new file mode 100644 index 00000000000..344cb73d687 --- /dev/null +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/config/CredentialRequestorConfigBean.java @@ -0,0 +1,15 @@ +package io.mosip.registration.processor.credentialrequestor.config; + +import io.mosip.registration.processor.credentialrequestor.util.CredentialPartnerUtil; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class CredentialRequestorConfigBean { + + @Bean + CredentialPartnerUtil credentialPartnerUtil() { + return new CredentialPartnerUtil(); + } + +} \ No newline at end of file diff --git a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/dto/CredentialPartner.java b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/dto/CredentialPartner.java new file mode 100644 index 00000000000..4cd399b0e5b --- /dev/null +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/dto/CredentialPartner.java @@ -0,0 +1,16 @@ +package io.mosip.registration.processor.credentialrequestor.dto; + +import lombok.Data; + +import java.util.List; + +@Data +public class CredentialPartner { + private String id; + private String partnerId; + private String credentialType; + private String template; + private String appIdBasedCredentialIdSuffix; + private List process; + private List metaInfoFields; +} diff --git a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/dto/CredentialPartnersList.java b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/dto/CredentialPartnersList.java new file mode 100644 index 00000000000..72afbab0056 --- /dev/null +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/dto/CredentialPartnersList.java @@ -0,0 +1,10 @@ +package io.mosip.registration.processor.credentialrequestor.dto; + +import lombok.Data; + +import java.util.List; + +@Data +public class CredentialPartnersList { + private List partners; +} diff --git a/registration-processor/post-processor/registration-processor-printing-stage/src/main/java/io/mosip/registration/processor/print/stage/PrintingStage.java b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/stage/CredentialRequestorStage.java similarity index 67% rename from registration-processor/post-processor/registration-processor-printing-stage/src/main/java/io/mosip/registration/processor/print/stage/PrintingStage.java rename to registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/stage/CredentialRequestorStage.java index c46df5eec54..39ee23c62ca 100644 --- a/registration-processor/post-processor/registration-processor-printing-stage/src/main/java/io/mosip/registration/processor/print/stage/PrintingStage.java +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/stage/CredentialRequestorStage.java @@ -1,448 +1,479 @@ -package io.mosip.registration.processor.print.stage; - -import java.io.File; -import java.io.IOException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.json.simple.JSONObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.cloud.context.config.annotation.RefreshScope; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.Environment; -import org.springframework.http.MediaType; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Service; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.kernel.core.exception.ServiceError; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.kernel.core.util.DateUtils; -import io.mosip.registration.processor.core.abstractverticle.MessageBusAddress; -import io.mosip.registration.processor.core.abstractverticle.MessageDTO; -import io.mosip.registration.processor.core.abstractverticle.MosipEventBus; -import io.mosip.registration.processor.core.abstractverticle.MosipRouter; -import io.mosip.registration.processor.core.abstractverticle.MosipVerticleAPIManager; -import io.mosip.registration.processor.core.code.ApiName; -import io.mosip.registration.processor.core.code.EventId; -import io.mosip.registration.processor.core.code.EventName; -import io.mosip.registration.processor.core.code.EventType; -import io.mosip.registration.processor.core.code.ModuleName; -import io.mosip.registration.processor.core.code.RegistrationTransactionStatusCode; -import io.mosip.registration.processor.core.code.RegistrationTransactionTypeCode; -import io.mosip.registration.processor.core.common.rest.dto.ErrorDTO; -import io.mosip.registration.processor.core.constant.IdType; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.constant.VidType; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.exception.util.PlatformSuccessMessages; -import io.mosip.registration.processor.core.http.RequestWrapper; -import io.mosip.registration.processor.core.http.ResponseWrapper; -import io.mosip.registration.processor.core.idrepo.dto.CredentialRequestDto; -import io.mosip.registration.processor.core.idrepo.dto.CredentialResponseDto; -import io.mosip.registration.processor.core.idrepo.dto.VidInfoDTO; -import io.mosip.registration.processor.core.idrepo.dto.VidsInfosDTO; -import io.mosip.registration.processor.core.logger.LogDescription; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; -import io.mosip.registration.processor.core.status.util.StatusUtil; -import io.mosip.registration.processor.core.status.util.TrimExceptionMessage; -import io.mosip.registration.processor.core.util.JsonUtil; -import io.mosip.registration.processor.packet.storage.utils.Utilities; -import io.mosip.registration.processor.print.stage.exception.VidNotAvailableException; -import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; -import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.service.RegistrationStatusService; - -/** - * The Class PrintStage. - * - * @author M1048358 Alok - * @author Ranjitha Siddegowda - * @author Sowmya - */ -@RefreshScope -@Service -@Configuration -@EnableScheduling -@ComponentScan(basePackages = { "${mosip.auth.adapter.impl.basepackage}", - "io.mosip.registration.processor.core.config", - "io.mosip.registration.processor.stages.config", - "io.mosip.registration.processor.print.config", - "io.mosip.registrationprocessor.stages.config", - "io.mosip.registration.processor.status.config", - "io.mosip.registration.processor.rest.client.config", - "io.mosip.registration.processor.packet.storage.config", - "io.mosip.registration.processor.packet.manager.config", - "io.mosip.kernel.idobjectvalidator.config", - "io.mosip.registration.processor.core.kernel.beans" }) -public class PrintingStage extends MosipVerticleAPIManager { - - private static final String STAGE_PROPERTY_PREFIX = "mosip.regproc.printing."; - private Random sr = null; - private static final int max = 999999; - private static final int min = 100000; - - /** The Constant FILE_SEPARATOR. */ - public static final String FILE_SEPARATOR = File.separator; - - - /** The reg proc logger. */ - private static Logger regProcLogger = RegProcessorLogger.getLogger(PrintingStage.class); - - /** The cluster manager url. */ - @Value("${vertx.cluster.configuration}") - private String clusterManagerUrl; - - - /** The core audit request builder. */ - @Autowired - private AuditLogRequestBuilder auditLogRequestBuilder; - - /** The mosip event bus. */ - private MosipEventBus mosipEventBus; - - /** The registration status service. */ - @Autowired - RegistrationStatusService registrationStatusService; - - /** worker pool size. */ - @Value("${worker.pool.size}") - private Integer workerPoolSize; - - /** After this time intervel, message should be considered as expired (In seconds). */ - @Value("${mosip.regproc.printing.message.expiry-time-limit}") - private Long messageExpiryTimeLimit; - - - @Value("${mosip.registration.processor.encrypt:false}") - private boolean encrypt; - - /** Mosip router for APIs */ - @Autowired - MosipRouter router; - - boolean isConnection = false; - - private static final String SEPERATOR = "::"; - - @Autowired - private RegistrationProcessorRestClientService restClientService; - - @Autowired - private ObjectMapper mapper; - - @Autowired - private Environment env; - - private static final String DATETIME_PATTERN = "mosip.registration.processor.datetime.pattern"; - - - @Autowired - private Utilities utilities; - - @Override - protected String getPropertyPrefix() { - return STAGE_PROPERTY_PREFIX; - } - - /** - * Deploy verticle. - */ - public void deployVerticle() { - mosipEventBus = this.getEventBus(this, clusterManagerUrl, workerPoolSize); - this.consumeAndSend(mosipEventBus, MessageBusAddress.PRINTING_BUS_IN, MessageBusAddress.PRINTING_BUS_OUT, - messageExpiryTimeLimit); - } - - /* - * (non-Javadoc) - * - * @see - * io.mosip.registration.processor.core.spi.eventbus.EventBusManager#process( - * java.lang.Object) - */ - @Override - public MessageDTO process(MessageDTO object) { - TrimExceptionMessage trimeExpMessage = new TrimExceptionMessage(); - object.setMessageBusAddress(MessageBusAddress.PRINTING_BUS_IN); - object.setInternalError(Boolean.FALSE); - object.setIsValid(Boolean.FALSE); - LogDescription description = new LogDescription(); - - boolean isTransactionSuccessful = false; - String uin = null; - String regId = object.getRid(); - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - regId, "PrintStage::process()::entry"); - - InternalRegistrationStatusDto registrationStatusDto = null; - RequestWrapper requestWrapper = new RequestWrapper<>(); - ResponseWrapper responseWrapper = null; - CredentialResponseDto credentialResponseDto; - try { - registrationStatusDto = registrationStatusService.getRegistrationStatus( - regId, object.getReg_type(), object.getIteration(), object.getWorkflowInstanceId()); - registrationStatusDto - .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.PRINT_SERVICE.toString()); - registrationStatusDto.setRegistrationStageName(getStageName()); - JSONObject jsonObject = utilities.retrieveUIN(regId); - uin = JsonUtil.getJSONValue(jsonObject, IdType.UIN.toString()); - if (uin == null) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), null, - PlatformErrorMessages.RPR_PRT_UIN_NOT_FOUND_IN_DATABASE.name()); - object.setIsValid(Boolean.FALSE); - isTransactionSuccessful = false; - description.setMessage(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getMessage()); - description.setCode(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getCode()); - - registrationStatusDto.setStatusComment( - StatusUtil.UIN_NOT_FOUND_IN_DATABASE.getMessage()); - registrationStatusDto.setSubStatusCode(StatusUtil.UIN_NOT_FOUND_IN_DATABASE.getCode()); - registrationStatusDto - .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.FAILED.toString()); - registrationStatusDto - .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.PRINT_SERVICE.toString()); - - } - else { - String vid = getVid(uin); - CredentialRequestDto credentialRequestDto = getCredentialRequestDto(vid); - requestWrapper.setId(env.getProperty("mosip.registration.processor.credential.request.service.id")); - DateTimeFormatter format = DateTimeFormatter.ofPattern(env.getProperty(DATETIME_PATTERN)); - LocalDateTime localdatetime = LocalDateTime - .parse(DateUtils.getUTCCurrentDateTimeString(env.getProperty(DATETIME_PATTERN)), format); - requestWrapper.setRequesttime(localdatetime); - requestWrapper.setVersion("1.0"); - requestWrapper.setRequest(credentialRequestDto); - responseWrapper = (ResponseWrapper) restClientService.postApi(ApiName.CREDENTIALREQUEST, null, - null, - requestWrapper, ResponseWrapper.class, MediaType.APPLICATION_JSON); - if (responseWrapper.getErrors() != null && !responseWrapper.getErrors().isEmpty()) { - ErrorDTO error = responseWrapper.getErrors().get(0); - object.setIsValid(Boolean.FALSE); - isTransactionSuccessful = false; - description.setMessage(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getMessage()); - description.setCode(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getCode()); - - registrationStatusDto.setStatusComment( - StatusUtil.PRINT_REQUEST_FAILED.getMessage() + SEPERATOR + error.getMessage()); - registrationStatusDto.setSubStatusCode(StatusUtil.PRINT_REQUEST_FAILED.getCode()); - registrationStatusDto - .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.REPROCESS.toString()); - registrationStatusDto - .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.PRINT_SERVICE.toString()); - } else { - credentialResponseDto = mapper.readValue(mapper.writeValueAsString(responseWrapper.getResponse()), - CredentialResponseDto.class); - - registrationStatusDto.setRefId(credentialResponseDto.getRequestId()); - object.setIsValid(Boolean.TRUE); - isTransactionSuccessful = true; - description.setMessage(PlatformSuccessMessages.RPR_PRINT_STAGE_REQUEST_SUCCESS.getMessage()); - description.setCode(PlatformSuccessMessages.RPR_PRINT_STAGE_REQUEST_SUCCESS.getCode()); - registrationStatusDto.setStatusComment( - trimeExpMessage.trimExceptionMessage(StatusUtil.PRINT_REQUEST_SUCCESS.getMessage())); - registrationStatusDto.setSubStatusCode(StatusUtil.PRINT_REQUEST_SUCCESS.getCode()); - registrationStatusDto - .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.PROCESSED.toString()); - registrationStatusDto - .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.PRINT_SERVICE.toString()); - - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), regId, "PrintStage::process()::exit"); - } - } - } catch (ApisResourceAccessException e) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - regId, PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.name() + e.getMessage() - + ExceptionUtils.getStackTrace(e)); - registrationStatusDto - .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.REPROCESS.toString()); - registrationStatusDto.setStatusComment(trimeExpMessage.trimExceptionMessage( - StatusUtil.API_RESOUCE_ACCESS_FAILED.getMessage() + SEPERATOR + e.getMessage())); - registrationStatusDto.setSubStatusCode(StatusUtil.API_RESOUCE_ACCESS_FAILED.getCode()); - description.setMessage(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getMessage()); - description.setCode(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getCode()); - object.setInternalError(Boolean.TRUE); - } catch (IOException e) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - regId, PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.name() + e.getMessage() - + ExceptionUtils.getStackTrace(e)); - registrationStatusDto - .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.REPROCESS.toString()); - registrationStatusDto.setStatusComment( - trimeExpMessage.trimExceptionMessage(StatusUtil.IO_EXCEPTION.getMessage() + e.getMessage())); - registrationStatusDto.setSubStatusCode(StatusUtil.IO_EXCEPTION.getCode()); - description.setMessage(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getMessage()); - description.setCode(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getCode()); - object.setInternalError(Boolean.TRUE); - } catch (VidNotAvailableException e) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - regId, PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.name() + e.getMessage() - + ExceptionUtils.getStackTrace(e)); - registrationStatusDto - .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.REPROCESS.toString()); - registrationStatusDto.setStatusComment( - trimeExpMessage.trimExceptionMessage(StatusUtil.VID_NOT_AVAILABLE.getMessage())); - registrationStatusDto.setSubStatusCode(StatusUtil.VID_NOT_AVAILABLE.getCode()); - description.setMessage(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getMessage()); - description.setCode(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getCode()); - object.setInternalError(Boolean.TRUE); - } catch (Exception e) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - regId, PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.name() + e.getMessage() - + ExceptionUtils.getStackTrace(e)); - registrationStatusDto - .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.REPROCESS.toString()); - registrationStatusDto.setStatusComment( - trimeExpMessage.trimExceptionMessage(StatusUtil.UNKNOWN_EXCEPTION_OCCURED.getMessage())); - registrationStatusDto.setSubStatusCode(StatusUtil.UNKNOWN_EXCEPTION_OCCURED.getCode()); - description.setMessage(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getMessage()); - description.setCode(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getCode()); - object.setInternalError(Boolean.TRUE); - } - finally { - if (object.getInternalError()) { - updateErrorFlags(registrationStatusDto, object); - } - String eventId = ""; - String eventName = ""; - String eventType = ""; - eventId = isTransactionSuccessful ? EventId.RPR_402.toString() : EventId.RPR_405.toString(); - eventName = eventId.equalsIgnoreCase(EventId.RPR_402.toString()) ? EventName.UPDATE.toString() - : EventName.EXCEPTION.toString(); - eventType = eventId.equalsIgnoreCase(EventId.RPR_402.toString()) ? EventType.BUSINESS.toString() - : EventType.SYSTEM.toString(); - /** Module-Id can be Both Success/Error code */ - String moduleId = isTransactionSuccessful - ? PlatformSuccessMessages.RPR_PRINT_STAGE_REQUEST_SUCCESS.getCode() - : description.getCode(); - String moduleName = ModuleName.PRINT_STAGE.toString(); - registrationStatusService.updateRegistrationStatus(registrationStatusDto, moduleId, moduleName); - - auditLogRequestBuilder.createAuditRequestBuilder(description.getMessage(), eventId, eventName, eventType, - moduleId, moduleName, regId); - - } - - return object; - } - - private CredentialRequestDto getCredentialRequestDto(String vid) { - CredentialRequestDto credentialRequestDto = new CredentialRequestDto(); - - credentialRequestDto.setCredentialType(env.getProperty("mosip.registration.processor.credentialtype")); - - credentialRequestDto.setEncrypt(encrypt); - - credentialRequestDto.setId(vid); - - credentialRequestDto.setIssuer(env.getProperty("mosip.registration.processor.issuer")); - - credentialRequestDto.setEncryptionKey(generatePin()); - - return credentialRequestDto; - } - - - /* - * (non-Javadoc) - * - * @see io.vertx.core.AbstractVerticle#start() - */ - @Override - public void start() { - router.setRoute(this.postUrl(getVertx(), - MessageBusAddress.PRINTING_BUS_IN, MessageBusAddress.PRINTING_BUS_OUT)); - this.createServer(router.getRouter(), getPort()); - } - - public String generatePin() { - if (sr == null) - instantiate(); - int randomInteger = sr.nextInt(max - min) + min; - return String.valueOf(randomInteger); - } - - @SuppressWarnings("unchecked") - private String getVid(String uin) throws ApisResourceAccessException, VidNotAvailableException { - List pathsegments = new ArrayList<>(); - pathsegments.add(uin); - String vid = null; - - VidsInfosDTO vidsInfosDTO; - - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", - "PrintServiceImpl::getVid():: get GETVIDSBYUIN service call started with request data : " - ); - - vidsInfosDTO = (VidsInfosDTO) restClientService.getApi(ApiName.GETVIDSBYUIN, - pathsegments, "", "", VidsInfosDTO.class); - - if (vidsInfosDTO.getErrors() != null && !vidsInfosDTO.getErrors().isEmpty()) { - ServiceError error = vidsInfosDTO.getErrors().get(0); - throw new VidNotAvailableException(PlatformErrorMessages.RPR_PRT_VID_NOT_AVAILABLE_EXCEPTION.getCode(), - error.getMessage()); - - } else { - if(vidsInfosDTO.getResponse()!=null && !vidsInfosDTO.getResponse().isEmpty()) { - for (VidInfoDTO VidInfoDTO : vidsInfosDTO.getResponse()) { - if (VidType.PERPETUAL.name().equalsIgnoreCase(VidInfoDTO.getVidType())) { - vid = VidInfoDTO.getVid(); - break; - } - } - if (vid == null) { - throw new VidNotAvailableException( - PlatformErrorMessages.RPR_PRT_VID_NOT_AVAILABLE_EXCEPTION.getCode(), - PlatformErrorMessages.RPR_PRT_VID_NOT_AVAILABLE_EXCEPTION.getMessage()); - } - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), "", - "PrintServiceImpl::getVid():: get GETVIDSBYUIN service call ended successfully"); - - }else { - throw new VidNotAvailableException(PlatformErrorMessages.RPR_PRT_VID_NOT_AVAILABLE_EXCEPTION.getCode(), - PlatformErrorMessages.RPR_PRT_VID_NOT_AVAILABLE_EXCEPTION.getMessage()); - } - - } - - return vid; - } - - private void updateErrorFlags(InternalRegistrationStatusDto registrationStatusDto, MessageDTO object) { - object.setInternalError(true); - if (registrationStatusDto.getLatestTransactionStatusCode() - .equalsIgnoreCase(RegistrationTransactionStatusCode.REPROCESS.toString())) { - object.setIsValid(true); - } else { - object.setIsValid(false); - } - } - - @Scheduled(fixedDelayString = "${mosip.regproc.printstage.pingeneration.refresh.millisecs:1800000}", - initialDelayString = "${mosip.regproc.printstage.pingeneration.refresh.delay-on-startup.millisecs:5000}") - private void instantiate() { - regProcLogger.debug("Instantiating SecureRandom for credential pin generation............"); - try { - sr = SecureRandom.getInstance("SHA1PRNG"); - } catch (NoSuchAlgorithmException e) { - regProcLogger.error("Could not instantiate SecureRandom for credential pin generation", e); - } - } +package io.mosip.registration.processor.credentialrequestor.stage; + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.mosip.kernel.core.exception.BaseUncheckedException; +import io.mosip.kernel.core.exception.ServiceError; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.registration.processor.core.abstractverticle.*; +import io.mosip.registration.processor.core.code.EventId; +import io.mosip.registration.processor.core.code.EventName; +import io.mosip.registration.processor.core.code.EventType; +import io.mosip.registration.processor.core.code.*; +import io.mosip.registration.processor.core.common.rest.dto.ErrorDTO; +import io.mosip.registration.processor.core.constant.*; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.exception.util.PlatformSuccessMessages; +import io.mosip.registration.processor.core.http.RequestWrapper; +import io.mosip.registration.processor.core.http.ResponseWrapper; +import io.mosip.registration.processor.core.idrepo.dto.CredentialRequestDto; +import io.mosip.registration.processor.core.idrepo.dto.CredentialResponseDto; +import io.mosip.registration.processor.core.idrepo.dto.VidInfoDTO; +import io.mosip.registration.processor.core.idrepo.dto.VidsInfosDTO; +import io.mosip.registration.processor.core.logger.LogDescription; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; +import io.mosip.registration.processor.core.status.util.StatusUtil; +import io.mosip.registration.processor.core.status.util.TrimExceptionMessage; +import io.mosip.registration.processor.core.util.JsonUtil; +import io.mosip.registration.processor.credentialrequestor.dto.CredentialPartner; +import io.mosip.registration.processor.credentialrequestor.stage.exception.VidNotAvailableException; +import io.mosip.registration.processor.credentialrequestor.util.CredentialPartnerUtil; +import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; +import io.mosip.registration.processor.status.code.RegistrationStatusCode; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.service.RegistrationStatusService; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.json.JSONArray; +import org.json.simple.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; +import org.springframework.http.MediaType; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; + +/** + * The Class PrintStage. + * + * @author M1048358 Alok + * @author Ranjitha Siddegowda + * @author Sowmya + */ +@RefreshScope +@Service +@Configuration +@EnableScheduling +@ComponentScan(basePackages = { "${mosip.auth.adapter.impl.basepackage}", + "io.mosip.registration.processor.core.config", + "io.mosip.registration.processor.stages.config", + "io.mosip.registration.processor.credentialrequestor.config", + "io.mosip.registrationprocessor.stages.config", + "io.mosip.registration.processor.status.config", + "io.mosip.registration.processor.rest.client.config", + "io.mosip.registration.processor.packet.storage.config", + "io.mosip.registration.processor.packet.manager.config", + "io.mosip.kernel.idobjectvalidator.config", + "io.mosip.registration.processor.core.kernel.beans" }) +public class CredentialRequestorStage extends MosipVerticleAPIManager { + + private static final String STAGE_PROPERTY_PREFIX = "mosip.regproc.credentialrequestor."; + private Random sr = null; + private static final int max = 999999; + private static final int min = 100000; + + /** The reg proc logger. */ + private static Logger regProcLogger = RegProcessorLogger.getLogger(CredentialRequestorStage.class); + + /** The cluster manager url. */ + @Value("${vertx.cluster.configuration}") + private String clusterManagerUrl; + + + /** The core audit request builder. */ + @Autowired + private AuditLogRequestBuilder auditLogRequestBuilder; + + /** The mosip event bus. */ + private MosipEventBus mosipEventBus; + + /** The registration status service. */ + @Autowired + RegistrationStatusService registrationStatusService; + + /** worker pool size. */ + @Value("${worker.pool.size}") + private Integer workerPoolSize; + + /** After this time intervel, message should be considered as expired (In seconds). */ + @Value("${mosip.regproc.credentialrequestor.message.expiry-time-limit}") + private Long messageExpiryTimeLimit; + + @Value("${mosip.registration.processor.encrypt:false}") + private boolean encrypt; + + /** Mosip router for APIs */ + @Autowired + MosipRouter router; + + private static final String SEPERATOR = "::"; + + @Autowired + private RegistrationProcessorRestClientService restClientService; + + @Autowired + private ObjectMapper mapper; + + @Autowired + private Environment env; + + private static final String DATETIME_PATTERN = "mosip.registration.processor.datetime.pattern"; + + private static final String ISSUERS = "mosip.registration.processor.issuer"; + + @Value("#{T(java.util.Arrays).asList('${mosip.registration.processor.credential.default.partner-ids:}')}") + private List defaultPartners; + + private static String COMMA = ","; + private static String HASH_DELIMITER = "#"; + + @Autowired + private Utilities utilities; + + @Autowired + private CredentialPartnerUtil credentialPartnerUtil; + + @Override + protected String getPropertyPrefix() { + return STAGE_PROPERTY_PREFIX; + } + + /** + * Deploy verticle. + */ + public void deployVerticle() { + mosipEventBus = this.getEventBus(this, clusterManagerUrl, workerPoolSize); + this.consumeAndSend(mosipEventBus, MessageBusAddress.PRINTING_BUS_IN, MessageBusAddress.PRINTING_BUS_OUT, + messageExpiryTimeLimit); + } + + /* + * (non-Javadoc) + * + * @see + * io.mosip.registration.processor.core.spi.eventbus.EventBusManager#process( + * java.lang.Object) + */ + @Override + public MessageDTO process(MessageDTO object) { + TrimExceptionMessage trimeExpMessage = new TrimExceptionMessage(); + object.setMessageBusAddress(MessageBusAddress.PRINTING_BUS_IN); + object.setInternalError(Boolean.FALSE); + object.setIsValid(Boolean.FALSE); + LogDescription description = new LogDescription(); + + boolean isTransactionSuccessful = false; + String uin = null; + String refIds = null; + String regId = object.getRid(); + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + regId, "PrintStage::process()::entry"); + + InternalRegistrationStatusDto registrationStatusDto = null; + RequestWrapper requestWrapper = new RequestWrapper<>(); + ResponseWrapper responseWrapper = null; + CredentialResponseDto credentialResponseDto; + try { + registrationStatusDto = registrationStatusService.getRegistrationStatus( + regId, object.getReg_type(), object.getIteration(), object.getWorkflowInstanceId()); + registrationStatusDto + .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.PRINT_SERVICE.toString()); + registrationStatusDto.setRegistrationStageName(getStageName()); + JSONObject jsonObject = utilities.retrieveUIN(regId); + uin = JsonUtil.getJSONValue(jsonObject, IdType.UIN.toString()); + if (uin == null) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), null, + PlatformErrorMessages.RPR_PRT_UIN_NOT_FOUND_IN_DATABASE.name()); + object.setIsValid(Boolean.FALSE); + isTransactionSuccessful = false; + description.setMessage(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getMessage()); + description.setCode(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getCode()); + + registrationStatusDto.setStatusComment( + StatusUtil.UIN_NOT_FOUND_IN_DATABASE.getMessage()); + registrationStatusDto.setSubStatusCode(StatusUtil.UIN_NOT_FOUND_IN_DATABASE.getCode()); + registrationStatusDto + .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.FAILED.toString()); + registrationStatusDto + .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.PRINT_SERVICE.toString()); + + } else { + requestWrapper.setId(env.getProperty("mosip.registration.processor.credential.request.service.id")); + DateTimeFormatter format = DateTimeFormatter.ofPattern(env.getProperty(DATETIME_PATTERN)); + requestWrapper.setVersion("1.0"); + List allIssuerList = credentialPartnerUtil.getAllCredentialPartners().getPartners(); + // filtering with default partner ids and process + List filteredPartners = allIssuerList.stream() + .filter(issuer -> defaultPartners.contains(issuer.getId())) + .filter(issuer -> (issuer.getProcess() == null) || (issuer.getProcess().contains(object.getReg_type()))) + .collect(Collectors.toList()); + filteredPartners.addAll(credentialPartnerUtil.getCredentialPartners( + regId, registrationStatusDto.getRegistrationType(), jsonObject)); + for (CredentialPartner key : filteredPartners) { + CredentialRequestDto credentialRequestDto = getCredentialRequestDto(regId, registrationStatusDto.getRegistrationType(), key); + LocalDateTime localdatetime = LocalDateTime.parse( + DateUtils.getUTCCurrentDateTimeString(env.getProperty(DATETIME_PATTERN)), format); + requestWrapper.setRequesttime(localdatetime); + requestWrapper.setRequest(credentialRequestDto); + // issuers with appIdBasedCredentialIdSuffix is calling v1 api and for others stage is calling v2 api for credential + if (StringUtils.isNotEmpty(key.getAppIdBasedCredentialIdSuffix())) { + List pathsegments = new ArrayList<>(); + pathsegments.add(regId + key.getAppIdBasedCredentialIdSuffix()); // #PDF suffix is added to identify the requested credential via rid + responseWrapper = (ResponseWrapper) restClientService.postApi(ApiName.CREDENTIALREQUESTV2, MediaType.APPLICATION_JSON, pathsegments, null, + null, requestWrapper, ResponseWrapper.class); + } else { + responseWrapper = (ResponseWrapper) restClientService.postApi(ApiName.CREDENTIALREQUEST, null, null, + requestWrapper, ResponseWrapper.class, MediaType.APPLICATION_JSON); + } + if (responseWrapper.getErrors() != null && !responseWrapper.getErrors().isEmpty()) { + ErrorDTO error = responseWrapper.getErrors().get(0); + object.setIsValid(Boolean.FALSE); + isTransactionSuccessful = false; + registrationStatusDto.setRefId(refIds); + description.setMessage(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getMessage()); + description.setCode(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getCode()); + + registrationStatusDto.setStatusComment( + StatusUtil.PRINT_REQUEST_FAILED.getMessage() + SEPERATOR + error.getMessage()); + registrationStatusDto.setSubStatusCode(StatusUtil.PRINT_REQUEST_FAILED.getCode()); + registrationStatusDto + .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.REPROCESS.toString()); + registrationStatusDto + .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.PRINT_SERVICE.toString()); + break; + } else { + credentialResponseDto = mapper.readValue(mapper.writeValueAsString(responseWrapper.getResponse()), + CredentialResponseDto.class); + refIds = credentialResponseDto.getRequestId(); + isTransactionSuccessful = true; + } + } + if (isTransactionSuccessful) { + registrationStatusDto.setRefId(refIds); + object.setIsValid(Boolean.TRUE); + description.setMessage(PlatformSuccessMessages.RPR_PRINT_STAGE_REQUEST_SUCCESS.getMessage()); + description.setCode(PlatformSuccessMessages.RPR_PRINT_STAGE_REQUEST_SUCCESS.getCode()); + registrationStatusDto.setStatusComment( + trimeExpMessage.trimExceptionMessage(StatusUtil.PRINT_REQUEST_SUCCESS.getMessage())); + registrationStatusDto.setSubStatusCode(StatusUtil.PRINT_REQUEST_SUCCESS.getCode()); + registrationStatusDto + .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.PROCESSED.toString()); + registrationStatusDto + .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.PRINT_SERVICE.toString()); + + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), regId, "PrintStage::process()::exit"); + } + } + } catch (ApisResourceAccessException e) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + regId, PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.name() + e.getMessage() + + ExceptionUtils.getStackTrace(e)); + registrationStatusDto + .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.REPROCESS.toString()); + registrationStatusDto.setStatusComment(trimeExpMessage.trimExceptionMessage( + StatusUtil.API_RESOUCE_ACCESS_FAILED.getMessage() + SEPERATOR + e.getMessage())); + registrationStatusDto.setSubStatusCode(StatusUtil.API_RESOUCE_ACCESS_FAILED.getCode()); + description.setMessage(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getMessage()); + description.setCode(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getCode()); + object.setInternalError(Boolean.TRUE); + } catch (IOException e) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + regId, PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.name() + e.getMessage() + + ExceptionUtils.getStackTrace(e)); + registrationStatusDto + .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.REPROCESS.toString()); + registrationStatusDto.setStatusComment( + trimeExpMessage.trimExceptionMessage(StatusUtil.IO_EXCEPTION.getMessage() + e.getMessage())); + registrationStatusDto.setSubStatusCode(StatusUtil.IO_EXCEPTION.getCode()); + description.setMessage(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getMessage()); + description.setCode(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getCode()); + object.setInternalError(Boolean.TRUE); + } catch (Exception e) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + regId, PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.name() + e.getMessage() + + ExceptionUtils.getStackTrace(e)); + registrationStatusDto + .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.REPROCESS.toString()); + registrationStatusDto.setStatusComment( + trimeExpMessage.trimExceptionMessage(StatusUtil.UNKNOWN_EXCEPTION_OCCURED.getMessage())); + registrationStatusDto.setSubStatusCode(StatusUtil.UNKNOWN_EXCEPTION_OCCURED.getCode()); + description.setMessage(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getMessage()); + description.setCode(PlatformErrorMessages.RPR_PRT_PRINT_REQUEST_FAILED.getCode()); + object.setInternalError(Boolean.TRUE); + } + finally { + if (object.getInternalError()) { + updateErrorFlags(registrationStatusDto, object); + } + String eventId = ""; + String eventName = ""; + String eventType = ""; + eventId = isTransactionSuccessful ? EventId.RPR_402.toString() : EventId.RPR_405.toString(); + eventName = eventId.equalsIgnoreCase(EventId.RPR_402.toString()) ? EventName.UPDATE.toString() + : EventName.EXCEPTION.toString(); + eventType = eventId.equalsIgnoreCase(EventId.RPR_402.toString()) ? EventType.BUSINESS.toString() + : EventType.SYSTEM.toString(); + /** Module-Id can be Both Success/Error code */ + String moduleId = isTransactionSuccessful + ? PlatformSuccessMessages.RPR_PRINT_STAGE_REQUEST_SUCCESS.getCode() + : description.getCode(); + String moduleName = ModuleName.PRINT_STAGE.toString(); + registrationStatusService.updateRegistrationStatus(registrationStatusDto, moduleId, moduleName); + + auditLogRequestBuilder.createAuditRequestBuilder(description.getMessage(), eventId, eventName, eventType, + moduleId, moduleName, regId); + + } + + return object; + } + + private CredentialRequestDto getCredentialRequestDto(String regId, String process, CredentialPartner key) { + CredentialRequestDto credentialRequestDto = new CredentialRequestDto(); + Map additionalAttributes=new HashMap<>(); + + credentialRequestDto.setCredentialType(key.getCredentialType()); + credentialRequestDto.setEncrypt(encrypt); + + credentialRequestDto.setId(regId); + + credentialRequestDto.setIssuer(key.getPartnerId()); + + credentialRequestDto.setEncryptionKey(generatePin()); + additionalAttributes.put("templateTypeCode", key.getTemplate()); + additionalAttributes.put("registrationId", regId); + if (CollectionUtils.isNotEmpty(key.getMetaInfoFields())) + getAdditionalCredentialFields(regId, process, key.getMetaInfoFields(), additionalAttributes); + credentialRequestDto.setAdditionalData(additionalAttributes); + + return credentialRequestDto; + } + + private void getAdditionalCredentialFields(String regId, String process, + List metaInfoFields, + Map additionalAttributes) { + try { + Map metaInfo = utilities.getPacketManagerService().getMetaInfo(regId, process, ProviderStageName.CREDENTIAL_REQUESTOR); + JSONArray metadata = new JSONArray(metaInfo.get(JsonConstant.METADATA)); + for(int i=0; i pathsegments = new ArrayList<>(); + pathsegments.add(uin); + String vid = null; + + VidsInfosDTO vidsInfosDTO; + + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", + "PrintServiceImpl::getVid():: get GETVIDSBYUIN service call started with request data : " + ); + + vidsInfosDTO = (VidsInfosDTO) restClientService.getApi(ApiName.GETVIDSBYUIN, + pathsegments, "", "", VidsInfosDTO.class); + + if (vidsInfosDTO.getErrors() != null && !vidsInfosDTO.getErrors().isEmpty()) { + ServiceError error = vidsInfosDTO.getErrors().get(0); + throw new VidNotAvailableException(PlatformErrorMessages.RPR_PRT_VID_NOT_AVAILABLE_EXCEPTION.getCode(), + error.getMessage()); + + } else { + if(vidsInfosDTO.getResponse()!=null && !vidsInfosDTO.getResponse().isEmpty()) { + for (VidInfoDTO VidInfoDTO : vidsInfosDTO.getResponse()) { + if (VidType.PERPETUAL.name().equalsIgnoreCase(VidInfoDTO.getVidType())) { + vid = VidInfoDTO.getVid(); + break; + } + } + if (vid == null) { + throw new VidNotAvailableException( + PlatformErrorMessages.RPR_PRT_VID_NOT_AVAILABLE_EXCEPTION.getCode(), + PlatformErrorMessages.RPR_PRT_VID_NOT_AVAILABLE_EXCEPTION.getMessage()); + } + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), "", + "PrintServiceImpl::getVid():: get GETVIDSBYUIN service call ended successfully"); + + }else { + throw new VidNotAvailableException(PlatformErrorMessages.RPR_PRT_VID_NOT_AVAILABLE_EXCEPTION.getCode(), + PlatformErrorMessages.RPR_PRT_VID_NOT_AVAILABLE_EXCEPTION.getMessage()); + } + + } + + return vid; + } + + private void updateErrorFlags(InternalRegistrationStatusDto registrationStatusDto, MessageDTO object) { + object.setInternalError(true); + if (registrationStatusDto.getLatestTransactionStatusCode() + .equalsIgnoreCase(RegistrationTransactionStatusCode.REPROCESS.toString())) { + object.setIsValid(true); + } else { + object.setIsValid(false); + } + } + + @Scheduled(fixedDelayString = "${mosip.regproc.printstage.pingeneration.refresh.millisecs:1800000}", + initialDelayString = "${mosip.regproc.printstage.pingeneration.refresh.delay-on-startup.millisecs:5000}") + private void instantiate() { + regProcLogger.debug("Instantiating SecureRandom for credential pin generation............"); + try { + sr = SecureRandom.getInstance("SHA1PRNG"); + } catch (NoSuchAlgorithmException e) { + regProcLogger.error("Could not instantiate SecureRandom for credential pin generation", e); + } + } } \ No newline at end of file diff --git a/registration-processor/post-processor/registration-processor-printing-stage/src/main/java/io/mosip/registration/processor/print/stage/exception/VidNotAvailableException.java b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/stage/exception/VidNotAvailableException.java similarity index 85% rename from registration-processor/post-processor/registration-processor-printing-stage/src/main/java/io/mosip/registration/processor/print/stage/exception/VidNotAvailableException.java rename to registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/stage/exception/VidNotAvailableException.java index 394a0e79e46..334fcc34b86 100644 --- a/registration-processor/post-processor/registration-processor-printing-stage/src/main/java/io/mosip/registration/processor/print/stage/exception/VidNotAvailableException.java +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/stage/exception/VidNotAvailableException.java @@ -1,27 +1,27 @@ -package io.mosip.registration.processor.print.stage.exception; - -import io.mosip.kernel.core.exception.BaseCheckedException; - -public class VidNotAvailableException extends BaseCheckedException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public VidNotAvailableException() { - super(); - } - - /** - * Instantiates a new reg proc checked exception. - * - * @param errorCode - * the error code - * @param errorMessage - * the error message - */ - public VidNotAvailableException(String errorCode, String errorMessage) { - super(errorCode, errorMessage); - } -} +package io.mosip.registration.processor.credentialrequestor.stage.exception; + +import io.mosip.kernel.core.exception.BaseCheckedException; + +public class VidNotAvailableException extends BaseCheckedException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public VidNotAvailableException() { + super(); + } + + /** + * Instantiates a new reg proc checked exception. + * + * @param errorCode + * the error code + * @param errorMessage + * the error message + */ + public VidNotAvailableException(String errorCode, String errorMessage) { + super(errorCode, errorMessage); + } +} diff --git a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/util/CredentialPartnerUtil.java b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/util/CredentialPartnerUtil.java new file mode 100644 index 00000000000..b357a6076e0 --- /dev/null +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/util/CredentialPartnerUtil.java @@ -0,0 +1,225 @@ +package io.mosip.registration.processor.credentialrequestor.util; + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.mosip.kernel.core.exception.BaseCheckedException; +import io.mosip.kernel.core.exception.ExceptionUtils; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.exception.JsonProcessingException; +import io.mosip.registration.processor.core.constant.JsonConstant; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.constant.MappingJsonConstants; +import io.mosip.registration.processor.core.constant.ProviderStageName; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.PacketManagerException; +import io.mosip.registration.processor.core.exception.RegistrationProcessorCheckedException; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.packet.dto.FieldValue; +import io.mosip.registration.processor.core.util.JsonUtil; +import io.mosip.registration.processor.credentialrequestor.dto.CredentialPartner; +import io.mosip.registration.processor.credentialrequestor.dto.CredentialPartnersList; +import io.mosip.registration.processor.packet.storage.exception.ParsingException; +import io.mosip.registration.processor.packet.storage.utils.IdSchemaUtil; +import io.mosip.registration.processor.packet.storage.utils.Utilities; +import org.apache.commons.collections.MapUtils; +import org.assertj.core.util.Lists; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.simple.JSONObject; +import org.mvel2.MVEL; +import org.mvel2.ParserContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +import javax.annotation.PostConstruct; +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; + +@Component +public class CredentialPartnerUtil { + + private static final Logger regProcLogger = RegProcessorLogger.getLogger(CredentialPartnerUtil.class); + private static final String VALUE_LABEL = "value"; + private static final String LANGUAGE = "language"; + + private CredentialPartnersList credentialPartners; + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + private Environment env; + + @Autowired + private Utilities utilities; + + @Autowired + IdSchemaUtil idSchemaUtil; + + @Value("${mosip.registration.processor.credential.partner-profiles}") + private String partnerProfileFileName; + + @Value("#{T(java.util.Arrays).asList('${mosip.mandatory-languages:}')}") + private List mandatoryLanguages; + + @Value("${mosip.registration.processor.credential.conditional.no-match-partner-ids}") + private String noMatchIssuer; + + @Value("#{${mosip.registration.processor.credential.conditional.partner-id-map:{}}}") + private Map credentialPartnerExpression; + + @Value("${config.server.file.storage.uri}") + private String configServerFileStorageURL; + + /** + * This map will hold the actual field names after resolving, using mapping JSON as keys and + * configured field names as values + */ + private Map requiredIDObjectFieldNamesMap; + /** + * Configured Id object fields + */ + private List requiredIdObjectFieldNames; + + @PostConstruct + private void getIdObjectFieldNames() throws BaseCheckedException { + regProcLogger.info( "CredentialPartnerUtil::getIdObjectFieldNames()::PostConstruct"); + try { + org.json.simple.JSONObject identityMappingJson = + utilities.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY); + requiredIDObjectFieldNamesMap = new HashMap<>(); + for(Map.Entry expressionEntry : credentialPartnerExpression.entrySet()) { + ParserContext parserContext = ParserContext.create(); + MVEL.analysisCompile(expressionEntry.getValue(), parserContext); + Map expressionVariablesMap = parserContext.getInputs(); + for(Map.Entry variableEntry: expressionVariablesMap.entrySet()) { + String actualFieldName = JsonUtil.getJSONValue( + JsonUtil.getJSONObject(identityMappingJson, variableEntry.getKey()), + VALUE_LABEL); + if(actualFieldName == null) + throw new BaseCheckedException( + PlatformErrorMessages.RPR_PCM_FIELD_NAME_NOT_AVAILABLE_IN_MAPPING_JSON.getCode(), + PlatformErrorMessages.RPR_PCM_FIELD_NAME_NOT_AVAILABLE_IN_MAPPING_JSON.getMessage()); + requiredIDObjectFieldNamesMap.put(actualFieldName, variableEntry.getKey()); + } + } + requiredIdObjectFieldNames = requiredIDObjectFieldNamesMap.keySet().stream().collect(Collectors.toList()); + } catch (IOException e) { + throw new BaseCheckedException( + PlatformErrorMessages.RPR_PCM_ACCESSING_IDOBJECT_MAPPING_FILE_FAILED.getCode(), + PlatformErrorMessages.RPR_PCM_ACCESSING_IDOBJECT_MAPPING_FILE_FAILED.getMessage(), e); + } + } + + public List getCredentialPartners(String regId, String registrationType, JSONObject identity) throws PacketManagerException, JSONException, ApisResourceAccessException, IOException, JsonProcessingException { + + regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + regId, "CredentialPartnerUtil::getCredentialPartners()::entry"); + + List filteredPartners = new ArrayList<>(); + if (credentialPartnerExpression == null || credentialPartnerExpression.isEmpty()) { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), regId, + PlatformErrorMessages.RPR_PRT_ISSUER_NOT_FOUND_IN_PROPERTY.name()); + return Lists.emptyList(); + } + + Map identityFieldValueMap = utilities.getPacketManagerService().getFields(regId, + requiredIdObjectFieldNames, registrationType, ProviderStageName.CREDENTIAL_REQUESTOR); + + Map context = new HashMap<>(); + for (Map.Entry identityAttribute: identityFieldValueMap.entrySet()) { + JSONObject attributeObject = new JSONObject(identityFieldValueMap); + try { + if (identityAttribute.getKey() != null && identityAttribute.getValue() != null) { + Object obj = attributeObject.get(identityAttribute.getKey()); + if (obj instanceof org.json.simple.JSONArray) { + org.json.simple.JSONArray attributeArray = (org.json.simple.JSONArray) obj; + for (int i = 0; i < attributeArray.size(); i++) { + JSONObject jsonObject = (JSONObject) attributeArray.get(i); + if (mandatoryLanguages.get(0).equalsIgnoreCase((String) jsonObject.get(LANGUAGE))) { + context.put(identityAttribute.getKey(), jsonObject.get(VALUE_LABEL)); + } + } + } else { + if (obj != null) { + context.put(identityAttribute.getKey(), obj.toString()); + } + } + } else + context.put(identityAttribute.getKey(), identityAttribute.getValue()); + } catch (Exception e) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", + ExceptionUtils.getStackTrace(e)); + throw new ParsingException(PlatformErrorMessages.RPR_PRT_DATA_VALIDATION_FAILED.getCode(), e); + } + } + + // adding additional metadata so that it can be used for MVEL expression + Map metaInfo = utilities.getPacketManagerService().getMetaInfo(regId, registrationType, ProviderStageName.CREDENTIAL_REQUESTOR); + if (MapUtils.isNotEmpty(metaInfo)) { + String metadata = metaInfo.get(JsonConstant.METADATA); + if (!StringUtils.isEmpty(metadata)) { + JSONArray jsonArray = new JSONArray(metadata); + addToMap(jsonArray, context); + } + } + + regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + regId, "CredentialPartnerUtil::CredentialPartnerExpression::" + credentialPartnerExpression.toString()); + + for(Map.Entry entry : credentialPartnerExpression.entrySet()) { + Boolean result = (Boolean) MVEL.eval(entry.getValue(), context); + if (result) { + filteredPartners.add(entry.getKey()); + } + } + if (StringUtils.hasText(noMatchIssuer) && filteredPartners.isEmpty()) { + filteredPartners.add(noMatchIssuer); + } + regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + regId, "CredentialPartnerUtil::FilteredPartners::" + filteredPartners.toString()); + + List finalList = new ArrayList<>(); + if (!filteredPartners.isEmpty()) { + filteredPartners.forEach( + p -> { + Optional partner = credentialPartners.getPartners() + .stream().filter(pr -> pr.getId().equalsIgnoreCase(p)).findAny(); + if (partner.isPresent()) + finalList.add(partner.get()); + }); + } + return finalList; + } + + private void addToMap(JSONArray jsonArray, Map allMap) throws JSONException, IOException { + for (int i =0; i < jsonArray.length(); i++) { + org.json.JSONObject jsonObject = (org.json.JSONObject) jsonArray.get(i); + FieldValue fieldValue = objectMapper.readValue(jsonObject.toString(), FieldValue.class); + allMap.put(fieldValue.getLabel(), fieldValue.getValue()); + } + } + + @PostConstruct + public void loadPartnerDetails() throws RegistrationProcessorCheckedException { + try { + String partners = Utilities.getJson(configServerFileStorageURL, partnerProfileFileName); + credentialPartners = JsonUtil.readValueWithUnknownProperties(partners, CredentialPartnersList.class); + } catch (Exception e) { + regProcLogger.error("Error loading credential Partners", e); + throw new RegistrationProcessorCheckedException(PlatformErrorMessages.RPR_SYS_IO_EXCEPTION.getCode(), + PlatformErrorMessages.RPR_SYS_IO_EXCEPTION.getMessage(), e); + } + } + + public CredentialPartnersList getAllCredentialPartners() throws RegistrationProcessorCheckedException { + if (credentialPartners == null) + loadPartnerDetails(); + return credentialPartners; + } +} diff --git a/registration-processor/post-processor/registration-processor-printing-stage/src/main/resources/bootstrap.properties b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/resources/bootstrap.properties similarity index 50% rename from registration-processor/post-processor/registration-processor-printing-stage/src/main/resources/bootstrap.properties rename to registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/resources/bootstrap.properties index 64b25477db4..e812af75ff3 100644 --- a/registration-processor/post-processor/registration-processor-printing-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/resources/bootstrap.properties @@ -1,25 +1,33 @@ -spring.cloud.config.uri=localhost -spring.cloud.config.label=master -spring.application.name=application,registration-processor -spring.profiles.active=dev -spring.cloud.config.name=application,registration-processor -registration.processor.identityjson=RegistrationProcessorIdentity.json -registration.processor.demographic.identity=identity -packet.info.storage.service=registration-processor-packet-info-storage-service -config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ -management.endpoints.web.exposure.include=refresh -registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml -#management.security.enabled=false -server.port=8099 -server.servlet.path=/registrationprocessor/v1/print-stage - -#disabling health check so that client doesnt try to load properties from sprint config server every -# 5 minutes (should not be done in production) -health.config.enabled=false -eventbus.port=5722 -#Kafka event bus configruations -mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.printing.eventbus.kafka.commit.type} -mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.printing.eventbus.kafka.max.poll.records} -mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.printing.eventbus.kafka.poll.frequency} -mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.printing.eventbus.kafka.group.id} \ No newline at end of file +spring.cloud.config.uri=localhost +spring.cloud.config.label=master +spring.application.name=application,registration-processor +spring.profiles.active=dev +spring.cloud.config.name=application,registration-processor +registration.processor.identityjson=RegistrationProcessorIdentity.json +registration.processor.demographic.identity=identity +packet.info.storage.service=registration-processor-packet-info-storage-service +config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ +management.endpoints.web.exposure.include=refresh +registration.processor.zone=secure +vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +#management.security.enabled=false +server.port=8099 +server.servlet.path=/registrationprocessor/v1/credential-requestor + +#disabling health check so that client doesnt try to load properties from sprint config server every +# 5 minutes (should not be done in production) +health.config.enabled=false +eventbus.port=5722 +#Kafka event bus configruations +mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.credentialrequestor.eventbus.kafka.commit.type} +mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.credentialrequestor.eventbus.kafka.max.poll.records} +mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.credentialrequestor.eventbus.kafka.poll.frequency} +mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.credentialrequestor.eventbus.kafka.group.id} +mosip.registration.processor.digitalcard.credentialtype=PDFCard +mosip.registration.processor.print.credentialtype=euin +mosip.registration.processor.digitalcard.template=RPR_UIN_CARD_TEMPLATE +mosip.registration.processor.print.template=RPR_UIN_CARD_TEMPLATE +# this property is used to define issuers eg partnerid:credentialType:templateTypeCode +mosip.registration.processor.default.internal.issuers=mpartner-default-digitalcard#PDFCard#RPR_UIN_CARD_TEMPLATE + +mosip.registration.processor.default.issuers=mpartner-default-print#euin#RPR_UIN_CARD_TEMPLATE \ No newline at end of file diff --git a/registration-processor/post-processor/registration-processor-printing-stage/src/main/resources/logback.xml b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/resources/logback.xml similarity index 100% rename from registration-processor/post-processor/registration-processor-printing-stage/src/main/resources/logback.xml rename to registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/resources/logback.xml diff --git a/registration-processor/post-processor/registration-processor-printing-stage/src/test/java/io/mosip/registrationprocessor/print/stage/test/PrintingStageTest.java b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/test/java/io/mosip/registrationprocessor/credentialrequestor/test/CredentialRequestorStageTest.java similarity index 87% rename from registration-processor/post-processor/registration-processor-printing-stage/src/test/java/io/mosip/registrationprocessor/print/stage/test/PrintingStageTest.java rename to registration-processor/post-processor/registration-processor-credential-requestor-stage/src/test/java/io/mosip/registrationprocessor/credentialrequestor/test/CredentialRequestorStageTest.java index dc4c470177a..1177e4e19c7 100644 --- a/registration-processor/post-processor/registration-processor-printing-stage/src/test/java/io/mosip/registrationprocessor/print/stage/test/PrintingStageTest.java +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/test/java/io/mosip/registrationprocessor/credentialrequestor/test/CredentialRequestorStageTest.java @@ -1,442 +1,471 @@ -package io.mosip.registrationprocessor.print.stage.test; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.json.simple.JSONObject; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.springframework.context.annotation.PropertySource; -import org.springframework.core.env.Environment; -import org.springframework.http.MediaType; -import org.springframework.test.util.ReflectionTestUtils; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.kernel.core.exception.ServiceError; -import io.mosip.registration.processor.core.abstractverticle.EventDTO; -import io.mosip.registration.processor.core.abstractverticle.HealthCheckDTO; -import io.mosip.registration.processor.core.abstractverticle.MessageBusAddress; -import io.mosip.registration.processor.core.abstractverticle.MessageDTO; -import io.mosip.registration.processor.core.abstractverticle.MosipEventBus; -import io.mosip.registration.processor.core.abstractverticle.MosipRouter; -import io.mosip.registration.processor.core.code.ApiName; -import io.mosip.registration.processor.core.common.rest.dto.ErrorDTO; -import io.mosip.registration.processor.core.constant.EventId; -import io.mosip.registration.processor.core.constant.EventName; -import io.mosip.registration.processor.core.constant.EventType; -import io.mosip.registration.processor.core.constant.RegistrationType; -import io.mosip.registration.processor.core.constant.VidType; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.http.ResponseWrapper; -import io.mosip.registration.processor.core.idrepo.dto.CredentialResponseDto; -import io.mosip.registration.processor.core.idrepo.dto.VidInfoDTO; -import io.mosip.registration.processor.core.idrepo.dto.VidsInfosDTO; -import io.mosip.registration.processor.core.packet.dto.Identity; -import io.mosip.registration.processor.core.spi.eventbus.EventHandler; -import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; -import io.mosip.registration.processor.core.util.PropertiesUtil; -import io.mosip.registration.processor.packet.storage.utils.Utilities; -import io.mosip.registration.processor.print.stage.PrintingStage; -import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; -import io.mosip.registration.processor.rest.client.audit.dto.AuditResponseDto; -import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.service.RegistrationStatusService; -import io.vertx.core.AsyncResult; -import io.vertx.core.Handler; -import io.vertx.core.Vertx; -import io.vertx.ext.web.Router; -import io.vertx.ext.web.RoutingContext; - -@SuppressWarnings("deprecation") -@RunWith(PowerMockRunner.class) -@PrepareForTest({}) -@PowerMockIgnore({ "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*","javax.management.*", "javax.net.*" }) -@PropertySource("classpath:bootstrap.properties") -public class PrintingStageTest { - - @Mock - private AuditLogRequestBuilder auditLogRequestBuilder; - - @Mock - MosipRouter router; - - @Mock - protected PropertiesUtil propertiesUtil; - - @Mock - private ObjectMapper objectMapper; - - private InternalRegistrationStatusDto registrationStatusDto = new InternalRegistrationStatusDto(); - - @Mock - private RegistrationStatusService registrationStatusService; - /** The rest template. */ - @Mock - private RegistrationProcessorRestClientService restClientService; - - - - /** The identity. */ - Identity identity = new Identity(); - - @Mock - private Environment env; - - private String response; - - @Mock - private Utilities utitilites; - - @InjectMocks - private PrintingStage stage = new PrintingStage() { - @Override - public MosipEventBus getEventBus(Object verticleName, String url, int instanceNumber) { - vertx = Vertx.vertx(); - - return new MosipEventBus() { - - @Override - public Vertx getEventbus() { - return vertx; - } - - @Override - public void consume(MessageBusAddress fromAddress, - EventHandler>> eventHandler) { - - } - - @Override - public void consumeAndSend(MessageBusAddress fromAddress, MessageBusAddress toAddress, - EventHandler>> eventHandler) { - - } - - @Override - public void send(MessageBusAddress toAddress, MessageDTO message) { - - } - - @Override - public void consumerHealthCheck(Handler eventHandler, String address) { - // TODO Auto-generated method stub - - } - - @Override - public void senderHealthCheck(Handler eventHandler, String address) { - // TODO Auto-generated method stub - - } - }; - } - - @Override - public void consume(MosipEventBus mosipEventBus, MessageBusAddress fromAddress, - long messageExpiryTimeLimit) { - } - - - @Override - public void send(MosipEventBus mosipEventBus, MessageBusAddress toAddress, MessageDTO message) { - } - - @Override - public void createServer(Router router, int port) { - - } - - @Override - public Router postUrl(Vertx vertx, MessageBusAddress consumeAddress, MessageBusAddress sendAddress) { - return null; - } - - @Override - public void setResponseWithDigitalSignature(RoutingContext ctx, Object object, String contentType) { - - } - }; - - @Before - public void setup() throws Exception { - when(env.getProperty("mosip.registration.processor.datetime.pattern")) - .thenReturn("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - when(env.getProperty("mosip.regproc.printing.server.port")).thenReturn("8099"); - - ReflectionTestUtils.setField(stage, "workerPoolSize", 10); - ReflectionTestUtils.setField(stage, "messageExpiryTimeLimit", Long.valueOf(0)); - ReflectionTestUtils.setField(stage, "clusterManagerUrl", "/dummyPath"); - ReflectionTestUtils.setField(stage, "busOutHaltAddresses", Arrays.asList()); - System.setProperty("server.port", "8099"); - - //ReflectionTestUtils.setField(stage, "port", "8080"); - ReflectionTestUtils.setField(stage, "encrypt", false); - Mockito.when(registrationStatusService.getRegistrationStatus(any(String.class), any(), any(), any())).thenReturn(registrationStatusDto); - Mockito.when(propertiesUtil.getIntegerProperty(any(), any())).thenReturn(8080); - - - - //Mockito.doNothing().when(registrationStatusDto).setStatusCode(any()); - //Mockito.doNothing().when(registrationStatusDto).setStatusComment(any()); - Mockito.doNothing().when(registrationStatusService).updateRegistrationStatus(any(), any(), any()); - //Mockito.doNothing().when(registrationStatusDto).setLatestTransactionTypeCode(any()); - //Mockito.doNothing().when(registrationStatusDto).setRegistrationStageName(any()); - //Mockito.doNothing().when(registrationStatusDto).setLatestTransactionStatusCode(any()); - Mockito.when(router.post(any())).thenReturn(null); - Mockito.when(router.get(any())).thenReturn(null); - - - Field auditLog = AuditLogRequestBuilder.class.getDeclaredField("registrationProcessorRestService"); - auditLog.setAccessible(true); - @SuppressWarnings("unchecked") - RegistrationProcessorRestClientService mockObj = Mockito - .mock(RegistrationProcessorRestClientService.class); - auditLog.set(auditLogRequestBuilder, mockObj); - AuditResponseDto auditResponseDto = new AuditResponseDto(); - ResponseWrapper responseWrapper = new ResponseWrapper<>(); - responseWrapper.setResponse(auditResponseDto); - Mockito.doReturn(responseWrapper).when(auditLogRequestBuilder).createAuditRequestBuilder( - "test case description", EventId.RPR_401.toString(), EventName.ADD.toString(), - EventType.BUSINESS.toString(), "1234testcase", ApiName.AUDIT); - Mockito.when(objectMapper.writeValueAsString(any())).thenReturn(response); - VidsInfosDTO vidsInfosDTO = new VidsInfosDTO(); - List vidList = new ArrayList<>(); - VidInfoDTO vidInfoDTO = new VidInfoDTO(); - vidInfoDTO.setVid("4796042638691271"); - vidInfoDTO.setVidType(VidType.PERPETUAL.name()); - vidList.add(vidInfoDTO); - vidsInfosDTO.setResponse(vidList); - Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(vidsInfosDTO); - Map map1 = new HashMap<>(); - map1.put("UIN", "4238135072"); - JSONObject jsonObject = new JSONObject(map1); - Mockito.when(utitilites.retrieveUIN(any())).thenReturn(jsonObject); - - - - } - - @Test - public void testAll() throws Exception { - testDeployVerticle(); - testStart(); - testPrintStageSuccess(); - testPrintStageFailure(); - } - - public void testStart() { - stage.start(); - } - - public void testDeployVerticle() throws Exception { - - - stage.deployVerticle(); - } - - - - - @Test - public void testPrintStageSuccess() - throws ApisResourceAccessException, JsonParseException, JsonMappingException, IOException { - MessageDTO dto = new MessageDTO(); - dto.setRid("1234567890987654321"); - - dto.setReg_type(RegistrationType.NEW.name()); - - ResponseWrapper responseWrapper = new ResponseWrapper<>(); - CredentialResponseDto credentialResponseDto = new CredentialResponseDto(); - credentialResponseDto.setRequestId("879664323421"); - Mockito.when(objectMapper.readValue(response, CredentialResponseDto.class)) - .thenReturn(credentialResponseDto); - responseWrapper.setResponse(credentialResponseDto); - Mockito.when(restClientService.postApi(any(), any(), any(), any(), any(), any(MediaType.class))) - .thenReturn(responseWrapper); - - MessageDTO result = stage.process(dto); - assertTrue(result.getIsValid()); - assertFalse(result.getInternalError()); - } - - - @Test - public void testPrintStageFailure() throws ApisResourceAccessException { - - MessageDTO dto = new MessageDTO(); - dto.setRid("1234567890987654321"); - - dto.setReg_type(RegistrationType.NEW.name()); - - ResponseWrapper responseWrapper = new ResponseWrapper<>(); - ErrorDTO error = new ErrorDTO(); - error.setErrorCode("IDR-CRG-004"); - error.setMessage("unknown exception"); - List errors = new ArrayList<>(); - errors.add(error); - responseWrapper.setErrors(errors); - - Mockito.when(restClientService.postApi(any(), any(), any(), any(), any(), any(MediaType.class))) - .thenReturn(responseWrapper); - - MessageDTO result = stage.process(dto); - assertFalse(result.getIsValid()); - assertFalse(result.getInternalError()); - } - - - @Test - public void testException() - throws JsonParseException, JsonMappingException, IOException, ApisResourceAccessException { - MessageDTO dto = new MessageDTO(); - dto.setRid("1234567890987654321"); - - dto.setReg_type(RegistrationType.NEW.name()); - - ResponseWrapper responseWrapper = new ResponseWrapper<>(); - CredentialResponseDto credentialResponseDto = new CredentialResponseDto(); - credentialResponseDto.setRequestId("879664323421"); - Mockito.when(objectMapper.readValue(response, CredentialResponseDto.class)).thenReturn(credentialResponseDto); - responseWrapper.setResponse(credentialResponseDto); - Mockito.when(restClientService.postApi(any(), any(), any(), any(), any(), any(MediaType.class))) - .thenReturn(null); - MessageDTO result = stage.process(dto); - assertTrue(result.getInternalError()); - assertTrue(result.getIsValid()); - } - - @Test - public void testApisResourceAccessException() - throws JsonParseException, JsonMappingException, IOException, ApisResourceAccessException { - MessageDTO dto = new MessageDTO(); - dto.setRid("1234567890987654321"); - - dto.setReg_type(RegistrationType.NEW.name()); - - ResponseWrapper responseWrapper = new ResponseWrapper<>(); - CredentialResponseDto credentialResponseDto = new CredentialResponseDto(); - credentialResponseDto.setRequestId("879664323421"); - Mockito.when(objectMapper.readValue(response, CredentialResponseDto.class)).thenReturn(credentialResponseDto); - responseWrapper.setResponse(credentialResponseDto); - Mockito.when(restClientService.postApi(any(), any(), any(), any(), any(), any(MediaType.class))) - .thenThrow(new ApisResourceAccessException()); - MessageDTO result = stage.process(dto); - assertTrue(result.getInternalError()); - assertTrue(result.getIsValid()); - } - - @Test - public void testUINNotavailable() - throws JsonParseException, JsonMappingException, IOException, ApisResourceAccessException { - MessageDTO dto = new MessageDTO(); - dto.setRid("1234567890987654321"); - - dto.setReg_type(RegistrationType.NEW.name()); - - ResponseWrapper responseWrapper = new ResponseWrapper<>(); - CredentialResponseDto credentialResponseDto = new CredentialResponseDto(); - credentialResponseDto.setRequestId("879664323421"); - Mockito.when(objectMapper.readValue(response, CredentialResponseDto.class)).thenReturn(credentialResponseDto); - responseWrapper.setResponse(credentialResponseDto); - Mockito.when(restClientService.postApi(any(), any(), any(), any(), any(), any(MediaType.class))) - .thenThrow(new ApisResourceAccessException()); - Map map1 = new HashMap<>(); - - JSONObject jsonObject = new JSONObject(map1); - Mockito.when(utitilites.retrieveUIN(any())).thenReturn(jsonObject); - MessageDTO result = stage.process(dto); - - assertFalse(result.getIsValid()); - assertFalse(result.getInternalError()); - } - - @Test - public void testVidNotAvailableException() - throws JsonParseException, JsonMappingException, IOException, ApisResourceAccessException { - MessageDTO dto = new MessageDTO(); - dto.setRid("1234567890987654321"); - - dto.setReg_type(RegistrationType.NEW.name()); - - ResponseWrapper responseWrapper = new ResponseWrapper<>(); - CredentialResponseDto credentialResponseDto = new CredentialResponseDto(); - credentialResponseDto.setRequestId("879664323421"); - Mockito.when(objectMapper.readValue(response, CredentialResponseDto.class)).thenReturn(credentialResponseDto); - responseWrapper.setResponse(credentialResponseDto); - Mockito.when(restClientService.postApi(any(), any(), any(), any(), any(), any(MediaType.class))) - .thenThrow(new ApisResourceAccessException()); - VidsInfosDTO vidsInfosDTO = new VidsInfosDTO(); - List vidList = new ArrayList<>(); - VidInfoDTO vidInfoDTO = new VidInfoDTO(); - vidInfoDTO.setVid("4796042638691271"); - vidInfoDTO.setVidType(VidType.TEMPORARY.name()); - vidList.add(vidInfoDTO); - vidsInfosDTO.setResponse(vidList); - Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(vidsInfosDTO); - MessageDTO result = stage.process(dto); - - assertTrue(result.getInternalError()); - assertTrue(result.getIsValid()); - } - - @Test - public void testVidNotAvailableGETAPIResponseNullException() - throws ApisResourceAccessException, JsonParseException, JsonMappingException, IOException { - MessageDTO dto = new MessageDTO(); - dto.setRid("1234567890987654321"); - - dto.setReg_type(RegistrationType.NEW.name()); - - VidsInfosDTO vidsInfosDTO = new VidsInfosDTO(); - vidsInfosDTO.setResponse(null); - Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(vidsInfosDTO); - - MessageDTO result = stage.process(dto); - assertTrue(result.getIsValid()); - assertTrue(result.getInternalError()); - } - - @Test - public void testVidNotAvailableGETAPIException() - throws ApisResourceAccessException, JsonParseException, JsonMappingException, IOException { - MessageDTO dto = new MessageDTO(); - dto.setRid("1234567890987654321"); - - dto.setReg_type(RegistrationType.NEW.name()); - - VidsInfosDTO vidsInfosDTO = new VidsInfosDTO(); - vidsInfosDTO.setResponse(null); - ServiceError error = new ServiceError(); - error.setErrorCode("ERR-001"); - error.setMessage("exception occured"); - vidsInfosDTO.setErrors(Arrays.asList(error)); - Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(vidsInfosDTO); - - MessageDTO result = stage.process(dto); - assertTrue(result.getIsValid()); - assertTrue(result.getInternalError()); - } - +package io.mosip.registrationprocessor.credentialrequestor.test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import io.mosip.registration.processor.credentialrequestor.dto.CredentialPartner; +import io.mosip.registration.processor.credentialrequestor.dto.CredentialPartnersList; +import io.mosip.registration.processor.credentialrequestor.util.CredentialPartnerUtil; +import org.assertj.core.util.Lists; +import org.json.simple.JSONObject; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.http.MediaType; +import org.springframework.test.util.ReflectionTestUtils; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.kernel.core.exception.ServiceError; +import io.mosip.registration.processor.core.abstractverticle.EventDTO; +import io.mosip.registration.processor.core.abstractverticle.HealthCheckDTO; +import io.mosip.registration.processor.core.abstractverticle.MessageBusAddress; +import io.mosip.registration.processor.core.abstractverticle.MessageDTO; +import io.mosip.registration.processor.core.abstractverticle.MosipEventBus; +import io.mosip.registration.processor.core.abstractverticle.MosipRouter; +import io.mosip.registration.processor.core.code.ApiName; +import io.mosip.registration.processor.core.common.rest.dto.ErrorDTO; +import io.mosip.registration.processor.core.constant.EventId; +import io.mosip.registration.processor.core.constant.EventName; +import io.mosip.registration.processor.core.constant.EventType; +import io.mosip.registration.processor.core.constant.RegistrationType; +import io.mosip.registration.processor.core.constant.VidType; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.http.ResponseWrapper; +import io.mosip.registration.processor.core.idrepo.dto.CredentialResponseDto; +import io.mosip.registration.processor.core.idrepo.dto.VidInfoDTO; +import io.mosip.registration.processor.core.idrepo.dto.VidsInfosDTO; +import io.mosip.registration.processor.core.packet.dto.Identity; +import io.mosip.registration.processor.core.spi.eventbus.EventHandler; +import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; +import io.mosip.registration.processor.core.util.PropertiesUtil; +import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.credentialrequestor.stage.CredentialRequestorStage; +import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; +import io.mosip.registration.processor.rest.client.audit.dto.AuditResponseDto; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.service.RegistrationStatusService; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.Vertx; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; + +@SuppressWarnings("deprecation") +@RunWith(PowerMockRunner.class) +@PrepareForTest({}) +@PowerMockIgnore({ "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*","javax.management.*", "javax.net.*" }) +@PropertySource("classpath:bootstrap.properties") +public class CredentialRequestorStageTest { + + @Mock + private AuditLogRequestBuilder auditLogRequestBuilder; + + @Mock + MosipRouter router; + + @Mock + protected PropertiesUtil propertiesUtil; + + @Mock + private CredentialPartnerUtil credentialPartnerUtil; + + @Mock + private ObjectMapper objectMapper; + + private InternalRegistrationStatusDto registrationStatusDto = new InternalRegistrationStatusDto(); + + @Mock + private RegistrationStatusService registrationStatusService; + /** The rest template. */ + @Mock + private RegistrationProcessorRestClientService restClientService; + + + + /** The identity. */ + Identity identity = new Identity(); + + @Mock + private Environment env; + + private String response; + + @Mock + private Utilities utitilites; + + @InjectMocks + private CredentialRequestorStage stage = new CredentialRequestorStage() { + @Override + public MosipEventBus getEventBus(Object verticleName, String url, int instanceNumber) { + vertx = Vertx.vertx(); + + return new MosipEventBus() { + + @Override + public Vertx getEventbus() { + return vertx; + } + + @Override + public void consume(MessageBusAddress fromAddress, + EventHandler>> eventHandler) { + + } + + @Override + public void consumeAndSend(MessageBusAddress fromAddress, MessageBusAddress toAddress, + EventHandler>> eventHandler) { + + } + + @Override + public void send(MessageBusAddress toAddress, MessageDTO message) { + + } + + @Override + public void consumerHealthCheck(Handler eventHandler, String address) { + // TODO Auto-generated method stub + + } + + @Override + public void senderHealthCheck(Handler eventHandler, String address) { + // TODO Auto-generated method stub + + } + }; + } + + @Override + public void consume(MosipEventBus mosipEventBus, MessageBusAddress fromAddress, + long messageExpiryTimeLimit) { + } + + + @Override + public void send(MosipEventBus mosipEventBus, MessageBusAddress toAddress, MessageDTO message) { + } + + @Override + public void createServer(Router router, int port) { + + } + + @Override + public Router postUrl(Vertx vertx, MessageBusAddress consumeAddress, MessageBusAddress sendAddress) { + return null; + } + + @Override + public void setResponseWithDigitalSignature(RoutingContext ctx, Object object, String contentType) { + + } + }; + + @Before + public void setup() throws Exception { + when(env.getProperty("mosip.registration.processor.datetime.pattern")) + .thenReturn("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + when(env.getProperty("mosip.regproc.credentialrequestor.server.port")).thenReturn("8099"); + when(env.getProperty("mosip.registration.processor.issuer")) + .thenReturn("mpartner-default-digitalcard:PDFCard:RPR_UIN_CARD_TEMPLATE;mpartner-default-print:euin:RPR_UIN_CARD_TEMPLATE"); + ReflectionTestUtils.setField(stage, "workerPoolSize", 10); + ReflectionTestUtils.setField(stage, "messageExpiryTimeLimit", Long.valueOf(0)); + ReflectionTestUtils.setField(stage, "clusterManagerUrl", "/dummyPath"); + ReflectionTestUtils.setField(stage, "busOutHaltAddresses", Arrays.asList()); + ReflectionTestUtils.setField(stage, "defaultPartners", Arrays.asList("digitalcardPartner", "opencrvsPartner")); + + System.setProperty("server.port", "8099"); + + //ReflectionTestUtils.setField(stage, "port", "8080"); + ReflectionTestUtils.setField(stage, "encrypt", false); + registrationStatusDto.setRegistrationId("45451454520011220230523070548"); + registrationStatusDto.setRegistrationType("NEW"); + registrationStatusDto.setWorkflowInstanceId("33e1fb7f-8202-41dc-82a1-49e821364eb2"); + Mockito.when(registrationStatusService.getRegistrationStatus(any(String.class), any(), any(), any())).thenReturn(registrationStatusDto); + Mockito.when(propertiesUtil.getIntegerProperty(any(), any())).thenReturn(8080); + + + + //Mockito.doNothing().when(registrationStatusDto).setStatusCode(any()); + //Mockito.doNothing().when(registrationStatusDto).setStatusComment(any()); + Mockito.doNothing().when(registrationStatusService).updateRegistrationStatus(any(), any(), any()); + //Mockito.doNothing().when(registrationStatusDto).setLatestTransactionTypeCode(any()); + //Mockito.doNothing().when(registrationStatusDto).setRegistrationStageName(any()); + //Mockito.doNothing().when(registrationStatusDto).setLatestTransactionStatusCode(any()); + Mockito.when(router.post(any())).thenReturn(null); + Mockito.when(router.get(any())).thenReturn(null); + + + Field auditLog = AuditLogRequestBuilder.class.getDeclaredField("registrationProcessorRestService"); + auditLog.setAccessible(true); + @SuppressWarnings("unchecked") + RegistrationProcessorRestClientService mockObj = Mockito + .mock(RegistrationProcessorRestClientService.class); + auditLog.set(auditLogRequestBuilder, mockObj); + AuditResponseDto auditResponseDto = new AuditResponseDto(); + ResponseWrapper responseWrapper = new ResponseWrapper<>(); + responseWrapper.setResponse(auditResponseDto); + Mockito.doReturn(responseWrapper).when(auditLogRequestBuilder).createAuditRequestBuilder( + "test case description", EventId.RPR_401.toString(), EventName.ADD.toString(), + EventType.BUSINESS.toString(), "1234testcase", ApiName.AUDIT); + Mockito.when(objectMapper.writeValueAsString(any())).thenReturn(response); + VidsInfosDTO vidsInfosDTO = new VidsInfosDTO(); + List vidList = new ArrayList<>(); + VidInfoDTO vidInfoDTO = new VidInfoDTO(); + vidInfoDTO.setVid("4796042638691271"); + vidInfoDTO.setVidType(VidType.PERPETUAL.name()); + vidList.add(vidInfoDTO); + vidsInfosDTO.setResponse(vidList); + Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(vidsInfosDTO); + Map map1 = new HashMap<>(); + map1.put("UIN", "4238135072"); + JSONObject jsonObject = new JSONObject(map1); + Mockito.when(utitilites.retrieveUIN(any())).thenReturn(jsonObject); + + CredentialPartner partner1 = new CredentialPartner(); + partner1.setId("digitalcardPartner"); + partner1.setPartnerId("mpartner-default-digitalcard"); + partner1.setCredentialType("PDFCard"); + partner1.setTemplate("RPR_UIN_CARD_TEMPLATE"); + partner1.setAppIdBasedCredentialIdSuffix(".pdf"); + + CredentialPartner partner2 = new CredentialPartner(); + partner2.setId("opencrvsPartner"); + partner2.setPartnerId("opencrvs-partner"); + partner2.setCredentialType("opencrvs"); + partner2.setTemplate("RPR_UIN_CARD_TEMPLATE"); + + CredentialPartnersList partnersList = new CredentialPartnersList(); + partnersList.setPartners(Lists.newArrayList(partner1, partner2)); + when(credentialPartnerUtil.getAllCredentialPartners()).thenReturn(partnersList); + + + + } + + @Test + public void testAll() throws Exception { + testDeployVerticle(); + testStart(); + testPrintStageSuccess(); + } + + public void testStart() { + stage.start(); + } + + public void testDeployVerticle() throws Exception { + + + stage.deployVerticle(); + } + + + + + @Test + public void testPrintStageSuccess() + throws ApisResourceAccessException, JsonParseException, JsonMappingException, IOException { + MessageDTO dto = new MessageDTO(); + dto.setRid("1234567890987654321"); + + dto.setReg_type(RegistrationType.NEW.name()); + + ResponseWrapper responseWrapper = new ResponseWrapper<>(); + CredentialResponseDto credentialResponseDto = new CredentialResponseDto(); + credentialResponseDto.setRequestId("879664323421"); + Mockito.when(objectMapper.readValue(response, CredentialResponseDto.class)) + .thenReturn(credentialResponseDto); + responseWrapper.setResponse(credentialResponseDto); + Mockito.when(restClientService.postApi(any(), any(), any(), any(), any(), any(MediaType.class))) + .thenReturn(responseWrapper); + Mockito.when(restClientService.postApi((ApiName) any(), any(MediaType.class),any(),any(), any(), any(), any())) + .thenReturn(responseWrapper); + MessageDTO result = stage.process(dto); + assertTrue(result.getIsValid()); + assertFalse(result.getInternalError()); + } + + + @Test + public void testPrintStageFailure() throws ApisResourceAccessException { + + MessageDTO dto = new MessageDTO(); + dto.setRid("1234567890987654321"); + + dto.setReg_type(RegistrationType.NEW.name()); + + ResponseWrapper responseWrapper = new ResponseWrapper<>(); + ErrorDTO error = new ErrorDTO(); + error.setErrorCode("IDR-CRG-004"); + error.setMessage("unknown exception"); + List errors = new ArrayList<>(); + errors.add(error); + responseWrapper.setErrors(errors); + + Mockito.when(restClientService.postApi(any(ApiName.class), any(), any(), any(), any(), any(MediaType.class))) + .thenReturn(responseWrapper); + + MessageDTO result = stage.process(dto); + assertTrue(result.getInternalError()); + } + + + @Test + public void testException() + throws JsonParseException, JsonMappingException, IOException, ApisResourceAccessException { + MessageDTO dto = new MessageDTO(); + dto.setRid("1234567890987654321"); + + dto.setReg_type(RegistrationType.NEW.name()); + + ResponseWrapper responseWrapper = new ResponseWrapper<>(); + CredentialResponseDto credentialResponseDto = new CredentialResponseDto(); + credentialResponseDto.setRequestId("879664323421"); + Mockito.when(objectMapper.readValue(response, CredentialResponseDto.class)).thenReturn(credentialResponseDto); + responseWrapper.setResponse(credentialResponseDto); + Mockito.when(restClientService.postApi(any(), any(), any(), any(), any(), any(MediaType.class))) + .thenReturn(null); + MessageDTO result = stage.process(dto); + assertTrue(result.getInternalError()); + assertTrue(result.getIsValid()); + } + + @Test + public void testApisResourceAccessException() + throws JsonParseException, JsonMappingException, IOException, ApisResourceAccessException { + MessageDTO dto = new MessageDTO(); + dto.setRid("1234567890987654321"); + + dto.setReg_type(RegistrationType.NEW.name()); + + ResponseWrapper responseWrapper = new ResponseWrapper<>(); + CredentialResponseDto credentialResponseDto = new CredentialResponseDto(); + credentialResponseDto.setRequestId("879664323421"); + Mockito.when(objectMapper.readValue(response, CredentialResponseDto.class)).thenReturn(credentialResponseDto); + responseWrapper.setResponse(credentialResponseDto); + Mockito.when(restClientService.postApi(any(), any(), any(), any(), any(), any(MediaType.class))) + .thenThrow(new ApisResourceAccessException()); + MessageDTO result = stage.process(dto); + assertTrue(result.getInternalError()); + assertTrue(result.getIsValid()); + } + + @Test + public void testUINNotavailable() + throws JsonParseException, JsonMappingException, IOException, ApisResourceAccessException { + MessageDTO dto = new MessageDTO(); + dto.setRid("1234567890987654321"); + + dto.setReg_type(RegistrationType.NEW.name()); + + ResponseWrapper responseWrapper = new ResponseWrapper<>(); + CredentialResponseDto credentialResponseDto = new CredentialResponseDto(); + credentialResponseDto.setRequestId("879664323421"); + Mockito.when(objectMapper.readValue(response, CredentialResponseDto.class)).thenReturn(credentialResponseDto); + responseWrapper.setResponse(credentialResponseDto); + Mockito.when(restClientService.postApi(any(), any(), any(), any(), any(), any(MediaType.class))) + .thenThrow(new ApisResourceAccessException()); + Map map1 = new HashMap<>(); + + JSONObject jsonObject = new JSONObject(map1); + Mockito.when(utitilites.retrieveUIN(any())).thenReturn(jsonObject); + MessageDTO result = stage.process(dto); + + assertFalse(result.getIsValid()); + assertFalse(result.getInternalError()); + } + + @Test + public void testVidNotAvailableException() + throws JsonParseException, JsonMappingException, IOException, ApisResourceAccessException { + MessageDTO dto = new MessageDTO(); + dto.setRid("1234567890987654321"); + + dto.setReg_type(RegistrationType.NEW.name()); + + ResponseWrapper responseWrapper = new ResponseWrapper<>(); + CredentialResponseDto credentialResponseDto = new CredentialResponseDto(); + credentialResponseDto.setRequestId("879664323421"); + Mockito.when(objectMapper.readValue(response, CredentialResponseDto.class)).thenReturn(credentialResponseDto); + responseWrapper.setResponse(credentialResponseDto); + Mockito.when(restClientService.postApi(any(), any(), any(), any(), any(), any(MediaType.class))) + .thenThrow(new ApisResourceAccessException()); + VidsInfosDTO vidsInfosDTO = new VidsInfosDTO(); + List vidList = new ArrayList<>(); + VidInfoDTO vidInfoDTO = new VidInfoDTO(); + vidInfoDTO.setVid("4796042638691271"); + vidInfoDTO.setVidType(VidType.TEMPORARY.name()); + vidList.add(vidInfoDTO); + vidsInfosDTO.setResponse(vidList); + Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(vidsInfosDTO); + MessageDTO result = stage.process(dto); + + assertTrue(result.getInternalError()); + assertTrue(result.getIsValid()); + } + + @Test + public void testVidNotAvailableGETAPIResponseNullException() + throws ApisResourceAccessException, JsonParseException, JsonMappingException, IOException { + MessageDTO dto = new MessageDTO(); + dto.setRid("1234567890987654321"); + + dto.setReg_type(RegistrationType.NEW.name()); + + VidsInfosDTO vidsInfosDTO = new VidsInfosDTO(); + vidsInfosDTO.setResponse(null); + Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(vidsInfosDTO); + + MessageDTO result = stage.process(dto); + assertTrue(result.getIsValid()); + assertTrue(result.getInternalError()); + } + + @Test + public void testVidNotAvailableGETAPIException() + throws ApisResourceAccessException, JsonParseException, JsonMappingException, IOException { + MessageDTO dto = new MessageDTO(); + dto.setRid("1234567890987654321"); + + dto.setReg_type(RegistrationType.NEW.name()); + + VidsInfosDTO vidsInfosDTO = new VidsInfosDTO(); + vidsInfosDTO.setResponse(null); + ServiceError error = new ServiceError(); + error.setErrorCode("ERR-001"); + error.setMessage("exception occured"); + vidsInfosDTO.setErrors(Arrays.asList(error)); + Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(vidsInfosDTO); + + MessageDTO result = stage.process(dto); + assertTrue(result.getIsValid()); + assertTrue(result.getInternalError()); + } + } \ No newline at end of file diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/code/ApiName.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/code/ApiName.java index 2408b0c1a67..4a85dc07a65 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/code/ApiName.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/code/ApiName.java @@ -196,7 +196,8 @@ public enum ApiName { IDREPOCREATEDRAFT, IDREPOUPDATEDRAFT, IDREPOPUBLISHDRAFT, - IDREPOEXTRACTBIOMETRICS; + IDREPOEXTRACTBIOMETRICS, + CREDENTIALREQUESTV2; } diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/constant/ProviderStageName.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/constant/ProviderStageName.java index c8ea5efdfed..9a9e0bea9a5 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/constant/ProviderStageName.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/constant/ProviderStageName.java @@ -19,7 +19,8 @@ public enum ProviderStageName { VERIFICATION("verification"), UIN_GENERATOR("uingenerator"), WORKFLOW_MANAGER("workflowmanager"), - MESSAGE_SENDER("messagesender"); + MESSAGE_SENDER("messagesender"), + CREDENTIAL_REQUESTOR("credentialrequestor"); private String value; diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/exception/util/PlatformErrorMessages.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/exception/util/PlatformErrorMessages.java index fa6aa67cdc2..92ef5f6ebac 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/exception/util/PlatformErrorMessages.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/exception/util/PlatformErrorMessages.java @@ -1135,6 +1135,11 @@ public enum PlatformErrorMessages { RPR_PRT_VID_NOT_AVAILABLE_EXCEPTION(PlatformConstants.RPR_PRINTING_MODULE + "027", "vid not available"), + /** The rpr prt print issuer not found in property. */ + RPR_PRT_ISSUER_NOT_FOUND_IN_PROPERTY(PlatformConstants.RPR_PRINTING_MODULE + "028", "Print issuer property is not found"), + + RPR_PRT_PARSING_ADDITIONAL_CRED_CONFIG(PlatformConstants.RPR_PRINTING_MODULE + "029", "issue with metaInfoFields in credential partner profiles."), + /** The rpr rgs registration connector not accessible. */ RPR_RGS_REGISTRATION_CONNECTOR_NOT_ACCESSIBLE("", "Registration connector stage is not accessible "), diff --git a/registration-processor/stage-groups/registration-processor-stage-group-7/pom.xml b/registration-processor/stage-groups/registration-processor-stage-group-7/pom.xml index c1a8220c7a6..8d85e80b286 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-7/pom.xml +++ b/registration-processor/stage-groups/registration-processor-stage-group-7/pom.xml @@ -1,74 +1,74 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - stage-groups - 1.2.0.1-B3 - - - registration-processor-stage-group-7 - 1.2.0.1-B3 - - - UTF-8 - - - - - - - io.mosip.registrationprocessor - mosip-stage-executor - 1.2.0.1-B3 - - - - - io.mosip.registrationprocessor - registration-processor-uin-generator-stage - 1.2.0.1-B3 - - - io.mosip.registrationprocessor - registration-processor-biometric-extraction-stage - 1.2.0.1-B3 - - - io.mosip.registrationprocessor - registration-processor-finalization-stage - 1.2.0.1-B3 - - - io.mosip.registrationprocessor - registration-processor-printing-stage - 1.2.0.1-B3 - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication - ZIP - - - - - build-info - repackage - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + stage-groups + 1.2.0.1-B3 + + + registration-processor-stage-group-7 + 1.2.0.1-B3 + + + UTF-8 + + + + + + + io.mosip.registrationprocessor + mosip-stage-executor + 1.2.0.1-B3 + + + + + io.mosip.registrationprocessor + registration-processor-uin-generator-stage + 1.2.0.1-B3 + + + io.mosip.registrationprocessor + registration-processor-biometric-extraction-stage + 1.2.0.1-B3 + + + io.mosip.registrationprocessor + registration-processor-finalization-stage + 1.2.0.1-B3 + + + io.mosip.registrationprocessor + registration-processor-credential-requestor-stage + 1.2.0.1-B3 + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication + ZIP + + + + + build-info + repackage + + + + + + \ No newline at end of file From 565d9ab65209bcc30fd5222117e0365be36e6721 Mon Sep 17 00:00:00 2001 From: Vishwa Date: Wed, 3 Jan 2024 19:50:05 +0530 Subject: [PATCH 2/2] Merge pull request #1818 from MonobikashDas/develop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MOSIP-28121 : calling idrepo instead of packetmanager in credential r… Signed-off-by: Monobikash Das --- .../stage/CredentialRequestorStage.java | 3 +-- .../util/CredentialPartnerUtil.java | 11 ++++------- .../test/CredentialRequestorStageTest.java | 4 ++-- .../processor/packet/storage/utils/Utilities.java | 2 +- .../service/impl/MessageNotificationServiceImpl.java | 2 +- .../service/MessageNotificationServiceImplTest.java | 2 +- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/stage/CredentialRequestorStage.java b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/stage/CredentialRequestorStage.java index 39ee23c62ca..cdaf63b9e3c 100644 --- a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/stage/CredentialRequestorStage.java +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/stage/CredentialRequestorStage.java @@ -196,7 +196,7 @@ public MessageDTO process(MessageDTO object) { registrationStatusDto .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.PRINT_SERVICE.toString()); registrationStatusDto.setRegistrationStageName(getStageName()); - JSONObject jsonObject = utilities.retrieveUIN(regId); + JSONObject jsonObject = utilities.idrepoRetrieveIdentityByRid(regId); uin = JsonUtil.getJSONValue(jsonObject, IdType.UIN.toString()); if (uin == null) { regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), @@ -343,7 +343,6 @@ public MessageDTO process(MessageDTO object) { moduleId, moduleName, regId); } - return object; } diff --git a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/util/CredentialPartnerUtil.java b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/util/CredentialPartnerUtil.java index b357a6076e0..4495ae6e7ed 100644 --- a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/util/CredentialPartnerUtil.java +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/util/CredentialPartnerUtil.java @@ -5,10 +5,7 @@ import io.mosip.kernel.core.exception.ExceptionUtils; import io.mosip.kernel.core.logger.spi.Logger; import io.mosip.kernel.core.util.exception.JsonProcessingException; -import io.mosip.registration.processor.core.constant.JsonConstant; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.constant.MappingJsonConstants; -import io.mosip.registration.processor.core.constant.ProviderStageName; +import io.mosip.registration.processor.core.constant.*; import io.mosip.registration.processor.core.exception.ApisResourceAccessException; import io.mosip.registration.processor.core.exception.PacketManagerException; import io.mosip.registration.processor.core.exception.RegistrationProcessorCheckedException; @@ -128,11 +125,11 @@ public List getCredentialPartners(String regId, String regist return Lists.emptyList(); } - Map identityFieldValueMap = utilities.getPacketManagerService().getFields(regId, - requiredIdObjectFieldNames, registrationType, ProviderStageName.CREDENTIAL_REQUESTOR); + Map identityFieldValueMap = new HashMap<>(); + requiredIdObjectFieldNames.forEach(field -> identityFieldValueMap.put(field, JsonUtil.getJSONValue(identity, field))); Map context = new HashMap<>(); - for (Map.Entry identityAttribute: identityFieldValueMap.entrySet()) { + for (Map.Entry identityAttribute: identityFieldValueMap.entrySet()) { JSONObject attributeObject = new JSONObject(identityFieldValueMap); try { if (identityAttribute.getKey() != null && identityAttribute.getValue() != null) { diff --git a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/test/java/io/mosip/registrationprocessor/credentialrequestor/test/CredentialRequestorStageTest.java b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/test/java/io/mosip/registrationprocessor/credentialrequestor/test/CredentialRequestorStageTest.java index 1177e4e19c7..b635ab725a1 100644 --- a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/test/java/io/mosip/registrationprocessor/credentialrequestor/test/CredentialRequestorStageTest.java +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/test/java/io/mosip/registrationprocessor/credentialrequestor/test/CredentialRequestorStageTest.java @@ -245,7 +245,7 @@ public void setup() throws Exception { Map map1 = new HashMap<>(); map1.put("UIN", "4238135072"); JSONObject jsonObject = new JSONObject(map1); - Mockito.when(utitilites.retrieveUIN(any())).thenReturn(jsonObject); + Mockito.when(utitilites.idrepoRetrieveIdentityByRid(any())).thenReturn(jsonObject); CredentialPartner partner1 = new CredentialPartner(); partner1.setId("digitalcardPartner"); @@ -394,7 +394,7 @@ public void testUINNotavailable() Map map1 = new HashMap<>(); JSONObject jsonObject = new JSONObject(map1); - Mockito.when(utitilites.retrieveUIN(any())).thenReturn(jsonObject); + Mockito.when(utitilites.idrepoRetrieveIdentityByRid(any())).thenReturn(jsonObject); MessageDTO result = stage.process(dto); assertFalse(result.getIsValid()); diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utilities.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utilities.java index 99b7abac080..b4418f83811 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utilities.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utilities.java @@ -662,7 +662,7 @@ public String getLatestTransactionId(String registrationId, String process, int * @throws IOException Signals that an I/O exception has * occurred. */ - public JSONObject retrieveUIN(String regId) throws ApisResourceAccessException, IdRepoAppException, IOException { + public JSONObject idrepoRetrieveIdentityByRid(String regId) throws ApisResourceAccessException, IdRepoAppException, IOException { regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), regId, "Utilities::retrieveUIN()::entry"); diff --git a/registration-processor/registration-processor-message-sender-impl/src/main/java/io/mosip/registration/processor/message/sender/service/impl/MessageNotificationServiceImpl.java b/registration-processor/registration-processor-message-sender-impl/src/main/java/io/mosip/registration/processor/message/sender/service/impl/MessageNotificationServiceImpl.java index cd551b37bd3..36413df5774 100644 --- a/registration-processor/registration-processor-message-sender-impl/src/main/java/io/mosip/registration/processor/message/sender/service/impl/MessageNotificationServiceImpl.java +++ b/registration-processor/registration-processor-message-sender-impl/src/main/java/io/mosip/registration/processor/message/sender/service/impl/MessageNotificationServiceImpl.java @@ -449,7 +449,7 @@ private Map setAttributes(String id, String process, String lang String uin = ""; if (idType.toString().equalsIgnoreCase(UIN)) { - JSONObject jsonObject = utility.retrieveUIN(id); + JSONObject jsonObject = utility.idrepoRetrieveIdentityByRid(id); uin = JsonUtil.getJSONValue(jsonObject, UIN); attributes.put("RID", id); attributes.put("UIN", uin); diff --git a/registration-processor/registration-processor-message-sender-impl/src/test/java/io/mosip/registration/processor/message/sender/test/service/MessageNotificationServiceImplTest.java b/registration-processor/registration-processor-message-sender-impl/src/test/java/io/mosip/registration/processor/message/sender/test/service/MessageNotificationServiceImplTest.java index 4f242aa7e98..ea6d1b11d1e 100644 --- a/registration-processor/registration-processor-message-sender-impl/src/test/java/io/mosip/registration/processor/message/sender/test/service/MessageNotificationServiceImplTest.java +++ b/registration-processor/registration-processor-message-sender-impl/src/test/java/io/mosip/registration/processor/message/sender/test/service/MessageNotificationServiceImplTest.java @@ -202,7 +202,7 @@ public void setup() throws Exception { map1.put("UIN", "423072"); JSONObject jsonObject1 = new JSONObject(map1); - Mockito.when(utility.retrieveUIN(any())).thenReturn(jsonObject1); + Mockito.when(utility.idrepoRetrieveIdentityByRid(any())).thenReturn(jsonObject1); Mockito.when(utility.getGetRegProcessorDemographicIdentity()).thenReturn("identity"); InputStream in = IOUtils.toInputStream("Hi Alok, Your UIN is generated", "UTF-8");