From cef4c130c7239b8956606caaa104c615f90ff12a Mon Sep 17 00:00:00 2001 From: kameshsr <47484458+kameshsr@users.noreply.github.com> Date: Fri, 9 Aug 2024 18:28:23 +0530 Subject: [PATCH] MOSIP-32460 Merge java 21 branch to develop (#1064) * MOSIP-32363 JAVA 21 upgrade (#941) Signed-off-by: Mohanachandran S * Updated the API commons artifact ID (#947) * MOSIP-32363 JAVA 21 upgrade Signed-off-by: Mohanachandran S * Updated the API commons artifact ID Signed-off-by: Mohanachandran S --------- Signed-off-by: Mohanachandran S * MOSIP-32363 - Merged from develop branch and updated the maven plugins for JAVA21 (#977) * MOSIP-32363 JAVA 21 upgrade Signed-off-by: Mohanachandran S * Updated the API commons artifact ID Signed-off-by: Mohanachandran S * Merged from the develop branch Signed-off-by: Mohanachandran S --------- Signed-off-by: Mohanachandran S * Java21 migration changes Signed-off-by: Neha Farheen * Java21 migration changes Signed-off-by: Neha Farheen * [DSD-5366] Updated Dockerfile & Push-trigger Signed-off-by: VSIVAKALYAN * [DSD-5366] Updated Push-trigger.yml Signed-off-by: VSIVAKALYAN * MOSIP-32418 Updated the POM for the apitest commons groupId (#986) * MOSIP-32363 JAVA 21 upgrade Signed-off-by: Mohanachandran S * Updated the API commons artifact ID Signed-off-by: Mohanachandran S * Merged from the develop branch Signed-off-by: Mohanachandran S --------- Signed-off-by: Mohanachandran S * MOSIP-32460 migrated the idrepo Signed-off-by: Neha Farheen * MOSIP-32460 migrated the idrepo Signed-off-by: Neha Farheen * MOSIP-32460 id repo resolved review comment and removed pom duplicacy issue Signed-off-by: Neha Farheen * added version in core pom Signed-off-by: Neha Farheen * Removed constrait from batch job Signed-off-by: Neha Farheen * added schema constrait from batch job Signed-off-by: Neha Farheen * updated the constraint for batch job Signed-off-by: Neha Farheen * docker file changes Signed-off-by: Neha Farheen * docker file changes Signed-off-by: Neha Farheen * docker file changes Signed-off-by: Neha Farheen * [MOSIP-32460] Id-repo migrate from java 11 to java 21 (#981) * Java21 migration changes Signed-off-by: Neha Farheen * Java21 migration changes Signed-off-by: Neha Farheen * MOSIP-32460 migrated the idrepo Signed-off-by: Neha Farheen * MOSIP-32460 migrated the idrepo Signed-off-by: Neha Farheen * MOSIP-32460 id repo resolved review comment and removed pom duplicacy issue Signed-off-by: Neha Farheen * added version in core pom Signed-off-by: Neha Farheen * Removed constrait from batch job Signed-off-by: Neha Farheen * added schema constrait from batch job Signed-off-by: Neha Farheen * updated the constraint for batch job Signed-off-by: Neha Farheen * docker file changes Signed-off-by: Neha Farheen * docker file changes Signed-off-by: Neha Farheen * docker file changes Signed-off-by: Neha Farheen --------- Signed-off-by: Neha Farheen Co-authored-by: Neha Farheen * [DSD-5514] Updated Dockerfile Signed-off-by: shubham_G <88794020+shubham17998@users.noreply.github.com> * [DSD-5514] Updated Dockerfile Signed-off-by: shubham_G <88794020+shubham17998@users.noreply.github.com> * [DSD-5514] Updated Dockerfile Signed-off-by: shubham_G <88794020+shubham17998@users.noreply.github.com> * [DSD-5514] Updated Dockerfile Signed-off-by: shubham_G <88794020+shubham17998@users.noreply.github.com> * updated pom and removedjdbctype code Signed-off-by: Neha Farheen * resolved docker issue Signed-off-by: Neha Farheen * resolved byte array issue Signed-off-by: Neha Farheen * Chnages in identity count datatype Signed-off-by: Neha Farheen * Chnages in identity count datatype (#1025) Signed-off-by: Neha Farheen Co-authored-by: Neha Farheen * batch job file added Signed-off-by: Neha Farheen * batch job file added Signed-off-by: Neha Farheen * batch job file added Signed-off-by: Neha Farheen * Interceptor issue is resolved Signed-off-by: Neha Farheen * Update MosipTestRunner.java Signed-off-by: Mohanachandran S <165888272+mohanachandran-s@users.noreply.github.com> * Update Dockerfile Signed-off-by: Mohanachandran S <165888272+mohanachandran-s@users.noreply.github.com> * Removed --show progress Signed-off-by: bhumi46 <111699703+bhumi46@users.noreply.github.com> * MOSIP-35065 Fixed Invalid request time error (#1057) * MOSIP-35065 Fixed Invalid request time error Signed-off-by: kameshsr * MOSIP-35065 Deleted un-necessary files Signed-off-by: kameshsr * Corrected constant name Signed-off-by: kameshsr * Corrected constant name Signed-off-by: kameshsr * Corrected variable name Signed-off-by: kameshsr * Corrected constant name Signed-off-by: kameshsr * Corrected constant name Signed-off-by: kameshsr --------- Signed-off-by: kameshsr * MOSIP-35065 MOSIP-35093 MOSIP-35094 MOSIP-35095 Fixed interceptor issue (#1059) * MOSIP-35065 Fixed interceptor issue Signed-off-by: kameshsr * MOSIP-35095 Fixed unknown error occured in create draft api Signed-off-by: kameshsr --------- Signed-off-by: kameshsr * MOSIP-35096 Handled No resoursce found exception (#1061) * MOSIP-35065 Fixed interceptor issue Signed-off-by: kameshsr * MOSIP-35095 Fixed unknown error occured in create draft api Signed-off-by: kameshsr * MOSIP-35096 Handled No resoursce found exception Signed-off-by: kameshsr --------- Signed-off-by: kameshsr * MOSIP-35094 MOSIP-35110 MOSIP-35065 35096 Added parameter true to idrepo core and identity service (#1063) * MOSIP-35065 Fixed interceptor issue Signed-off-by: kameshsr * MOSIP-35095 Fixed unknown error occured in create draft api Signed-off-by: kameshsr * MOSIP-35096 Handled No resoursce found exception Signed-off-by: kameshsr * MOSIP-35094 Added parameter true to idrepo core and identity service Signed-off-by: kameshsr * MOSIP-35094 Returned bad request for invalid request Signed-off-by: kameshsr * MOSIP-35110 Corrected column name in uin draft table Signed-off-by: kameshsr * MOSIP-35110 Added column name Signed-off-by: kameshsr * MOSIP-35110 corrected status code Signed-off-by: kameshsr * MOSIP-35065 Added ok status code Signed-off-by: kameshsr * Removed un-necessary code Signed-off-by: kameshsr * Removed un-necessary code Signed-off-by: kameshsr --------- Signed-off-by: kameshsr * MOSIP-35065 Merge java 21 branch to develop Signed-off-by: kameshsr * Added 1201 pom of idrepo parent Signed-off-by: kameshsr * Switched back to java 11 for api test Signed-off-by: kameshsr * Changed code as per review comment Signed-off-by: kameshsr * Corrected base packages Signed-off-by: kameshsr * Fixed test case failure Signed-off-by: kameshsr * Renamed file Signed-off-by: kameshsr --------- Signed-off-by: Mohanachandran S Signed-off-by: Neha Farheen Signed-off-by: VSIVAKALYAN Signed-off-by: shubham_G <88794020+shubham17998@users.noreply.github.com> Signed-off-by: Mohanachandran S <165888272+mohanachandran-s@users.noreply.github.com> Signed-off-by: bhumi46 <111699703+bhumi46@users.noreply.github.com> Signed-off-by: kameshsr Co-authored-by: Mohanachandran S <165888272+mohanachandran-s@users.noreply.github.com> Co-authored-by: Neha Farheen Co-authored-by: VSIVAKALYAN Co-authored-by: Chandra Keshav Mishra Co-authored-by: Neha2365 <110969715+Neha2365@users.noreply.github.com> Co-authored-by: shubham_G <88794020+shubham17998@users.noreply.github.com> Co-authored-by: bhumi46 <111699703+bhumi46@users.noreply.github.com> --- .github/workflows/push-trigger.yml | 10 +- apitest/Dockerfile | 2 +- apitest/pom.xml | 744 +++++++++--------- .../ddl/credential-batch_job_execution.sql | 21 +- ...credential-batch_job_execution_context.sql | 7 +- .../credential-batch_job_execution_params.sql | 11 +- .../ddl/credential-batch_job_instance.sql | 9 +- .../ddl/credential-batch_step_execution.sql | 37 +- ...redential-batch_step_execution_context.sql | 8 +- .../ddl/credential-credential_transaction.sql | 1 - .../mosip_credential/ddl/credential-fk.sql | 12 +- .../sql/1.2.0.1_to_1.3.0_rollback.sql | 22 + .../sql/1.2.0.1_to_1.3.0_upgrade.sql | 22 + .../credential-request-generator/Dockerfile | 16 +- .../credential-request-generator/pom.xml | 82 +- ...entialRequestGeneratorBootApplication.java | 44 ++ ...entialRequestGeneratorBootApplication.java | 38 - .../CredentialRequestGeneratorConfig.java | 11 +- .../batch/config/BatchConfiguration.java | 143 +--- .../CredentialItemReprocessTasklet.java | 4 +- .../batch/config/CredentialItemTasklet.java | 5 +- .../CredentialScheduleJobConfiguration.java | 72 ++ .../JobCompletionNotificationListener.java | 5 +- .../request/generator/dao/CredentialDao.java | 2 +- .../generator/entity/CredentialEntity.java | 8 +- .../CredentialTransactionInterceptor.java | 10 +- .../repositary/CredentialRepositary.java | 10 +- .../request/generator/util/RestUtil.java | 42 +- .../src/main/resources/bootstrap.properties | 6 + .../generator/dao/CredentialDaoTest.java | 2 +- .../init/CredentialInitializerTest.java | 2 +- .../batch/config/BatchConfigurationTest.java | 29 +- .../test/config/TestSecurityConfig.java | 36 +- ...dentialRequestGeneratorControllerTest.java | 1 - .../test/init/SubscribeEventTest.java | 2 +- id-repository/credential-service/Dockerfile | 16 +- id-repository/credential-service/pom.xml | 62 +- .../api/config/CredentialStoreConfig.java | 2 +- .../config/CredentialStoreBeanConfig.java | 23 - .../credentialstore/config/MvelConfig.java | 38 + .../provider/CredentialProvider.java | 10 +- .../provider/impl/IdAuthProvider.java | 2 + .../provider/impl/QrCodeProvider.java | 4 +- .../provider/impl/VerCredProvider.java | 21 +- .../impl/CredentialStoreServiceImpl.java | 3 +- .../src/main/resources/bootstrap.properties | 1 + .../test/config/TestSecurityConfig.java | 35 +- .../test/util/UtilitiesTest.java | 3 +- id-repository/id-repository-core/pom.xml | 58 +- .../core/builder/RestRequestBuilder.java | 2 +- .../core/config/IdRepoDataSourceConfig.java | 11 +- .../core/entity/CredentialRequestStatus.java | 20 +- .../idrepository/core/entity/Handle.java | 17 +- .../core/entity/UinEncryptSalt.java | 11 +- .../idrepository/core/entity/UinHashSalt.java | 11 +- .../exception/IdRepoExceptionHandler.java | 34 +- .../idrepository/core/helper/RestHelper.java | 2 +- .../core/httpfilter/BaseIdRepoFilter.java | 16 +- .../manager/CredentialServiceManager.java | 2 +- .../partner/PartnerServiceManager.java | 2 +- .../core/security/IdRepoSecurityManager.java | 2 +- .../mosip/idrepository/core/util/EnvUtil.java | 2 +- .../core/validator/BaseIdRepoValidator.java | 2 +- .../core/test/helper/RestHelperTest.java | 23 +- .../id-repository-credentials-feeder/pom.xml | 5 +- .../test/CredentialsFeedingWriterTest.java | 15 +- .../id-repository-identity-service/Dockerfile | 38 +- .../id-repository-identity-service/pom.xml | 57 +- .../identity/IdRepoBootApplication.java | 9 +- .../identity/config/IdRepoConfig.java | 108 +-- .../config/IdentityScheduleConfig.java | 21 + .../config/IdentitySecurityConfig.java | 31 + .../identity/config/IdentityWebsubConfig.java | 23 + .../identity/config/ObjectMapperConfig.java | 24 + .../identity/config/RestTemplateConfig.java | 77 ++ .../identity/controller/IdRepoController.java | 6 +- .../entity/AnonymousProfileEntity.java | 12 +- .../identity/entity/AuthtypeLock.java | 14 +- .../identity/entity/ChannelInfo.java | 13 +- .../entity/IdentityUpdateTracker.java | 13 +- .../idrepository/identity/entity/Uin.java | 44 +- .../identity/entity/UinBiometric.java | 28 +- .../identity/entity/UinBiometricDraft.java | 26 +- .../identity/entity/UinBiometricHistory.java | 17 +- .../identity/entity/UinDocument.java | 30 +- .../identity/entity/UinDocumentDraft.java | 32 +- .../identity/entity/UinDocumentHistory.java | 19 +- .../identity/entity/UinDraft.java | 34 +- .../identity/entity/UinHistory.java | 28 +- .../helper/AnonymousProfileHelper.java | 2 +- .../identity/helper/IdRepoServiceHelper.java | 2 +- .../identity/httpfilter/IdRepoFilter.java | 2 +- .../interceptor/IdRepoEntityInterceptor.java | 22 +- .../IdentityUpdateTrackerPolicyProvider.java | 2 +- .../service/impl/IdRepoDraftServiceImpl.java | 1 - .../service/impl/IdRepoProxyServiceImpl.java | 2 +- .../service/impl/IdRepoServiceImpl.java | 2 +- .../validator/IdRequestValidator.java | 6 +- .../src/main/resources/bootstrap.properties | 6 +- ...entityUpdateTrackerPolicyProviderTest.java | 2 +- .../validator/IdRequestValidatorTest.java | 2 +- .../id-repository-salt-generator/pom.xml | 110 +-- .../id-repository-vid-service/Dockerfile | 18 +- .../id-repository-vid-service/pom.xml | 21 +- .../idrepository/vid/VidBootApplication.java | 7 +- .../vid/config/RestTemplateConfig.java | 39 + .../vid/config/VidRepoConfig.java | 32 +- .../io/mosip/idrepository/vid/entity/Vid.java | 15 +- .../vid/httpfilter/IdRepoFilter.java | 2 +- .../IdRepoVidEntityInterceptor.java | 10 +- .../vid/provider/VidPolicyProvider.java | 2 +- .../vid/service/impl/VidServiceImpl.java | 2 +- .../vid/validator/VidRequestValidator.java | 2 +- id-repository/pom.xml | 378 +++++---- 114 files changed, 1671 insertions(+), 1653 deletions(-) create mode 100644 db_upgrade_scripts/mosip_credential/sql/1.2.0.1_to_1.3.0_rollback.sql create mode 100644 db_upgrade_scripts/mosip_credential/sql/1.2.0.1_to_1.3.0_upgrade.sql create mode 100644 id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/CredentialRequestGeneratorBootApplication.java delete mode 100644 id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/api/CredentialRequestGeneratorBootApplication.java create mode 100644 id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/CredentialScheduleJobConfiguration.java create mode 100644 id-repository/credential-service/src/main/java/io/mosip/credentialstore/config/MvelConfig.java create mode 100644 id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdentityScheduleConfig.java create mode 100644 id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdentitySecurityConfig.java create mode 100644 id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdentityWebsubConfig.java create mode 100644 id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/ObjectMapperConfig.java create mode 100644 id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/RestTemplateConfig.java create mode 100644 id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/config/RestTemplateConfig.java diff --git a/.github/workflows/push-trigger.yml b/.github/workflows/push-trigger.yml index 32749fbaa..943136c3f 100644 --- a/.github/workflows/push-trigger.yml +++ b/.github/workflows/push-trigger.yml @@ -18,12 +18,12 @@ on: - release* - master - 1.* - - develop + - develop* - MOSIP* jobs: build-maven-id-repository: - uses: mosip/kattu/.github/workflows/maven-build.yml@master + uses: mosip/kattu/.github/workflows/maven-build.yml@master-java21 with: SERVICE_LOCATION: ./id-repository BUILD_ARTIFACT: id-repository @@ -37,7 +37,7 @@ jobs: publish_to_nexus: if: "${{ !contains(github.ref, 'master') && github.event_name != 'pull_request' && github.event_name != 'release' && github.event_name != 'prerelease' && github.event_name != 'publish' }}" needs: build-maven-id-repository - uses: mosip/kattu/.github/workflows/maven-publish-to-nexus.yml@master + uses: mosip/kattu/.github/workflows/maven-publish-to-nexus.yml@master-java21 with: SERVICE_LOCATION: ./id-repository secrets: @@ -73,7 +73,7 @@ jobs: BUILD_ARTIFACT: 'id-repository' fail-fast: false name: ${{ matrix.SERVICE_NAME }} - uses: mosip/kattu/.github/workflows/docker-build.yml@master + uses: mosip/kattu/.github/workflows/docker-build.yml@master-java21 with: SERVICE_LOCATION: ${{ matrix.SERVICE_LOCATION }} SERVICE_NAME: ${{ matrix.SERVICE_NAME }} @@ -87,7 +87,7 @@ jobs: sonar_analysis: needs: build-maven-id-repository if: "${{ github.event_name != 'pull_request' }}" - uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master + uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master-java21 with: SERVICE_LOCATION: ./id-repository secrets: diff --git a/apitest/Dockerfile b/apitest/Dockerfile index 2af566cab..cbeb1f59a 100644 --- a/apitest/Dockerfile +++ b/apitest/Dockerfile @@ -59,4 +59,4 @@ ENV ENV_USER= ENV ENV_ENDPOINT= ENV ENV_TESTLEVEL=smokeAndRegression -ENTRYPOINT ["./entrypoint.sh"] +ENTRYPOINT ["./entrypoint.sh"] \ No newline at end of file diff --git a/apitest/pom.xml b/apitest/pom.xml index 4496eaa3d..f07f14ce9 100644 --- a/apitest/pom.xml +++ b/apitest/pom.xml @@ -1,223 +1,223 @@ - 4.0.0 - io.mosip.idrepo - apitest-idrepo - jar - apitest-idrepo - Parent project of apitest-idrepo - https://github.com/mosip/id-repository - 1.2.1-SNAPSHOT - - - - MPL 2.0 - https://www.mozilla.org/en-US/MPL/2.0/ - - - - - scm:git:git://github.com/mosip/id-repository.git - scm:git:ssh://github.com:mosip/id-repository.git - https://github.com/mosip/id-repository - HEAD - - - - - Mosip - mosip.emailnotifier@gmail.com - io.mosip - https://github.com/mosip/id-repository - - - - - - - UTF-8 - - - 11 - 11 - 3.7.0 - 3.0.2 - 3.1.0 - 2.9 - 0.8.1 - 3.2 - 3.0.1 - 2.3 - false - 3.7.0.1746 - - 2.0.2.RELEASE - 2.0.7.RELEASE - 5.0.5.RELEASE - 2.0.0.RELEASE - - 2.0.7 - 1.5.20 - 2.9.2 - - 3.6.2 - 3.7.0 - - - - 1.2 - 3.0.0 - 1.3 - 2.2 - 2.0.1.Final - 2.2.6 - - - 1.4.197 - 5.1.46 - 42.2.2 - 2.5.0 - 6.0.12.Final - - - 1.10.19 - 1.7.4 - 2.0.0-beta.5 - - - 3.6.1 - 3.7 - 2.6 - 1.11 - 4.3 - 1.9.2 - 2.2 - 4.5.6 - 19.0 - 1.18.8 - 0.1.54 - 1.4.0 - 7.1.0 - 2.0.0 - 5.5.13 - 2.3.23 - 1.7 - 2.0 - 1.5.2 - 2.1.1 - 1.60 - 63.1 - 1.0.0 - 3.3.3 - 2.8.1 - 4.1.0-incubating - 1.11.368 - 0.2.4 - 2.3.0 - 3.0.1 - 1.9.12 - 0.6.0 - 2.0.0.AM2 - - - - - - - - 0.8.2 - 2.2 - 3.2 - UTF-8 - 3.7.0 - 3.0.1 - - - 1.1.6 - 1.7.19 - 1.10.19 - - - 1.4.6 - - - 5.0.6.RELEASE - - - 5.4.2.Final - - - 2.1.1 - - - 10.13.1.1 - - - 3.4.0 - - - 1.3.5 - - - 0.3.12 - - - 0.3.0 - - - 1.1.2-incubating - 1.2.0.1-B1 - 0.4.7 - 3.0.0 - 2.41.2 - 2.4.0 - 3.3.9 - 3.0.7 - 6.11 - 1.13 - apitest-idrepo-1.2.0.1-SNAPSHOT-jar-with-dependencies - - - - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - attach-javadocs - - jar - - - - - none - - - - maven-compiler-plugin - 3.5.1 - - 11 - 11 - -Dfile.encoding=UTF-8 - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.2.0 - - none - - - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + io.mosip.idrepo + apitest-idrepo + jar + apitest-idrepo + Parent project of apitest-idrepo + https://github.com/mosip/id-repository + 1.2.1-SNAPSHOT + + + + MPL 2.0 + https://www.mozilla.org/en-US/MPL/2.0/ + + + + + scm:git:git://github.com/mosip/id-repository.git + scm:git:ssh://github.com:mosip/id-repository.git + https://github.com/mosip/id-repository + HEAD + + + + + Mosip + mosip.emailnotifier@gmail.com + io.mosip + https://github.com/mosip/id-repository + + + + + + + UTF-8 + + + 11 + 11 + 3.7.0 + 3.0.2 + 3.1.0 + 2.9 + 0.8.1 + 3.2 + 3.0.1 + 2.3 + false + 3.7.0.1746 + + 2.0.2.RELEASE + 2.0.7.RELEASE + 5.0.5.RELEASE + 2.0.0.RELEASE + + 2.0.7 + 1.5.20 + 2.9.2 + + 3.6.2 + 3.7.0 + + + + 1.2 + 3.0.0 + 1.3 + 2.2 + 2.0.1.Final + 2.2.6 + + + 1.4.197 + 5.1.46 + 42.2.2 + 2.5.0 + 6.0.12.Final + + + 1.10.19 + 1.7.4 + 2.0.0-beta.5 + + + 3.6.1 + 3.7 + 2.6 + 1.11 + 4.3 + 1.9.2 + 2.2 + 4.5.6 + 19.0 + 1.18.8 + 0.1.54 + 1.4.0 + 7.1.0 + 2.0.0 + 5.5.13 + 2.3.23 + 1.7 + 2.0 + 1.5.2 + 2.1.1 + 1.60 + 63.1 + 1.0.0 + 3.3.3 + 2.8.1 + 4.1.0-incubating + 1.11.368 + 0.2.4 + 2.3.0 + 3.0.1 + 1.9.12 + 0.6.0 + 2.0.0.AM2 + + + + + + + + 0.8.2 + 2.2 + 3.2 + UTF-8 + 3.7.0 + 3.0.1 + + + 1.1.6 + 1.7.19 + 1.10.19 + + + 1.4.6 + + + 5.0.6.RELEASE + + + 5.4.2.Final + + + 2.1.1 + + + 10.13.1.1 + + + 3.4.0 + + + 1.3.5 + + + 0.3.12 + + + 0.3.0 + + + 1.1.2-incubating + 1.2.0.1-B1 + 0.4.7 + 3.0.0 + 2.41.2 + 2.4.0 + 3.3.9 + 3.0.7 + 6.11 + 1.13 + apitest-idrepo-1.2.0.1-SNAPSHOT-jar-with-dependencies + + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + + none + + + + maven-compiler-plugin + 3.5.1 + + 11 + 11 + -Dfile.encoding=UTF-8 + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.2.0 + + none + + + pl.project13.maven git-commit-id-plugin 3.0.1 @@ -241,156 +241,156 @@ - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - --pinentry-mode - loopback - - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - - shade - - - ${fileName} - - - - - - io.mosip.testrig.apirig.testrunner.MosipTestRunner - - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - 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} - - - - - - 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-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-antrun-plugin - 3.0.0 - - - make-jar-executable - package - - run - - - - - - - - - - - - - - - - - - - io.mosip.testrig.apirig.apitest.commons - apitest-commons - 1.2.1-SNAPSHOT - - - - - + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + + shade + + + ${fileName} + + + + + + io.mosip.testrig.apirig.testrunner.MosipTestRunner + + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + 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} + + + + + + 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-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 3.0.0 + + + make-jar-executable + package + + run + + + + + + + + + + + + + + + + + + + io.mosip.testrig.apirig.apitest.commons + apitest-commons + 1.2.1-SNAPSHOT + + + + + \ No newline at end of file diff --git a/db_scripts/mosip_credential/ddl/credential-batch_job_execution.sql b/db_scripts/mosip_credential/ddl/credential-batch_job_execution.sql index bc6ada2ba..721f69732 100644 --- a/db_scripts/mosip_credential/ddl/credential-batch_job_execution.sql +++ b/db_scripts/mosip_credential/ddl/credential-batch_job_execution.sql @@ -3,17 +3,16 @@ -- DROP TABLE credential.batch_job_execution; CREATE TABLE credential.batch_job_execution ( - JOB_EXECUTION_ID BIGINT PRIMARY KEY , - VERSION BIGINT, - JOB_INSTANCE_ID BIGINT NOT NULL, - CREATE_TIME TIMESTAMP NOT NULL, - START_TIME TIMESTAMP DEFAULT NULL, - END_TIME TIMESTAMP DEFAULT NULL, - STATUS VARCHAR(10), - EXIT_CODE VARCHAR(20), - EXIT_MESSAGE VARCHAR(2500), - LAST_UPDATED TIMESTAMP, - JOB_CONFIGURATION_LOCATION VARCHAR(2500) NULL + JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY, + VERSION BIGINT, + JOB_INSTANCE_ID BIGINT NOT NULL, + CREATE_TIME TIMESTAMP NOT NULL, + START_TIME TIMESTAMP DEFAULT NULL, + END_TIME TIMESTAMP DEFAULT NULL, + STATUS VARCHAR(10), + EXIT_CODE VARCHAR(2500), + EXIT_MESSAGE VARCHAR(2500), + LAST_UPDATED TIMESTAMP ) WITH ( OIDS = FALSE diff --git a/db_scripts/mosip_credential/ddl/credential-batch_job_execution_context.sql b/db_scripts/mosip_credential/ddl/credential-batch_job_execution_context.sql index 451e21ec5..8e4d9d947 100644 --- a/db_scripts/mosip_credential/ddl/credential-batch_job_execution_context.sql +++ b/db_scripts/mosip_credential/ddl/credential-batch_job_execution_context.sql @@ -4,10 +4,9 @@ CREATE TABLE credential.batch_job_execution_context ( - job_execution_id bigint NOT NULL, - short_context character varying(2500) COLLATE pg_catalog."default" NOT NULL, - serialized_context text COLLATE pg_catalog."default", - CONSTRAINT batch_job_execution_context_pkey PRIMARY KEY (job_execution_id) + JOB_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY, + SHORT_CONTEXT VARCHAR(2500) NOT NULL, + SERIALIZED_CONTEXT TEXT ) WITH ( OIDS = FALSE diff --git a/db_scripts/mosip_credential/ddl/credential-batch_job_execution_params.sql b/db_scripts/mosip_credential/ddl/credential-batch_job_execution_params.sql index caaf5a908..2c9085074 100644 --- a/db_scripts/mosip_credential/ddl/credential-batch_job_execution_params.sql +++ b/db_scripts/mosip_credential/ddl/credential-batch_job_execution_params.sql @@ -3,13 +3,10 @@ -- DROP TABLE credential.batch_job_execution_params; CREATE TABLE credential.batch_job_execution_params ( - JOB_EXECUTION_ID BIGINT NOT NULL , - TYPE_CD VARCHAR(6) NOT NULL , - KEY_NAME VARCHAR(100) NOT NULL , - STRING_VAL VARCHAR(250) , - DATE_VAL TIMESTAMP DEFAULT NULL , - LONG_VAL BIGINT , - DOUBLE_VAL DOUBLE PRECISION , + JOB_EXECUTION_ID BIGINT NOT NULL, + PARAMETER_NAME VARCHAR(100) NOT NULL, + PARAMETER_TYPE VARCHAR(100) NOT NULL, + PARAMETER_VALUE VARCHAR(2500), IDENTIFYING CHAR(1) NOT NULL ) WITH ( diff --git a/db_scripts/mosip_credential/ddl/credential-batch_job_instance.sql b/db_scripts/mosip_credential/ddl/credential-batch_job_instance.sql index 6fe2cecc2..705fae4f4 100644 --- a/db_scripts/mosip_credential/ddl/credential-batch_job_instance.sql +++ b/db_scripts/mosip_credential/ddl/credential-batch_job_instance.sql @@ -3,10 +3,11 @@ -- DROP TABLE credential.batch_job_instance; CREATE TABLE credential.batch_job_instance ( - JOB_INSTANCE_ID BIGINT PRIMARY KEY , - VERSION BIGINT, - JOB_NAME VARCHAR(100) NOT NULL , - JOB_KEY VARCHAR(2500) + JOB_INSTANCE_ID BIGINT NOT NULL PRIMARY KEY, + VERSION BIGINT, + JOB_NAME VARCHAR(100) NOT NULL, + JOB_KEY VARCHAR(32) NOT NULL, + constraint JOB_INST_UN unique (JOB_NAME, JOB_KEY) ) WITH ( OIDS = FALSE diff --git a/db_scripts/mosip_credential/ddl/credential-batch_step_execution.sql b/db_scripts/mosip_credential/ddl/credential-batch_step_execution.sql index 6ae64fb5f..a90116107 100644 --- a/db_scripts/mosip_credential/ddl/credential-batch_step_execution.sql +++ b/db_scripts/mosip_credential/ddl/credential-batch_step_execution.sql @@ -3,24 +3,25 @@ -- DROP TABLE credential.batch_step_execution; CREATE TABLE credential.batch_step_execution ( - STEP_EXECUTION_ID BIGINT PRIMARY KEY , - VERSION BIGINT NOT NULL, - STEP_NAME VARCHAR(100) NOT NULL, - JOB_EXECUTION_ID BIGINT NOT NULL, - START_TIME TIMESTAMP NOT NULL , - END_TIME TIMESTAMP DEFAULT NULL, - STATUS VARCHAR(10), - COMMIT_COUNT BIGINT , - READ_COUNT BIGINT , - FILTER_COUNT BIGINT , - WRITE_COUNT BIGINT , - READ_SKIP_COUNT BIGINT , - WRITE_SKIP_COUNT BIGINT , - PROCESS_SKIP_COUNT BIGINT , - ROLLBACK_COUNT BIGINT , - EXIT_CODE VARCHAR(20) , - EXIT_MESSAGE VARCHAR(2500) , - LAST_UPDATED TIMESTAMP + STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY, + VERSION BIGINT NOT NULL, + STEP_NAME VARCHAR(100) NOT NULL, + JOB_EXECUTION_ID BIGINT NOT NULL, + CREATE_TIME TIMESTAMP NOT NULL, + START_TIME TIMESTAMP DEFAULT NULL , + END_TIME TIMESTAMP DEFAULT NULL , + STATUS VARCHAR(10), + COMMIT_COUNT BIGINT, + READ_COUNT BIGINT, + FILTER_COUNT BIGINT, + WRITE_COUNT BIGINT, + READ_SKIP_COUNT BIGINT, + WRITE_SKIP_COUNT BIGINT, + PROCESS_SKIP_COUNT BIGINT, + ROLLBACK_COUNT BIGINT, + EXIT_CODE VARCHAR(2500), + EXIT_MESSAGE VARCHAR(2500), + LAST_UPDATED TIMESTAMP ) WITH ( OIDS = FALSE diff --git a/db_scripts/mosip_credential/ddl/credential-batch_step_execution_context.sql b/db_scripts/mosip_credential/ddl/credential-batch_step_execution_context.sql index b89baab4c..3c4b37c83 100644 --- a/db_scripts/mosip_credential/ddl/credential-batch_step_execution_context.sql +++ b/db_scripts/mosip_credential/ddl/credential-batch_step_execution_context.sql @@ -4,11 +4,9 @@ CREATE TABLE credential.batch_step_execution_context ( - step_execution_id bigint NOT NULL, - short_context character varying(2500) COLLATE pg_catalog."default" NOT NULL, - serialized_context text COLLATE pg_catalog."default", - CONSTRAINT batch_step_execution_context_pkey PRIMARY KEY (step_execution_id) - + STEP_EXECUTION_ID BIGINT NOT NULL PRIMARY KEY, + SHORT_CONTEXT VARCHAR(2500) NOT NULL, + SERIALIZED_CONTEXT TEXT ) WITH ( OIDS = FALSE diff --git a/db_scripts/mosip_credential/ddl/credential-credential_transaction.sql b/db_scripts/mosip_credential/ddl/credential-credential_transaction.sql index 335d52b91..9485299ca 100644 --- a/db_scripts/mosip_credential/ddl/credential-credential_transaction.sql +++ b/db_scripts/mosip_credential/ddl/credential-credential_transaction.sql @@ -31,7 +31,6 @@ CREATE TABLE credential.credential_transaction( del_dtimes timestamp, status_comment character varying(512), CONSTRAINT pk_credtrn_id PRIMARY KEY (id) - ); CREATE INDEX cred_tran_NEW_status_cr_dtimes ON credential.credential_transaction USING btree (cr_dtimes) WHERE status_code = 'NEW'; diff --git a/db_scripts/mosip_credential/ddl/credential-fk.sql b/db_scripts/mosip_credential/ddl/credential-fk.sql index c4ec54b56..786e2c19c 100644 --- a/db_scripts/mosip_credential/ddl/credential-fk.sql +++ b/db_scripts/mosip_credential/ddl/credential-fk.sql @@ -15,31 +15,31 @@ -- object: STEP_EXEC_CTX_FK | type: CONSTRAINT -- -- ALTER TABLE credential.batch_step_execution_context DROP CONSTRAINT IF EXISTS STEP_EXEC_CTX_FK CASCADE; ALTER TABLE credential.batch_step_execution_context ADD CONSTRAINT STEP_EXEC_CTX_FK FOREIGN KEY (STEP_EXECUTION_ID) -REFERENCES BATCH_STEP_EXECUTION(STEP_EXECUTION_ID); +REFERENCES credential.BATCH_STEP_EXECUTION(STEP_EXECUTION_ID); -- ddl-end -- -- object: JOB_EXEC_CTX_FK | type: CONSTRAINT -- -- ALTER TABLE credential.batch_job_execution_context DROP CONSTRAINT IF EXISTS JOB_EXEC_CTX_FK CASCADE; ALTER TABLE credential.batch_job_execution_context ADD CONSTRAINT JOB_EXEC_CTX_FK FOREIGN KEY (JOB_EXECUTION_ID) -REFERENCES BATCH_JOB_EXECUTION(JOB_EXECUTION_ID); +REFERENCES credential.BATCH_JOB_EXECUTION(JOB_EXECUTION_ID); -- ddl-end -- -- object: JOB_INSTANCE_EXECUTION_FK | type: CONSTRAINT -- -- ALTER TABLE credential.batch_job_execution DROP CONSTRAINT IF EXISTS JOB_INSTANCE_EXECUTION_FK CASCADE; -ALTER TABLE credential.batch_job_execution ADD CONSTRAINT JOB_INSTANCE_EXECUTION_FK FOREIGN KEY (JOB_INSTANCE_ID) -REFERENCES BATCH_JOB_INSTANCE(JOB_INSTANCE_ID); +ALTER TABLE credential.batch_job_execution ADD CONSTRAINT JOB_INST_EXEC_FK FOREIGN KEY (JOB_INSTANCE_ID) +REFERENCES credential.BATCH_JOB_INSTANCE(JOB_INSTANCE_ID); -- ddl-end -- -- object: JOB_EXECUTION_STEP_FK | type: CONSTRAINT -- -- ALTER TABLE credential.batch_step_execution DROP CONSTRAINT IF EXISTS JOB_EXECUTION_STEP_FK CASCADE; ALTER TABLE credential.batch_step_execution ADD CONSTRAINT JOB_EXECUTION_STEP_FK FOREIGN KEY (JOB_EXECUTION_ID) -REFERENCES BATCH_JOB_EXECUTION(JOB_EXECUTION_ID); +REFERENCES credential.BATCH_JOB_EXECUTION(JOB_EXECUTION_ID); -- ddl-end -- -- object: JOB_EXEC_PARAMS_FK | type: CONSTRAINT -- -- ALTER TABLE credential.batch_job_execution_params DROP CONSTRAINT IF EXISTS JOB_EXEC_PARAMS_FK CASCADE; ALTER TABLE credential.batch_job_execution_params ADD CONSTRAINT JOB_EXEC_PARAMS_FK FOREIGN KEY (JOB_EXECUTION_ID) -REFERENCES BATCH_JOB_EXECUTION(JOB_EXECUTION_ID); +REFERENCES credential.BATCH_JOB_EXECUTION(JOB_EXECUTION_ID); -- ddl-end -- CREATE SEQUENCE credential.batch_job_seq; diff --git a/db_upgrade_scripts/mosip_credential/sql/1.2.0.1_to_1.3.0_rollback.sql b/db_upgrade_scripts/mosip_credential/sql/1.2.0.1_to_1.3.0_rollback.sql new file mode 100644 index 000000000..04876d6c6 --- /dev/null +++ b/db_upgrade_scripts/mosip_credential/sql/1.2.0.1_to_1.3.0_rollback.sql @@ -0,0 +1,22 @@ +-- ------------------------------------------------------------------------------------------ +-- Revoke script for Migrating Spring batch version to 5.0 as part of Java 21 Migration. +-- References: +-- 1. https://github.com/spring-projects/spring-batch/wiki/Spring-Batch-5.0-Migration-Guide#ms-sqlserver +-- 2. https://github.com/spring-projects/spring-batch/blob/main/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-postgresql.sql +-- ------------------------------------------------------------------------------------------ +ALTER TABLE BATCH_STEP_EXECUTION DROP CREATE_TIME TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00'; +ALTER TABLE BATCH_STEP_EXECUTION ALTER COLUMN START_TIME ADD NULL; +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS ADD COLUMN DATE_VAL; +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS ADD COLUMN LONG_VAL; +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS ADD COLUMN DOUBLE_VAL; +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS ALTER COLUMN TYPE_CD TYPE VARCHAR(6); +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS RENAME PARAMETER_TYPE TO TYPE_CD; +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS ALTER COLUMN KEY_NAME TYPE VARCHAR(100); +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS RENAME PARAMETER_NAME TO KEY_NAME; +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS ALTER COLUMN STRING_VAL TYPE VARCHAR(250); +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS RENAME PARAMETER_VALUE TO STRING_VAL; +ALTER TABLE BATCH_JOB_EXECUTION ADD COLUMN JOB_CONFIGURATION_LOCATION; + +DROP SEQUENCE BATCH_STEP_EXECUTION_SEQ; +DROP SEQUENCE BATCH_JOB_EXECUTION_SEQ; +DROP SEQUENCE BATCH_JOB_SEQ; \ No newline at end of file diff --git a/db_upgrade_scripts/mosip_credential/sql/1.2.0.1_to_1.3.0_upgrade.sql b/db_upgrade_scripts/mosip_credential/sql/1.2.0.1_to_1.3.0_upgrade.sql new file mode 100644 index 000000000..91ffdc28a --- /dev/null +++ b/db_upgrade_scripts/mosip_credential/sql/1.2.0.1_to_1.3.0_upgrade.sql @@ -0,0 +1,22 @@ +-- ------------------------------------------------------------------------------------------ +-- Upgrade script for Migrating Spring batch version to 5.0 as part of Java 21 Migration. +-- References: +-- 1. https://github.com/spring-projects/spring-batch/wiki/Spring-Batch-5.0-Migration-Guide#ms-sqlserver +-- 2. https://github.com/spring-projects/spring-batch/blob/main/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-postgresql.sql +-- ------------------------------------------------------------------------------------------ +ALTER TABLE BATCH_STEP_EXECUTION ADD CREATE_TIME TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00'; +ALTER TABLE BATCH_STEP_EXECUTION ALTER COLUMN START_TIME DROP NOT NULL; +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS DROP COLUMN DATE_VAL; +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS DROP COLUMN LONG_VAL; +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS DROP COLUMN DOUBLE_VAL; +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS ALTER COLUMN TYPE_CD TYPE VARCHAR(100); +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS RENAME TYPE_CD TO PARAMETER_TYPE; +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS ALTER COLUMN KEY_NAME TYPE VARCHAR(100); +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS RENAME KEY_NAME TO PARAMETER_NAME; +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS ALTER COLUMN STRING_VAL TYPE VARCHAR(2500); +ALTER TABLE BATCH_JOB_EXECUTION_PARAMS RENAME STRING_VAL TO PARAMETER_VALUE; +ALTER TABLE BATCH_JOB_EXECUTION DROP COLUMN JOB_CONFIGURATION_LOCATION; + +CREATE SEQUENCE BATCH_STEP_EXECUTION_SEQ START WITH 0 MINVALUE 0 MAXVALUE 9223372036854775807 NO CYCLE; +CREATE SEQUENCE BATCH_JOB_EXECUTION_SEQ START WITH 0 MINVALUE 0 MAXVALUE 9223372036854775807 NO CYCLE; +CREATE SEQUENCE BATCH_JOB_SEQ START WITH 0 MINVALUE 0 MAXVALUE 9223372036854775807 NO CYCLE; \ No newline at end of file diff --git a/id-repository/credential-request-generator/Dockerfile b/id-repository/credential-request-generator/Dockerfile index 7d37dce2c..2f839e124 100644 --- a/id-repository/credential-request-generator/Dockerfile +++ b/id-repository/credential-request-generator/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:11 +FROM eclipse-temurin:21-jre-alpine ARG SOURCE ARG COMMIT_HASH @@ -48,16 +48,16 @@ ARG container_user=mosip ARG container_user_group=mosip # can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 +ARG container_user_uid=1002 # can be passed during Docker build as build time environment for github branch to pickup configuration from. ARG container_user_gid=1001 # install packages and create user -RUN apt-get -y update \ -&& apt-get install -y unzip \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} +RUN apk -q update \ +&& apk add -q unzip \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} # set working directory for the user WORKDIR /home/${container_user} @@ -89,10 +89,10 @@ CMD if [ "$is_glowroot_env" = "present" ]; then \ rm -rf glowroot.zip ; \ sed -i 's//credential-request-generator/g' glowroot/glowroot.properties ; \ wget -q --show-progress "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -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 credential-request-generator.jar ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" --add-opens java.base/sun.reflect.annotation=ALL-UNNAMED -jar -javaagent:glowroot/glowroot.jar credential-request-generator.jar ; \ else \ wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -jar credential-request-generator.jar ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" --add-opens java.base/sun.reflect.annotation=ALL-UNNAMED -jar credential-request-generator.jar ; \ fi diff --git a/id-repository/credential-request-generator/pom.xml b/id-repository/credential-request-generator/pom.xml index b6b578e12..8e4f49b8f 100644 --- a/id-repository/credential-request-generator/pom.xml +++ b/id-repository/credential-request-generator/pom.xml @@ -16,14 +16,13 @@ UTF-8 - 11 - 11 + 21 + 21 2.0.2.RELEASE 2.0.7.RELEASE 5.0.5.RELEASE 2.0.0.RELEASE 1.4.197 - 2.9.8 2.9.2 1.2.1-SNAPSHOT 1.7.4 @@ -40,26 +39,6 @@ - - com.fasterxml.jackson.core - jackson-databind - 2.12.0 - - - com.fasterxml.jackson.core - jackson-annotations - 2.12.0 - - - com.fasterxml.jackson.core - jackson-core - 2.12.0 - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - 2.12.0 - org.springframework.cloud spring-cloud-starter-config @@ -71,12 +50,7 @@ ${mockito.version} test - - com.fasterxml.jackson.module - jackson-module-afterburner - 2.12.0 - - + com.h2database h2 ${h2.version} @@ -84,30 +58,10 @@ - - com.fasterxml.jackson.core - jackson-databind - 2.12.0 - - - com.fasterxml.jackson.core - jackson-annotations - 2.12.0 - - - com.fasterxml.jackson.core - jackson-core - 2.12.0 - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - 2.12.0 - + junit junit - 3.8.1 test @@ -128,17 +82,14 @@ org.springframework.cloud spring-cloud-starter-config - ${spring-cloud-config.version} org.springframework.boot spring-boot-starter-data-jpa - ${spring.boot.version} org.springframework.boot spring-boot-starter-web - ${spring.boot.version} io.springfox @@ -153,23 +104,19 @@ com.h2database h2 - ${h2.version} runtime org.springframework.boot spring-boot-starter-batch - ${spring.boot.version} javax.xml.bind jaxb-api - 2.3.0 org.apache.httpcomponents httpclient - ${apache.httpcomponents.version} io.mosip.kernel @@ -179,24 +126,20 @@ com.googlecode.json-simple json-simple - 1.1.1 com.google.code.gson gson - ${gson.version} junit junit - ${junit.version} test org.springframework.boot spring-boot-starter-test test - ${spring.boot.version} org.mockito @@ -218,17 +161,14 @@ org.postgresql postgresql - ${postgresql.version} io.micrometer micrometer-core - ${io.micrometer.prometheus.version} io.micrometer micrometer-registry-prometheus - ${io.micrometer.prometheus.version} io.mosip.kernel @@ -238,7 +178,6 @@ org.springframework.batch spring-batch-integration - ${spring.batch.integration.version} org.springframework @@ -249,29 +188,24 @@ org.springframework spring-context - 5.0.6.RELEASE io.projectreactor reactor-core - 3.1.6.RELEASE org.springframework spring-jdbc - 4.3.8.RELEASE - - - org.springdoc - springdoc-openapi-ui - ${springdoc.version} org.springframework.boot spring-boot-configuration-processor - ${spring.boot.version} true + + org.hibernate.validator + hibernate-validator + diff --git a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/CredentialRequestGeneratorBootApplication.java b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/CredentialRequestGeneratorBootApplication.java new file mode 100644 index 000000000..3ef22309a --- /dev/null +++ b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/CredentialRequestGeneratorBootApplication.java @@ -0,0 +1,44 @@ +package io.mosip.credential.request.generator; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.scheduling.annotation.EnableScheduling; + +import io.mosip.credential.request.generator.api.config.CredentialRequestGeneratorConfig; +import io.mosip.credential.request.generator.entity.CredentialEntity; +import io.mosip.idrepository.core.config.IdRepoDataSourceConfig; +import io.mosip.idrepository.core.helper.RestHelper; +import io.mosip.idrepository.core.security.IdRepoSecurityManager; +import io.mosip.idrepository.core.util.DummyPartnerCheckUtil; +import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; +import io.mosip.kernel.dataaccess.hibernate.repository.impl.HibernateRepositoryImpl; + +/** + * The Class CredentialRequestGeneratorApp. + * + */ +@SpringBootApplication +@Import(value = { java.lang.String.class, DummyPartnerCheckUtil.class, RestHelper.class, IdRepoSecurityManager.class, + CredentialRequestGeneratorConfig.class }) +@ComponentScan(basePackages = { "io.mosip.credential.*", "${mosip.auth.adapter.impl.basepackage}" }, excludeFilters = { + @ComponentScan.Filter(type = FilterType.ASPECTJ, pattern = { "io.mosip.kernel.dataaccess.hibernate.config.*" }), + @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = { HibernateDaoConfig.class, + IdRepoDataSourceConfig.class }) }) + +@EnableScheduling +public class CredentialRequestGeneratorBootApplication { + + /** + * The main method. + * + * @param args the arguments + */ + public static void main(String[] args) { + SpringApplication.run(CredentialRequestGeneratorBootApplication.class, args); + } +} diff --git a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/api/CredentialRequestGeneratorBootApplication.java b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/api/CredentialRequestGeneratorBootApplication.java deleted file mode 100644 index 56e037fbd..000000000 --- a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/api/CredentialRequestGeneratorBootApplication.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.mosip.credential.request.generator.api; - -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.FilterType; -import org.springframework.context.annotation.Import; -import org.springframework.scheduling.annotation.EnableScheduling; - -import io.mosip.idrepository.core.helper.RestHelper; -import io.mosip.idrepository.core.security.IdRepoSecurityManager; -import io.mosip.idrepository.core.util.DummyPartnerCheckUtil; -import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; - -/** - * The Class CredentialRequestGeneratorApp. - * - * @author Sowmya - */ -@SpringBootApplication(exclude = HibernateDaoConfig.class) -@Import(value = { java.lang.String.class, DummyPartnerCheckUtil.class, RestHelper.class, IdRepoSecurityManager.class }) -@ComponentScan(basePackages = { "io.mosip.*", -"${mosip.auth.adapter.impl.basepackage}" }, excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = { - "io.mosip.idrepository.core.config.IdRepoDataSourceConfig.*", "io.mosip.kernel.dataaccess.hibernate.config.*" })) -@EnableBatchProcessing -@EnableScheduling -public class CredentialRequestGeneratorBootApplication { - - /** - * The main method. - * - * @param args the arguments - */ - public static void main(String[] args) { - SpringApplication.run(CredentialRequestGeneratorBootApplication.class, args); - } -} diff --git a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/api/config/CredentialRequestGeneratorConfig.java b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/api/config/CredentialRequestGeneratorConfig.java index 15b0ac6a9..35e65f00c 100644 --- a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/api/config/CredentialRequestGeneratorConfig.java +++ b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/api/config/CredentialRequestGeneratorConfig.java @@ -6,17 +6,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springdoc.core.GroupedOpenApi; +import org.springdoc.core.models.GroupedOpenApi; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import io.mosip.credential.request.generator.entity.CredentialEntity; import io.mosip.credential.request.generator.interceptor.CredentialTransactionInterceptor; -import io.mosip.credential.request.generator.repositary.CredentialRepositary; import io.mosip.credential.request.generator.util.RestUtil; import io.mosip.idrepository.core.builder.RestRequestBuilder; import io.mosip.idrepository.core.constant.RestServicesConstants; @@ -29,8 +30,8 @@ import io.swagger.v3.oas.models.servers.Server; @Configuration -@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory", basePackageClasses = { - CredentialRepositary.class }, basePackages = "io.mosip.credential.request.generator.repositary.*", repositoryBaseClass = HibernateRepositoryImpl.class) +@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory", basePackages = "io.mosip.credential.request.generator.repositary.*", repositoryBaseClass = HibernateRepositoryImpl.class, excludeFilters = { + @ComponentScan.Filter(type = FilterType.ASPECTJ, pattern = { "io.mosip.idrepository.core.repository.*" }) }) @EntityScan(basePackageClasses = { CredentialEntity.class }) public class CredentialRequestGeneratorConfig extends HibernateDaoConfig { @@ -46,7 +47,7 @@ public class CredentialRequestGeneratorConfig extends HibernateDaoConfig { @Override public Map jpaProperties() { Map jpaProperties = super.jpaProperties(); - jpaProperties.put("hibernate.ejb.interceptor", new CredentialTransactionInterceptor(restUtil)); + jpaProperties.put("hibernate.session_factory.interceptor", new CredentialTransactionInterceptor(restUtil)); return jpaProperties; } diff --git a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/BatchConfiguration.java b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/BatchConfiguration.java index 95f4860dd..8bf8470b0 100644 --- a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/BatchConfiguration.java +++ b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/BatchConfiguration.java @@ -1,128 +1,48 @@ package io.mosip.credential.request.generator.batch.config; import java.lang.reflect.Field; +import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; import java.util.Map; -import javax.persistence.QueryHint; +import javax.sql.DataSource; -import io.mosip.idrepository.core.logger.IdRepoLogger; -import io.mosip.idrepository.core.security.IdRepoSecurityManager; -import io.mosip.kernel.core.exception.ExceptionUtils; -import io.mosip.kernel.core.logger.spi.Logger; import org.springframework.batch.core.Job; -import org.springframework.batch.core.JobParameters; -import org.springframework.batch.core.JobParametersBuilder; import org.springframework.batch.core.Step; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; -import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; -import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; -import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.batch.core.job.builder.JobBuilder; import org.springframework.batch.core.launch.support.RunIdIncrementer; -import org.springframework.batch.integration.async.AsyncItemProcessor; -import org.springframework.batch.integration.async.AsyncItemWriter; -import org.springframework.batch.item.ItemProcessor; -import org.springframework.batch.item.data.RepositoryItemReader; -import org.springframework.batch.item.data.RepositoryItemWriter; +import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.core.step.builder.StepBuilder; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.DependsOn; import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.data.domain.Sort.Direction; import org.springframework.data.jpa.repository.QueryHints; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; +import org.springframework.transaction.PlatformTransactionManager; import com.fasterxml.jackson.module.afterburner.AfterburnerModule; -import io.mosip.credential.request.generator.entity.CredentialEntity; import io.mosip.credential.request.generator.repositary.CredentialRepositary; import io.mosip.credential.request.generator.util.RestUtil; - - +import jakarta.persistence.QueryHint; /** * The Class BatchConfiguration. * - * @author Sowmya */ @Configuration -@EnableBatchProcessing public class BatchConfiguration { - + @Autowired public CredentialItemTasklet credentialItemTasklet; @Autowired public CredentialItemReprocessTasklet credentialItemReprocessTasklet; - /** The job builder factory. */ - @Autowired - public JobBuilderFactory jobBuilderFactory; - - /** The step builder factory. */ - @Autowired - public StepBuilderFactory stepBuilderFactory; - - /** The job launcher. */ - @Autowired - private JobLauncher jobLauncher; - - /** The crdential repo. */ - @Autowired - private CredentialRepositary crdentialRepo; - - /** The credential process job. */ - @Autowired - private Job credentialProcessJob; - - /** The credential re process job. */ - @Autowired - private Job credentialReProcessJob; - - private static final String BATCH_CONFIGURATION = "BatchConfiguration"; - private static final Logger LOGGER = IdRepoLogger.getLogger(BatchConfiguration.class); - - /** - * Process job. - */ - @Scheduled(fixedDelayString = "${mosip.credential.request.job.timedelay}") - public void processJob() { - try { - JobParameters jobParameters = new JobParametersBuilder().addLong("time", System.currentTimeMillis()) - .toJobParameters(); - jobLauncher.run(credentialProcessJob, jobParameters); - - } catch (Exception e) { - LOGGER.error(IdRepoSecurityManager.getUser(), BATCH_CONFIGURATION, - "error in JobLauncher " + ExceptionUtils.getStackTrace(e)); - } - } - - /** - * Re process job. - */ - @Scheduled(fixedDelayString = "${mosip.credential.request.reprocess.job.timedelay}") - public void reProcessJob() { - try { - JobParameters jobParameters = new JobParametersBuilder().addLong("time", System.currentTimeMillis()) - .toJobParameters(); - jobLauncher.run(credentialReProcessJob, jobParameters); - - } catch (Exception e) { - LOGGER.error(IdRepoSecurityManager.getUser(), BATCH_CONFIGURATION, - "error in JobLauncher " + ExceptionUtils.getStackTrace(e)); - } - } - /** * Credential process job. * @@ -130,9 +50,9 @@ public void reProcessJob() { * @return the job */ @Bean - public Job credentialProcessJob(JobCompletionNotificationListener listener) throws Exception { - return jobBuilderFactory.get("credentialProcessJob").incrementer(new RunIdIncrementer()).listener(listener) - .flow(credentialProcessStep()).end().build(); + public Job credentialProcessJob(JobRepository jobRepository, JobCompletionNotificationListener listener,PlatformTransactionManager transactionManager) { + return new JobBuilder("credentialProcessJob", jobRepository).incrementer(new RunIdIncrementer()) + .listener(listener).flow(credentialProcessStep(jobRepository,transactionManager)).end().build(); } /** @@ -140,27 +60,30 @@ public Job credentialProcessJob(JobCompletionNotificationListener listener) thro * * @param listener the listener * @return the job + * @throws Exception */ + @Bean - public Job credentialReProcessJob(JobCompletionNotificationListener listener) throws Exception { - return jobBuilderFactory.get("credentialReProcessJob").incrementer(new RunIdIncrementer()).listener(listener) - .flow(credentialReProcessStep()).end().build(); + public Job credentialReProcessJob(JobRepository jobRepository, JobCompletionNotificationListener listener,PlatformTransactionManager transactionManager) + throws Exception { + return new JobBuilder("credentialReProcessJob", jobRepository).incrementer(new RunIdIncrementer()) + .listener(listener).flow(credentialReProcessStep(jobRepository,transactionManager)).end().build(); } - + @Bean @DependsOn("alterAnnotation") - public Step credentialProcessStep() { - return stepBuilderFactory.get("credentialProcessJob").tasklet(credentialItemTasklet).build(); - + public Step credentialProcessStep(JobRepository jobRepository,PlatformTransactionManager transactionManager) { + return new StepBuilder("credentialProcessJob", jobRepository).tasklet(credentialItemTasklet, null).transactionManager(transactionManager).build(); } - + @Bean @DependsOn("alterAnnotation") - public Step credentialReProcessStep() throws Exception { - return stepBuilderFactory.get("credentialProcessJob").tasklet(credentialItemReprocessTasklet).build(); - + public Step credentialReProcessStep(JobRepository jobRepository,PlatformTransactionManager transactionManager) { + Step step = new StepBuilder("credentialProcessJob", jobRepository).tasklet(credentialItemReprocessTasklet, null).transactionManager(transactionManager) + .build(); + return step; } - + /** * Gets the rest util. * @@ -186,15 +109,12 @@ public ThreadPoolTaskScheduler getTaskScheduler() { * * @return the step */ - @Bean public PropertyLoader propertyLoader() { return new PropertyLoader(); } - - @Bean(name = "alterAnnotation") public String alterAnnotation() throws Exception { @@ -203,7 +123,7 @@ public String alterAnnotation() throws Exception { findCredentialByStatusCode.setAccessible(true); QueryHints queryHints = findCredentialByStatusCode.getDeclaredAnnotation(QueryHints.class); QueryHint queryHint = (QueryHint) queryHints.value()[0]; - java.lang.reflect.InvocationHandler invocationHandler = Proxy.getInvocationHandler(queryHint); + InvocationHandler invocationHandler = Proxy.getInvocationHandler(queryHint); Field memberValues = invocationHandler.getClass().getDeclaredField("memberValues"); memberValues.setAccessible(true); Map values = (Map) memberValues.get(invocationHandler); @@ -211,11 +131,11 @@ public String alterAnnotation() throws Exception { findCredentialByStatusCode.setAccessible(false); Method findCredentialByStatusCodes = CredentialRepositary.class.getDeclaredMethod("findCredentialByStatusCodes", - String[].class,Pageable.class); + String[].class, Pageable.class); findCredentialByStatusCodes.setAccessible(true); QueryHints queryHintsReprocess = findCredentialByStatusCodes.getDeclaredAnnotation(QueryHints.class); QueryHint queryHintReprocess = (QueryHint) queryHintsReprocess.value()[0]; - java.lang.reflect.InvocationHandler invocationHandlerReprocess = Proxy.getInvocationHandler(queryHintReprocess); + InvocationHandler invocationHandlerReprocess = Proxy.getInvocationHandler(queryHintReprocess); Field memberValuesReprocess = invocationHandlerReprocess.getClass().getDeclaredField("memberValues"); memberValuesReprocess.setAccessible(true); Map valuesReprocess = (Map) memberValuesReprocess @@ -225,9 +145,8 @@ public String alterAnnotation() throws Exception { findCredentialByStatusCodes.setAccessible(false); return ""; - } - + @Bean public AfterburnerModule afterburnerModule() { return new AfterburnerModule(); diff --git a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/CredentialItemReprocessTasklet.java b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/CredentialItemReprocessTasklet.java index 6794d3919..a0c641d2f 100644 --- a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/CredentialItemReprocessTasklet.java +++ b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/CredentialItemReprocessTasklet.java @@ -6,7 +6,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.scope.context.ChunkContext; @@ -14,6 +14,7 @@ import org.springframework.batch.repeat.RepeatStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Lazy; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -48,6 +49,7 @@ public class CredentialItemReprocessTasklet implements Tasklet { @Value("${credential.batch.thread.count:10}") private int threadCount; + @Lazy @Autowired private ObjectMapper mapper; diff --git a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/CredentialItemTasklet.java b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/CredentialItemTasklet.java index da8a4dd91..5abdeae65 100644 --- a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/CredentialItemTasklet.java +++ b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/CredentialItemTasklet.java @@ -6,14 +6,13 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; -import javax.annotation.PostConstruct; - import org.springframework.batch.core.StepContribution; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.core.step.tasklet.Tasklet; import org.springframework.batch.repeat.RepeatStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Lazy; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -39,6 +38,7 @@ import io.mosip.kernel.core.exception.ExceptionUtils; import io.mosip.kernel.core.logger.spi.Logger; import io.mosip.kernel.core.util.DateUtils; +import jakarta.annotation.PostConstruct; @Component public class CredentialItemTasklet implements Tasklet { @@ -46,6 +46,7 @@ public class CredentialItemTasklet implements Tasklet { @Value("${credential.batch.thread.count:10}") private int threadCount; + @Lazy @Autowired private ObjectMapper mapper; diff --git a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/CredentialScheduleJobConfiguration.java b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/CredentialScheduleJobConfiguration.java new file mode 100644 index 000000000..e5b871304 --- /dev/null +++ b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/CredentialScheduleJobConfiguration.java @@ -0,0 +1,72 @@ +package io.mosip.credential.request.generator.batch.config; + +import org.springframework.batch.core.Job; +import org.springframework.batch.core.JobParameters; +import org.springframework.batch.core.JobParametersBuilder; +import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.Scheduled; + +import io.mosip.idrepository.core.logger.IdRepoLogger; +import io.mosip.idrepository.core.security.IdRepoSecurityManager; +import io.mosip.kernel.core.exception.ExceptionUtils; +import io.mosip.kernel.core.logger.spi.Logger; + +/** + * @author Neha Farheen The Class RestUtil. + */ + +@Configuration +public class CredentialScheduleJobConfiguration { + + /** The job launcher. */ + @Autowired + private JobLauncher jobLauncher; + + /** The credential process job. */ + @Autowired + private Job credentialProcessJob; + + /** The credential re process job. */ + @Autowired + private Job credentialReProcessJob; + + private static final String CREDENTIAL_SCHEDULE_CONFIGURATION = "CredentialJobConfiguration"; + private static final Logger LOGGER = IdRepoLogger.getLogger(CredentialScheduleJobConfiguration.class); + + /** + * Process job. + */ + @Scheduled(fixedDelayString = "${mosip.credential.request.job.timedelay}") + public void processJob() { + try { + JobParameters jobParameters = new JobParametersBuilder().addLong("time", System.currentTimeMillis()) + .toJobParameters(); + jobLauncher.run(credentialProcessJob, jobParameters); + + } catch (Exception e) { + LOGGER.error(IdRepoSecurityManager.getUser(), CREDENTIAL_SCHEDULE_CONFIGURATION, + "error in JobLauncher " + ExceptionUtils.getStackTrace(e)); + } + } + + /** + * Re process job. + */ + @Scheduled(fixedDelayString = "${mosip.credential.request.reprocess.job.timedelay}") + public void reProcessJob() { + try { + JobParameters jobParameters = new JobParametersBuilder().addLong("time", System.currentTimeMillis()) + .toJobParameters(); + jobLauncher.run(credentialReProcessJob, jobParameters); + + } catch (Exception e) { + LOGGER.error(IdRepoSecurityManager.getUser(), CREDENTIAL_SCHEDULE_CONFIGURATION, + "error in JobLauncher " + ExceptionUtils.getStackTrace(e)); + } + } + + + +} diff --git a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/JobCompletionNotificationListener.java b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/JobCompletionNotificationListener.java index 8e939a37d..768842595 100644 --- a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/JobCompletionNotificationListener.java +++ b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/batch/config/JobCompletionNotificationListener.java @@ -2,7 +2,7 @@ import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.JobExecution; -import org.springframework.batch.core.listener.JobExecutionListenerSupport; +import org.springframework.batch.core.JobExecutionListener; import org.springframework.stereotype.Component; import io.mosip.credential.request.generator.constants.LoggerFileConstant; @@ -22,7 +22,7 @@ * @author Sowmya */ @Component -public class JobCompletionNotificationListener extends JobExecutionListenerSupport { +public class JobCompletionNotificationListener implements JobExecutionListener { private static final Logger LOGGER = IdRepoLogger .getLogger(JobCompletionNotificationListener.class); @@ -30,7 +30,6 @@ public class JobCompletionNotificationListener extends JobExecutionListenerSuppo /* (non-Javadoc) * @see org.springframework.batch.core.listener.JobExecutionListenerSupport#afterJob(org.springframework.batch.core.JobExecution) */ - @Override public void afterJob(JobExecution jobExecution) { if (jobExecution.getStatus() == BatchStatus.COMPLETED) { LOGGER.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.ID.toString(), diff --git a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/dao/CredentialDao.java b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/dao/CredentialDao.java index 758400a63..782afc4ee 100644 --- a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/dao/CredentialDao.java +++ b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/dao/CredentialDao.java @@ -35,7 +35,7 @@ public class CredentialDao { /** The crdential repo. */ @Autowired - private CredentialRepositary credentialRepo; + private CredentialRepositary credentialRepo; public void update(String batchId, List credentialEntities) { credentialRepo.saveAll(credentialEntities); diff --git a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/entity/CredentialEntity.java b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/entity/CredentialEntity.java index cef4c46ad..8a87a7f22 100644 --- a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/entity/CredentialEntity.java +++ b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/entity/CredentialEntity.java @@ -5,10 +5,10 @@ import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; /** * The Class CredentialEntity. diff --git a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/interceptor/CredentialTransactionInterceptor.java b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/interceptor/CredentialTransactionInterceptor.java index 71265f6e4..02e612afc 100644 --- a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/interceptor/CredentialTransactionInterceptor.java +++ b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/interceptor/CredentialTransactionInterceptor.java @@ -5,7 +5,7 @@ import java.util.Map; import java.util.Objects; -import org.hibernate.EmptyInterceptor; +import org.hibernate.Interceptor; import org.hibernate.type.Type; import org.springframework.http.MediaType; @@ -28,7 +28,7 @@ * @author Manoj SP * */ -public class CredentialTransactionInterceptor extends EmptyInterceptor { +public class CredentialTransactionInterceptor implements Interceptor { private static final String REQUEST = "request"; @@ -45,7 +45,7 @@ public CredentialTransactionInterceptor(RestUtil restUtil) { @Override public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) { encryptData(entity, state, propertyNames); - return super.onSave(entity, id, state, propertyNames, types); + return Interceptor.super.onSave(entity, id, state, propertyNames, types); } @Override @@ -65,14 +65,14 @@ public boolean onLoad(Object entity, Serializable id, Object[] state, String[] p } state[indexOfData] = decryptedData; } - return super.onLoad(entity, id, state, propertyNames, types); + return Interceptor.super.onLoad(entity, id, state, propertyNames, types); } @Override public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) { encryptData(entity, currentState, propertyNames); - return super.onFlushDirty(entity, id, currentState, previousState, propertyNames, types); + return Interceptor.super.onFlushDirty(entity, id, currentState, previousState, propertyNames, types); } private void encryptData(Object entity, Object[] state, String[] propertyNames) { diff --git a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/repositary/CredentialRepositary.java b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/repositary/CredentialRepositary.java index 40855bb17..5ffa2b3a4 100644 --- a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/repositary/CredentialRepositary.java +++ b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/repositary/CredentialRepositary.java @@ -2,8 +2,8 @@ import java.time.LocalDateTime; -import javax.persistence.LockModeType; -import javax.persistence.QueryHint; +import jakarta.persistence.LockModeType; +import jakarta.persistence.QueryHint; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -30,7 +30,7 @@ * @param the element type */ @Repository -public interface CredentialRepositary extends BaseRepository { +public interface CredentialRepositary extends BaseRepository { @Query("SELECT crdn FROM CredentialEntity crdn WHERE crdn.statusCode= :statusCode") Page findByStatusCode(@Param("statusCode") String statusCode, Pageable pageable); @@ -43,7 +43,7 @@ Page findByStatusCodeWithEffectiveDtimes(@Param("statusCode") @Transactional @Lock(value = LockModeType.PESSIMISTIC_WRITE) - @QueryHints({ @QueryHint(name = "javax.persistence.lock.timeout", value = "1") }) + @QueryHints({ @QueryHint(name = "jakarta.persistence.lock.timeout", value = "1") }) @Query("select c from CredentialEntity c where c.statusCode=:statusCode") Page findCredentialByStatusCode(@Param("statusCode")String statusCode, Pageable pageable); @@ -57,7 +57,7 @@ Page findByStatusCodeWithEffectiveDtimes(@Param("statusCode") */ @Transactional @Lock(value = LockModeType.PESSIMISTIC_WRITE) - @QueryHints({ @QueryHint(name = "javax.persistence.lock.timeout", value = "1") }) + @QueryHints({ @QueryHint(name = "jakarta.persistence.lock.timeout", value = "1") }) @Query("SELECT crdn FROM CredentialEntity crdn WHERE crdn.statusCode in :statusCodes ") Page findCredentialByStatusCodes(@Param("statusCodes") String[] statusCodes,Pageable pageable); } diff --git a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/util/RestUtil.java b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/util/RestUtil.java index 9fec0d6fe..28ee8dc61 100644 --- a/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/util/RestUtil.java +++ b/id-repository/credential-request-generator/src/main/java/io/mosip/credential/request/generator/util/RestUtil.java @@ -9,14 +9,17 @@ import io.mosip.kernel.core.util.DateUtils; import io.mosip.kernel.core.util.StringUtils; import io.mosip.kernel.core.util.TokenHandlerUtil; -import org.apache.http.Header; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; +import org.apache.hc.core5.http.Header; +import org.apache.hc.core5.http.ParseException; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.classic.methods.HttpPost; +import org.apache.hc.core5.http.io.entity.StringEntity; + +import org.apache.hc.client5.http.impl.classic.HttpClientBuilder; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.core5.http.io.entity.EntityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; @@ -38,7 +41,6 @@ import java.util.List; import java.util.Objects; - /** * @author Sowmya The Class RestUtil. */ @@ -183,9 +185,16 @@ public T getApi(ApiName apiName, List pathsegments, String queryPara * @throws KeyStoreException the key store exception */ public RestTemplate getRestTemplate() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException { - if (restTemplate == null) { - HttpClientBuilder httpClientBuilder = HttpClients.custom().setMaxConnPerRoute(maxConnectionPerRoute) - .setMaxConnTotal(totalMaxConnection).disableCookieManagement(); + if (restTemplate == null) { + + var connnectionManagerBuilder = PoolingHttpClientConnectionManagerBuilder.create() + .setMaxConnPerRoute(maxConnectionPerRoute) + .setMaxConnTotal(totalMaxConnection); + var connectionManager = connnectionManagerBuilder.build(); + HttpClientBuilder httpClientBuilder = HttpClients.custom() + .setConnectionManager(connectionManager) + .disableCookieManagement(); + HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); requestFactory.setHttpClient(httpClientBuilder.build()); @@ -193,6 +202,7 @@ public RestTemplate getRestTemplate() throws KeyManagementException, NoSuchAlgor } return restTemplate; } + /** * Sets the request header. @@ -255,7 +265,7 @@ public String getToken() throws IOException { tokenRequestDTO.setVersion(EnvUtil.getCredReqTokenVersion()); Gson gson = new Gson(); - HttpClient httpClient = HttpClientBuilder.create().build(); + CloseableHttpClient httpClient = HttpClientBuilder.create().build(); // HttpPost post = new // HttpPost(environment.getProperty("PASSWORDBASEDTOKENAPI")); HttpPost post = new HttpPost(environment.getProperty("KEYBASEDTOKENAPI")); @@ -263,8 +273,8 @@ public String getToken() throws IOException { StringEntity postingString = new StringEntity(gson.toJson(tokenRequestDTO)); post.setEntity(postingString); post.setHeader("Content-type", "application/json"); - HttpResponse response = httpClient.execute(post); - org.apache.http.HttpEntity entity = response.getEntity(); + CloseableHttpResponse response = httpClient.execute(post); + org.apache.hc.core5.http.HttpEntity entity = response.getEntity(); String responseBody = EntityUtils.toString(entity, "UTF-8"); Header[] cookie = response.getHeaders("Set-Cookie"); if (cookie.length == 0) @@ -274,6 +284,8 @@ public String getToken() throws IOException { return token.substring(0, token.indexOf(';')); } catch (IOException e) { throw e; + }catch (ParseException e) { + throw new RuntimeException(e); } } return AUTHORIZATION + token; diff --git a/id-repository/credential-request-generator/src/main/resources/bootstrap.properties b/id-repository/credential-request-generator/src/main/resources/bootstrap.properties index 22f2e7396..e1a6ac331 100644 --- a/id-repository/credential-request-generator/src/main/resources/bootstrap.properties +++ b/id-repository/credential-request-generator/src/main/resources/bootstrap.properties @@ -23,6 +23,12 @@ javax.persistence.jdbc.user=${mosip.credential.service.jdbc.user} javax.persistence.jdbc.password=${mosip.credential.service.jdbc.password} javax.persistence.jdbc.driver=${mosip.credential.service.jdbc.driver} +#jakarta.persistence.jdbc.url=${mosip.credential.service.jdbc.url} +#jakarta.persistence.jdbc.user=${mosip.credential.service.jdbc.user} +#jakarta.persistence.jdbc.password=${mosip.credential.service.jdbc.password} +#jakarta.persistence.jdbc.driver=${mosip.credential.service.jdbc.driver} +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect +spring.batch.job.enabled=false #Swagger 3.0 open api openapi.info.title=Credential Request Generator openapi.info.description=Credential Request Generator diff --git a/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/dao/CredentialDaoTest.java b/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/dao/CredentialDaoTest.java index 36e44b2bb..94d3a6685 100644 --- a/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/dao/CredentialDaoTest.java +++ b/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/dao/CredentialDaoTest.java @@ -29,7 +29,7 @@ public class CredentialDaoTest { @Mock - private CredentialRepositary credentialRepo; + private CredentialRepositary credentialRepo; @InjectMocks private CredentialDao credentialDao; diff --git a/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/init/CredentialInitializerTest.java b/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/init/CredentialInitializerTest.java index 7537b56a2..8745b0457 100644 --- a/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/init/CredentialInitializerTest.java +++ b/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/init/CredentialInitializerTest.java @@ -36,7 +36,7 @@ public class CredentialInitializerTest { @Test public void onApplicationEventTest(){ SpringApplication application = new SpringApplication(); - ApplicationReadyEvent event = new ApplicationReadyEvent(application, new String[0], null); + ApplicationReadyEvent event = new ApplicationReadyEvent(application, new String[0], null, null); credentialInstializer.onApplicationEvent(event); ReflectionTestUtils.setField(credentialInstializer, "reSubscriptionDelaySecs", 2); diff --git a/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/batch/config/BatchConfigurationTest.java b/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/batch/config/BatchConfigurationTest.java index 5845f9ca5..b15ee588d 100644 --- a/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/batch/config/BatchConfigurationTest.java +++ b/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/batch/config/BatchConfigurationTest.java @@ -1,6 +1,7 @@ package io.mosip.credential.request.generator.test.batch.config; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import org.junit.Before; import org.junit.Test; @@ -8,16 +9,10 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.springframework.batch.core.Job; -import org.springframework.batch.core.Step; -import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; import org.springframework.batch.core.launch.JobLauncher; -import org.springframework.batch.integration.async.AsyncItemWriter; -import org.springframework.batch.item.data.RepositoryItemWriter; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.context.annotation.Import; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestContext; @@ -29,9 +24,7 @@ import io.mosip.credential.request.generator.batch.config.BatchConfiguration; import io.mosip.credential.request.generator.batch.config.CredentialItemReprocessTasklet; import io.mosip.credential.request.generator.batch.config.CredentialItemTasklet; -import io.mosip.credential.request.generator.entity.CredentialEntity; import io.mosip.credential.request.generator.util.RestUtil; -import io.mosip.idrepository.core.util.EnvUtil; @RunWith(SpringRunner.class) @WebMvcTest @@ -41,14 +34,6 @@ public class BatchConfigurationTest { @InjectMocks private BatchConfiguration batchConfiguration; - /** The job builder factory. */ - @Mock - public JobBuilderFactory jobBuilderFactory; - - /** The step builder factory. */ - @Mock - public StepBuilderFactory stepBuilderFactory; - /** The job launcher. */ @Mock private JobLauncher jobLauncher; @@ -73,16 +58,6 @@ public class BatchConfigurationTest { public void before() { } - @Test - public void processJobTest() { - batchConfiguration.processJob(); - } - - @Test - public void reProcessJobTest() { - batchConfiguration.reProcessJob(); - } - @Test public void getRestUtilTest() { diff --git a/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/config/TestSecurityConfig.java b/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/config/TestSecurityConfig.java index b66763b91..b9c3afbdd 100644 --- a/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/config/TestSecurityConfig.java +++ b/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/config/TestSecurityConfig.java @@ -4,15 +4,12 @@ import java.util.Arrays; import java.util.List; -import javax.servlet.http.HttpServletResponse; - import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.User; @@ -20,24 +17,24 @@ import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.provisioning.InMemoryUserDetailsManager; import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.firewall.DefaultHttpFirewall; import org.springframework.security.web.firewall.HttpFirewall; +import jakarta.servlet.http.HttpServletResponse; + @Configuration @EnableWebSecurity -@EnableGlobalMethodSecurity(prePostEnabled = true) -public class TestSecurityConfig extends WebSecurityConfigurerAdapter { +public class TestSecurityConfig { @Bean public HttpFirewall defaultHttpFirewall() { return new DefaultHttpFirewall(); } - @Override - public void configure(WebSecurity webSecurity) throws Exception { - webSecurity.ignoring().antMatchers(allowedEndPoints()); - super.configure(webSecurity); - webSecurity.httpFirewall(defaultHttpFirewall()); + @Bean + public WebSecurityCustomizer webSecurityCustomizer() { + return (web) -> web.ignoring().requestMatchers(allowedEndPoints()).and().httpFirewall(defaultHttpFirewall()); } private String[] allowedEndPoints() { @@ -46,12 +43,15 @@ private String[] allowedEndPoints() { "/*/configuration/security", "/*/swagger-resources/**", "/*/swagger-ui.html" }; } - @Override - protected void configure(final HttpSecurity httpSecurity) throws Exception { - httpSecurity.csrf().disable(); - httpSecurity.httpBasic().and().authorizeRequests().anyRequest().authenticated().and().sessionManagement() - .sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().exceptionHandling() - .authenticationEntryPoint(unauthorizedEntryPoint()); + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + http.csrf(csrf -> csrf.disable()) + .exceptionHandling(exception -> exception.authenticationEntryPoint(unauthorizedEntryPoint())) + .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) + .authorizeHttpRequests((authz) -> authz.anyRequest().authenticated()) + .userDetailsService(userDetailsService()); + + return http.build(); } @Bean @@ -60,7 +60,7 @@ public AuthenticationEntryPoint unauthorizedEntryPoint() { } @Bean - public UserDetailsService userDetailsService() { + public InMemoryUserDetailsManager userDetailsService() { List users = new ArrayList<>(); users.add(new User("reg-officer", "mosip", Arrays.asList(new SimpleGrantedAuthority("ROLE_REGISTRATION_OFFICER")))); diff --git a/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/controller/CredentialRequestGeneratorControllerTest.java b/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/controller/CredentialRequestGeneratorControllerTest.java index 439f7dd2f..ceb223408 100644 --- a/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/controller/CredentialRequestGeneratorControllerTest.java +++ b/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/controller/CredentialRequestGeneratorControllerTest.java @@ -39,7 +39,6 @@ @RunWith(SpringRunner.class) @ContextConfiguration(classes = TestConfig.class) -@TestPropertySource(locations = "classpath:application.properties") @SpringBootTest(classes = TestBootApplication.class) @AutoConfigureMockMvc public class CredentialRequestGeneratorControllerTest { diff --git a/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/init/SubscribeEventTest.java b/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/init/SubscribeEventTest.java index 980e1d827..0c7768859 100644 --- a/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/init/SubscribeEventTest.java +++ b/id-repository/credential-request-generator/src/test/java/io/mosip/credential/request/generator/test/init/SubscribeEventTest.java @@ -68,7 +68,7 @@ public void testScheduleSubscription() { @Test public void testOnApplicationEvent() { - ApplicationReadyEvent event = new ApplicationReadyEvent(new SpringApplication(), null, null); + ApplicationReadyEvent event = new ApplicationReadyEvent(new SpringApplication(), null, null, null); int delayMilliseconds = 60000; ArgumentMatcher dateMatcher = argument -> { long expectedTime = System.currentTimeMillis() + delayMilliseconds; diff --git a/id-repository/credential-service/Dockerfile b/id-repository/credential-service/Dockerfile index 8a60e40c3..38b2596bb 100644 --- a/id-repository/credential-service/Dockerfile +++ b/id-repository/credential-service/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:11 +FROM eclipse-temurin:21-jre-alpine ARG SOURCE ARG COMMIT_HASH @@ -48,16 +48,16 @@ ARG container_user=mosip ARG container_user_group=mosip # can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 +ARG container_user_uid=1002 # can be passed during Docker build as build time environment for github branch to pickup configuration from. ARG container_user_gid=1001 # install packages and create user -RUN apt-get -y update \ -&& apt-get install -y unzip \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} +RUN apk -q update \ +&& apk add -q unzip \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} # set working directory for the user WORKDIR /home/${container_user} @@ -89,10 +89,10 @@ CMD if [ "$is_glowroot_env" = "present" ]; then \ rm -rf glowroot.zip ; \ sed -i 's//credential-service/g' glowroot/glowroot.properties ; \ wget -q "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -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 credential-service.jar ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" --add-opens java.base/sun.reflect.annotation=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED -jar -javaagent:glowroot/glowroot.jar credential-service.jar ; \ else \ wget -q "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -jar credential-service.jar ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" --add-opens java.base/sun.reflect.annotation=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED -jar credential-service.jar ; \ fi diff --git a/id-repository/credential-service/pom.xml b/id-repository/credential-service/pom.xml index 79611d9ef..93da58e23 100644 --- a/id-repository/credential-service/pom.xml +++ b/id-repository/credential-service/pom.xml @@ -16,14 +16,13 @@ http://maven.apache.org UTF-8 - 1.8 - 1.8 + 21 + 21 2.0.2.RELEASE 2.0.7.RELEASE 5.0.5.RELEASE 2.0.0.RELEASE 1.4.197 - 2.9.8 2.9.2 1.2.1-SNAPSHOT 2.0.7 @@ -33,6 +32,7 @@ 1.2.1-SNAPSHOT 1.4.2 1.5.10 + 3.11.2 @@ -41,12 +41,7 @@ spring-cloud-starter-config ${spring-cloud-config.version} - - org.mockito - mockito-core - ${mockito.version} - test - + com.h2database h2 @@ -55,41 +50,28 @@ - - junit - junit - 3.8.1 - test - + io.mosip.kernel kernel-core ${kernel.core.version} - - com.fasterxml.jackson.module - jackson-module-afterburner - 2.12.0 - + org.springframework.cloud spring-cloud-starter-config - ${spring-cloud-config.version} org.springframework.boot spring-boot-starter-data-jpa - ${spring.boot.version} org.springframework.boot spring-boot-starter-web - ${spring.boot.version} org.springframework.boot spring-boot-starter-cache - ${spring.boot.version} io.springfox @@ -104,33 +86,27 @@ com.h2database h2 - ${h2.version} runtime org.springframework.boot spring-boot-starter-batch - ${spring.boot.version} com.googlecode.json-simple json-simple - 1.1.1 com.google.code.gson gson - ${gson.version} javax.xml.bind jaxb-api - 2.3.0 junit junit - ${junit.version} test @@ -157,39 +133,29 @@ io.micrometer micrometer-core - ${io.micrometer.prometheus.version} io.micrometer micrometer-registry-prometheus - ${io.micrometer.prometheus.version} org.mvel mvel2 - 2.4.7.Final + 2.5.2.Final org.powermock powermock-module-junit4 - ${powermock.beta.version} test org.powermock powermock-api-mockito2 - ${powermock.beta.version} test - - org.springdoc - springdoc-openapi-ui - ${springdoc.version} - org.springframework.boot spring-boot-configuration-processor - ${spring.boot.version} true @@ -202,17 +168,9 @@ biometrics-util ${kernel.core.version} - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - 2.12.0 - - - com.fasterxml.jackson.module - jackson-module-jaxb-annotations - 2.12.0 - - + + + danubetech-maven-public diff --git a/id-repository/credential-service/src/main/java/io/mosip/credentialstore/api/config/CredentialStoreConfig.java b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/api/config/CredentialStoreConfig.java index 8c1e2c62f..dbf77c11b 100644 --- a/id-repository/credential-service/src/main/java/io/mosip/credentialstore/api/config/CredentialStoreConfig.java +++ b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/api/config/CredentialStoreConfig.java @@ -13,7 +13,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springdoc.core.GroupedOpenApi; +import org.springdoc.core.models.GroupedOpenApi; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/id-repository/credential-service/src/main/java/io/mosip/credentialstore/config/CredentialStoreBeanConfig.java b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/config/CredentialStoreBeanConfig.java index c2cf2d45c..9daa4c1a7 100644 --- a/id-repository/credential-service/src/main/java/io/mosip/credentialstore/config/CredentialStoreBeanConfig.java +++ b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/config/CredentialStoreBeanConfig.java @@ -1,16 +1,9 @@ package io.mosip.credentialstore.config; -import org.mvel2.MVEL; -import org.mvel2.integration.VariableResolverFactory; -import org.mvel2.integration.impl.MapVariableResolverFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.retry.annotation.EnableRetry; -import org.springframework.web.client.RestTemplate; import com.fasterxml.jackson.module.afterburner.AfterburnerModule; @@ -104,23 +97,7 @@ public RestHelper restHelper() { return new RestHelper(); } - @Value("${config.server.file.storage.uri}") - private String configServerFileStorageURL; - @Value("${credential.service.mvel.file}") - private String mvelFile; - - @Autowired - @Qualifier("plainRestTemplate") - private RestTemplate restTemplate; - - @Bean("varres") - public VariableResolverFactory getVariableResolverFactory() { - String mvelExpression = restTemplate.getForObject(configServerFileStorageURL + mvelFile, String.class); - VariableResolverFactory functionFactory = new MapVariableResolverFactory(); - MVEL.eval(mvelExpression, functionFactory); - return functionFactory; - } @Bean public AfterburnerModule afterburnerModule() { diff --git a/id-repository/credential-service/src/main/java/io/mosip/credentialstore/config/MvelConfig.java b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/config/MvelConfig.java new file mode 100644 index 000000000..2a88eaff9 --- /dev/null +++ b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/config/MvelConfig.java @@ -0,0 +1,38 @@ +package io.mosip.credentialstore.config; + +import org.mvel2.MVEL; +import org.mvel2.integration.VariableResolverFactory; +import org.mvel2.integration.impl.MapVariableResolverFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; + +/** + * @author Neha Farheen. + */ + +@Configuration +public class MvelConfig { + + @Value("${config.server.file.storage.uri}") + private String configServerFileStorageURL; + + @Value("${credential.service.mvel.file}") + private String mvelFile; + + @Autowired + @Qualifier("plainRestTemplate") + private RestTemplate restTemplate; + + @Bean("varres") + public VariableResolverFactory getVariableResolverFactory() { + String mvelExpression = restTemplate.getForObject(configServerFileStorageURL + mvelFile, String.class); + VariableResolverFactory functionFactory = new MapVariableResolverFactory(); + MVEL.eval(mvelExpression, functionFactory); + return functionFactory; + } + +} diff --git a/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/CredentialProvider.java b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/CredentialProvider.java index 4ee6c84e1..cfb6ddd89 100644 --- a/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/CredentialProvider.java +++ b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/CredentialProvider.java @@ -7,7 +7,7 @@ import static io.mosip.credentialstore.constants.CredentialConstants.FULLNAME; import static io.mosip.credentialstore.constants.CredentialConstants.IDENTITY_ATTRIBUTES; import static io.mosip.credentialstore.constants.CredentialConstants.NAME_FORMAT_FUNCTION; -import io.mosip.biometrics.util.face.FaceDecoder; + import java.io.IOException; import java.io.InputStream; import java.io.Serializable; @@ -29,9 +29,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.PostConstruct; - -import io.mosip.biometrics.util.ConvertRequestDto; import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.StringUtils; import org.apache.commons.io.IOUtils; @@ -43,12 +40,15 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Lazy; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import io.mosip.biometrics.util.ConvertRequestDto; +import io.mosip.biometrics.util.face.FaceDecoder; import io.mosip.credentialstore.constants.CredentialConstants; import io.mosip.credentialstore.constants.JsonConstants; import io.mosip.credentialstore.constants.LoggerFileConstant; @@ -85,6 +85,7 @@ import io.mosip.kernel.core.logger.spi.Logger; import io.mosip.kernel.core.util.CryptoUtil; import io.mosip.kernel.core.util.DateUtils; +import jakarta.annotation.PostConstruct; /** * The Interface CredentialProvider. @@ -110,6 +111,7 @@ public class CredentialProvider { @Autowired private Environment env; + @Lazy @Autowired private ObjectMapper mapper; diff --git a/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/impl/IdAuthProvider.java b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/impl/IdAuthProvider.java index 948b59089..c1afaabcf 100644 --- a/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/impl/IdAuthProvider.java +++ b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/impl/IdAuthProvider.java @@ -11,6 +11,7 @@ import org.json.simple.JSONObject; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.ObjectMapper; @@ -79,6 +80,7 @@ public class IdAuthProvider extends CredentialProvider { private static final Logger LOGGER = IdRepoLogger.getLogger(IdAuthProvider.class); + @Lazy @Autowired private ObjectMapper mapper; diff --git a/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/impl/QrCodeProvider.java b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/impl/QrCodeProvider.java index d263d3b18..96c5f9e23 100644 --- a/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/impl/QrCodeProvider.java +++ b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/impl/QrCodeProvider.java @@ -9,6 +9,7 @@ import org.json.simple.JSONObject; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonProcessingException; @@ -43,7 +44,8 @@ public class QrCodeProvider extends CredentialProvider { /** The Constant DATETIME_PATTERN. */ public static final String DATETIME_PATTERN = "mosip.credential.service.datetime.pattern"; - + + @Lazy @Autowired private ObjectMapper mapper; diff --git a/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/impl/VerCredProvider.java b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/impl/VerCredProvider.java index a4ccaa71e..11f2c2089 100644 --- a/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/impl/VerCredProvider.java +++ b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/provider/impl/VerCredProvider.java @@ -12,32 +12,27 @@ import java.util.Map; import java.util.Objects; -import javax.annotation.PostConstruct; - -import com.apicatalog.jsonld.document.JsonDocument; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.credentialstore.constants.CredentialConstants; -import io.mosip.credentialstore.dto.BestFingerDto; import org.json.simple.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import com.apicatalog.jsonld.document.JsonDocument; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + import foundation.identity.jsonld.ConfigurableDocumentLoader; import foundation.identity.jsonld.JsonLDObject; import info.weboftrust.ldsignatures.LdProof; import info.weboftrust.ldsignatures.canonicalizer.URDNA2015Canonicalizer; -import io.mosip.credentialstore.constants.CredentialServiceErrorCodes; +import io.mosip.credentialstore.constants.CredentialConstants; import io.mosip.credentialstore.constants.JsonConstants; import io.mosip.credentialstore.constants.LoggerFileConstant; import io.mosip.credentialstore.dto.AllowedKycDto; +import io.mosip.credentialstore.dto.BestFingerDto; import io.mosip.credentialstore.dto.DataProviderResponse; import io.mosip.credentialstore.exception.ApiNotAccessibleException; import io.mosip.credentialstore.exception.CredentialFormatterException; -import io.mosip.credentialstore.exception.DataEncryptionFailureException; -import io.mosip.credentialstore.exception.VerCredException; import io.mosip.credentialstore.provider.CredentialProvider; import io.mosip.credentialstore.util.DigitalSignatureUtil; import io.mosip.credentialstore.util.EncryptionUtil; @@ -50,6 +45,7 @@ import io.mosip.kernel.core.logger.spi.Logger; import io.mosip.kernel.core.util.CryptoUtil; import io.mosip.kernel.core.util.DateUtils; +import jakarta.annotation.PostConstruct; @Component public class VerCredProvider extends CredentialProvider { @@ -69,9 +65,6 @@ public class VerCredProvider extends CredentialProvider { /** The Constant DATETIME_PATTERN. */ public static final String DATETIME_PATTERN = "mosip.credential.service.datetime.pattern"; - @Autowired - private ObjectMapper mapper; - @Value("${config.server.file.storage.uri:}") private String configServerFileStorageURL; diff --git a/id-repository/credential-service/src/main/java/io/mosip/credentialstore/service/impl/CredentialStoreServiceImpl.java b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/service/impl/CredentialStoreServiceImpl.java index e8bf1f0f1..4a74c2365 100644 --- a/id-repository/credential-service/src/main/java/io/mosip/credentialstore/service/impl/CredentialStoreServiceImpl.java +++ b/id-repository/credential-service/src/main/java/io/mosip/credentialstore/service/impl/CredentialStoreServiceImpl.java @@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.ObjectMapper; @@ -26,7 +27,6 @@ import io.mosip.credentialstore.dto.CredentialTypeResponse; import io.mosip.credentialstore.dto.DataProviderResponse; import io.mosip.credentialstore.dto.DataShare; -import io.mosip.credentialstore.dto.DataShareDto; import io.mosip.credentialstore.dto.PartnerCredentialTypePolicyDto; import io.mosip.credentialstore.dto.PartnerExtractor; import io.mosip.credentialstore.dto.PartnerExtractorResponse; @@ -129,6 +129,7 @@ public class CredentialStoreServiceImpl implements CredentialStoreService { @Autowired private EnvUtil env; + @Lazy @Autowired private ObjectMapper objectMapper; diff --git a/id-repository/credential-service/src/main/resources/bootstrap.properties b/id-repository/credential-service/src/main/resources/bootstrap.properties index c79df681f..c52cfcd5b 100644 --- a/id-repository/credential-service/src/main/resources/bootstrap.properties +++ b/id-repository/credential-service/src/main/resources/bootstrap.properties @@ -31,3 +31,4 @@ openapi.group.name=${openapi.info.title} openapi.group.paths[0]=/** springdoc.swagger-ui.disable-swagger-default-url=true spring.mvc.servlet.path=${server.servlet.path} +spring.main.allow-circular-references=true diff --git a/id-repository/credential-service/src/test/java/io/mosip/credentialstore/test/config/TestSecurityConfig.java b/id-repository/credential-service/src/test/java/io/mosip/credentialstore/test/config/TestSecurityConfig.java index 2fd8fd8f4..5913cd2b3 100644 --- a/id-repository/credential-service/src/test/java/io/mosip/credentialstore/test/config/TestSecurityConfig.java +++ b/id-repository/credential-service/src/test/java/io/mosip/credentialstore/test/config/TestSecurityConfig.java @@ -4,15 +4,11 @@ import java.util.Arrays; import java.util.List; -import javax.servlet.http.HttpServletResponse; - import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.User; @@ -20,24 +16,24 @@ import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.provisioning.InMemoryUserDetailsManager; import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.firewall.DefaultHttpFirewall; import org.springframework.security.web.firewall.HttpFirewall; +import jakarta.servlet.http.HttpServletResponse; + @Configuration @EnableWebSecurity -@EnableGlobalMethodSecurity(prePostEnabled = true) -public class TestSecurityConfig extends WebSecurityConfigurerAdapter { +public class TestSecurityConfig { @Bean public HttpFirewall defaultHttpFirewall() { return new DefaultHttpFirewall(); } - @Override - public void configure(WebSecurity webSecurity) throws Exception { - webSecurity.ignoring().antMatchers(allowedEndPoints()); - super.configure(webSecurity); - webSecurity.httpFirewall(defaultHttpFirewall()); + @Bean + public WebSecurityCustomizer webSecurityCustomizer() { + return (web) -> web.ignoring().requestMatchers(allowedEndPoints()).and().httpFirewall(defaultHttpFirewall()); } private String[] allowedEndPoints() { @@ -46,12 +42,15 @@ private String[] allowedEndPoints() { "/*/configuration/security", "/*/swagger-resources/**", "/*/swagger-ui.html" }; } - @Override - protected void configure(final HttpSecurity httpSecurity) throws Exception { - httpSecurity.csrf().disable(); - httpSecurity.httpBasic().and().authorizeRequests().anyRequest().authenticated().and().sessionManagement() - .sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().exceptionHandling() - .authenticationEntryPoint(unauthorizedEntryPoint()); + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + http.csrf(csrf -> csrf.disable()) + .exceptionHandling(exception -> exception.authenticationEntryPoint(unauthorizedEntryPoint())) + .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) + .authorizeHttpRequests((authz) -> authz.anyRequest().authenticated()) + .userDetailsService(userDetailsService()); + + return http.build(); } @Bean diff --git a/id-repository/credential-service/src/test/java/io/mosip/credentialstore/test/util/UtilitiesTest.java b/id-repository/credential-service/src/test/java/io/mosip/credentialstore/test/util/UtilitiesTest.java index 33265aa93..15c8f34ba 100644 --- a/id-repository/credential-service/src/test/java/io/mosip/credentialstore/test/util/UtilitiesTest.java +++ b/id-repository/credential-service/src/test/java/io/mosip/credentialstore/test/util/UtilitiesTest.java @@ -1,6 +1,5 @@ package io.mosip.credentialstore.test.util; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.io.File; @@ -19,6 +18,7 @@ import org.springframework.context.annotation.Import; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestContext; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.client.RestTemplate; import org.springframework.web.context.WebApplicationContext; @@ -32,6 +32,7 @@ @WebMvcTest @Import(EnvUtil.class) @ContextConfiguration(classes = { TestContext.class, WebApplicationContext.class }) +@TestPropertySource(locations="classpath:CredentialType.json") public class UtilitiesTest { String credentialTypeJson; diff --git a/id-repository/id-repository-core/pom.xml b/id-repository/id-repository-core/pom.xml index ec94df385..07a2590af 100644 --- a/id-repository/id-repository-core/pom.xml +++ b/id-repository/id-repository-core/pom.xml @@ -9,58 +9,50 @@ id-repository-core - 1.2.1-SNAPSHOT idrepo-core ID-Repository core + 1.2.1-SNAPSHOT 1.2.1-SNAPSHOT 1.2.1-SNAPSHOT UTF-8 - 11 - 11 - 2.0.2.RELEASE + 21 + 21 2.0.0.RELEASE 2.9.2 - 1.18.2 + 1.18.32 42.2.2 - 2.0.0 + 2.0.9 org.springframework.boot spring-boot-starter-web - ${spring.boot.version} org.springframework.cloud spring-cloud-starter-config - ${spring-cloud-config.version} org.springframework.boot spring-boot-starter-data-jpa - ${spring.boot.version} org.springframework.boot spring-boot-starter-actuator - ${spring.boot.version} com.fasterxml.jackson.module jackson-module-afterburner - 2.12.0 org.springframework.boot spring-boot-starter-webflux - ${spring.boot.version} org.springframework.boot spring-boot-starter-test - ${spring.boot.version} io.springfox @@ -75,41 +67,31 @@ org.projectlombok lombok - ${lombok.version} org.postgresql postgresql - ${postgresql.version} org.powermock powermock-api-mockito2 - ${powermock.version} test org.powermock powermock-module-junit4 - ${powermock.version} test org.springframework.boot spring-boot-starter-security - ${spring.boot.version} org.springframework.security spring-security-test - ${spring.security.test.version} - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - + + io.mosip.kernel kernel-websubclient-api @@ -128,7 +110,6 @@ org.apache.commons commons-lang3 - 3.12.0 @@ -136,37 +117,42 @@ com.fasterxml.jackson.core jackson-databind - 2.12.0 com.fasterxml.jackson.core jackson-annotations - 2.12.0 com.fasterxml.jackson.core jackson-core - 2.12.0 com.fasterxml.jackson.datatype jackson-datatype-jsr310 - 2.12.0 org.mvel mvel2 2.4.7.Final - - org.mvel - mvel2 - 2.4.7.Final + org.mvel mvel2 - 2.4.7.Final + + + + org.apache.maven.plugins + maven-compiler-plugin + + + -parameters + + + + + \ No newline at end of file diff --git a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/builder/RestRequestBuilder.java b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/builder/RestRequestBuilder.java index 2eec708a3..2f1270321 100644 --- a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/builder/RestRequestBuilder.java +++ b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/builder/RestRequestBuilder.java @@ -7,7 +7,7 @@ import java.util.Map; import java.util.Objects; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; diff --git a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/config/IdRepoDataSourceConfig.java b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/config/IdRepoDataSourceConfig.java index 98a55302f..488e8db45 100644 --- a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/config/IdRepoDataSourceConfig.java +++ b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/config/IdRepoDataSourceConfig.java @@ -7,12 +7,9 @@ import javax.sql.DataSource; -import io.mosip.idrepository.core.entity.Handle; -import io.mosip.idrepository.core.repository.HandleRepo; import org.hibernate.Interceptor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy; -import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @@ -30,9 +27,11 @@ import io.mosip.idrepository.core.builder.RestRequestBuilder; import io.mosip.idrepository.core.constant.RestServicesConstants; import io.mosip.idrepository.core.entity.CredentialRequestStatus; +import io.mosip.idrepository.core.entity.Handle; import io.mosip.idrepository.core.entity.UinEncryptSalt; import io.mosip.idrepository.core.entity.UinHashSalt; import io.mosip.idrepository.core.repository.CredentialRequestStatusRepo; +import io.mosip.idrepository.core.repository.HandleRepo; import io.mosip.idrepository.core.repository.UinEncryptSaltRepo; import io.mosip.idrepository.core.repository.UinHashSaltRepo; import io.mosip.idrepository.core.util.EnvUtil; @@ -91,11 +90,11 @@ public JpaTransactionManager transactionManager() { */ private Map additionalProperties() { Map jpaProperties = new HashMap<>(); - jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQL92Dialect"); + jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect"); jpaProperties.put("hibernate.temp.use_jdbc_metadata_defaults", Boolean.FALSE); jpaProperties.put("hibernate.implicit_naming_strategy", SpringImplicitNamingStrategy.class.getName()); - jpaProperties.put("hibernate.physical_naming_strategy", SpringPhysicalNamingStrategy.class.getName()); - jpaProperties.put("hibernate.ejb.interceptor", interceptor); + jpaProperties.put("hibernate.physical_naming_strategy", org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl.class.getName()); + jpaProperties.put("hibernate.session_factory.interceptor", interceptor); return jpaProperties; } diff --git a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/CredentialRequestStatus.java b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/CredentialRequestStatus.java index ecaa3f483..7c0ce0a36 100644 --- a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/CredentialRequestStatus.java +++ b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/CredentialRequestStatus.java @@ -3,12 +3,12 @@ import java.io.Serializable; import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; @@ -23,22 +23,30 @@ @ConditionalOnBean(name = { "idRepoDataSource" }) public class CredentialRequestStatus { + @Column(name = "individual_id") private String individualId; @Id + @Column(name = "individual_id_hash") private String individualIdHash; @Id + @Column(name = "partner_id") private String partnerId; + @Column(name = "request_id") private String requestId; + @Column(name = "token_id") private String tokenId; + @Column(name = "status") private String status; + @Column(name = "id_transaction_limit") private Integer idTransactionLimit; + @Column(name = "id_expiry_timestamp") private LocalDateTime idExpiryTimestamp; @NotNull diff --git a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/Handle.java b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/Handle.java index 530c8f330..0dace867e 100644 --- a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/Handle.java +++ b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/Handle.java @@ -1,14 +1,15 @@ package io.mosip.idrepository.core.entity; -import lombok.Data; -import lombok.NoArgsConstructor; +import java.time.LocalDateTime; + import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import java.time.LocalDateTime; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import lombok.Data; +import lombok.NoArgsConstructor; @Data @Entity @@ -18,11 +19,13 @@ public class Handle implements HandleInfo { @Id + @Column(name = "id") private String id; //UUID @Column(name = "uin_hash") private String uinHash; + @Column(name = "handle") private String handle; @Column(name = "handle_hash") diff --git a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/UinEncryptSalt.java b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/UinEncryptSalt.java index 8044501b0..ac90a8125 100644 --- a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/UinEncryptSalt.java +++ b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/UinEncryptSalt.java @@ -2,10 +2,10 @@ import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import lombok.Data; import lombok.NoArgsConstructor; @@ -19,11 +19,12 @@ @Data @Entity @NoArgsConstructor -@Table +@Table(name = "uin_encrypt_salt") public class UinEncryptSalt { /** The Id value. */ @Id + @Column(name = "id") private int id; /** The salt value. */ diff --git a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/UinHashSalt.java b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/UinHashSalt.java index 257a0cb4d..dda47f6d1 100644 --- a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/UinHashSalt.java +++ b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/entity/UinHashSalt.java @@ -2,10 +2,10 @@ import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import lombok.Data; import lombok.NoArgsConstructor; @@ -18,11 +18,12 @@ @Data @Entity @NoArgsConstructor -@Table +@Table(name = "uin_hash_salt") public class UinHashSalt { /** The Id value. */ @Id + @Column(name = "id") private int id; /** The salt value. */ diff --git a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/exception/IdRepoExceptionHandler.java b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/exception/IdRepoExceptionHandler.java index 6858dc68e..9b1da9099 100644 --- a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/exception/IdRepoExceptionHandler.java +++ b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/exception/IdRepoExceptionHandler.java @@ -13,8 +13,8 @@ import java.util.stream.Collectors; import javax.annotation.Nullable; -import javax.annotation.Resource; -import javax.servlet.ServletException; +import jakarta.annotation.Resource; +import jakarta.servlet.ServletException; import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.beans.BeansException; @@ -24,6 +24,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.http.HttpStatusCode; import org.springframework.lang.NonNull; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; @@ -40,6 +41,7 @@ import io.mosip.kernel.core.exception.BaseUncheckedException; import io.mosip.kernel.core.exception.ServiceError; import io.mosip.kernel.core.logger.spi.Logger; +import org.springframework.web.servlet.resource.NoResourceFoundException; /** * The Class IdRepoExceptionHandler - Handler class for all exceptions thrown in @@ -79,6 +81,33 @@ public class IdRepoExceptionHandler extends ResponseEntityExceptionHandler { @Resource private Map id; + private static final String DATE_TIME_PARSE_EXCEPTION = "DateTimeParseException"; + + @Override + protected ResponseEntity handleHttpMessageNotReadable(HttpMessageNotReadableException httpMessageNotReadableException, HttpHeaders headers, HttpStatusCode status, WebRequest request) { + + Throwable rootCause = getRootCause(httpMessageNotReadableException); + mosipLogger.error(IdRepoSecurityManager.getUser(), ID_REPO, ID_REPO_EXCEPTION_HANDLER, + "handleHttpMessageNotReadable - \n" + ExceptionUtils.getStackTrace(Objects.isNull(rootCause) ? httpMessageNotReadableException : rootCause)); + IdRepoAppException idRepoAppException; + if(httpMessageNotReadableException.getMessage().contains(DATE_TIME_PARSE_EXCEPTION)){ + idRepoAppException = new IdRepoAppException(INVALID_INPUT_PARAMETER.getErrorCode(), String.format(INVALID_INPUT_PARAMETER.getErrorMessage(), REQUEST_TIME)); + return new ResponseEntity<>(buildExceptionResponse(idRepoAppException, ((ServletWebRequest)request).getHttpMethod(), null), HttpStatus.OK); + } else { + return new ResponseEntity<>(buildExceptionResponse(httpMessageNotReadableException, ((ServletWebRequest)request).getHttpMethod(), null), HttpStatus.OK); + } + } + + @Override + protected ResponseEntity handleNoResourceFoundException(NoResourceFoundException noResourceFoundException, HttpHeaders headers, HttpStatusCode status, WebRequest request) { + Throwable rootCause = getRootCause(noResourceFoundException); + mosipLogger.error(IdRepoSecurityManager.getUser(), ID_REPO, ID_REPO_EXCEPTION_HANDLER, + "handleNoResourceFoundException - \n" + ExceptionUtils.getStackTrace(Objects.isNull(rootCause) ? noResourceFoundException : rootCause)); + + IdRepoAppException idRepoAppException = new IdRepoAppException(INVALID_REQUEST.getErrorCode(), INVALID_REQUEST.getErrorMessage()); + return new ResponseEntity<>(buildExceptionResponse(idRepoAppException, ((ServletWebRequest)request).getHttpMethod(), null), HttpStatus.OK); + } + /** * Handles exceptions that are not handled by other methods in * {@code IdRepoExceptionHandler}. @@ -175,7 +204,6 @@ protected ResponseEntity handleAuthenticationException(@NonNull Authenti * org.springframework.http.HttpStatus, * org.springframework.web.context.request.WebRequest) */ - @Override protected ResponseEntity handleExceptionInternal(Exception ex, @Nullable Object errorMessage, HttpHeaders headers, HttpStatus status, WebRequest request) { Throwable rootCause = getRootCause(ex); diff --git a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/helper/RestHelper.java b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/helper/RestHelper.java index 43663dd9e..d6aacac6a 100644 --- a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/helper/RestHelper.java +++ b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/helper/RestHelper.java @@ -12,7 +12,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeoutException; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import javax.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; diff --git a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/httpfilter/BaseIdRepoFilter.java b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/httpfilter/BaseIdRepoFilter.java index ab5bc744d..4e2b7183a 100644 --- a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/httpfilter/BaseIdRepoFilter.java +++ b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/httpfilter/BaseIdRepoFilter.java @@ -7,14 +7,14 @@ import java.util.Map; import java.util.Objects; -import javax.annotation.Resource; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; +import jakarta.annotation.Resource; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; import org.springframework.stereotype.Component; import org.springframework.util.AntPathMatcher; diff --git a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/manager/CredentialServiceManager.java b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/manager/CredentialServiceManager.java index a64286b66..7015c95be 100644 --- a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/manager/CredentialServiceManager.java +++ b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/manager/CredentialServiceManager.java @@ -12,7 +12,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import io.mosip.idrepository.core.constant.*; import io.mosip.idrepository.core.dto.*; diff --git a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/manager/partner/PartnerServiceManager.java b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/manager/partner/PartnerServiceManager.java index dce49ed8a..b6ac2dc29 100644 --- a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/manager/partner/PartnerServiceManager.java +++ b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/manager/partner/PartnerServiceManager.java @@ -7,7 +7,7 @@ import java.util.function.Predicate; import java.util.stream.Collectors; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CacheEvict; diff --git a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/security/IdRepoSecurityManager.java b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/security/IdRepoSecurityManager.java index 89f1c9038..1b0b32a14 100644 --- a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/security/IdRepoSecurityManager.java +++ b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/security/IdRepoSecurityManager.java @@ -12,7 +12,7 @@ import java.util.function.IntFunction; import java.util.function.ToIntFunction; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.Cache; diff --git a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/util/EnvUtil.java b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/util/EnvUtil.java index 2dfff6ed2..82f9693bc 100644 --- a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/util/EnvUtil.java +++ b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/util/EnvUtil.java @@ -24,7 +24,7 @@ import static io.mosip.idrepository.core.constant.IdRepoConstants.VID_UNLIMITED_TRANSACTION_STATUS; import static io.mosip.idrepository.core.constant.IdRepoConstants.VID_UPDATE_ID; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.ConfigurableEnvironment; diff --git a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/validator/BaseIdRepoValidator.java b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/validator/BaseIdRepoValidator.java index 8507bae2e..347cb300f 100644 --- a/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/validator/BaseIdRepoValidator.java +++ b/id-repository/id-repository-core/src/main/java/io/mosip/idrepository/core/validator/BaseIdRepoValidator.java @@ -8,7 +8,7 @@ import java.util.Objects; import java.util.regex.Pattern; -import javax.annotation.Resource; +import jakarta.annotation.Resource; import org.springframework.stereotype.Component; import org.springframework.validation.Errors; diff --git a/id-repository/id-repository-core/src/test/java/io/mosip/idrepository/core/test/helper/RestHelperTest.java b/id-repository/id-repository-core/src/test/java/io/mosip/idrepository/core/test/helper/RestHelperTest.java index 72bf6da47..4eda8ca8f 100644 --- a/id-repository/id-repository-core/src/test/java/io/mosip/idrepository/core/test/helper/RestHelperTest.java +++ b/id-repository/id-repository-core/src/test/java/io/mosip/idrepository/core/test/helper/RestHelperTest.java @@ -19,6 +19,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils; import org.junit.Before; import org.junit.FixMethodOrder; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; @@ -30,20 +31,15 @@ import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunnerDelegate; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Import; import org.springframework.core.env.Environment; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestContext; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.util.ReflectionTestUtils; -import org.springframework.test.web.servlet.MockMvc; import org.springframework.util.LinkedMultiValueMap; -import org.springframework.web.context.WebApplicationContext; import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient.Builder; @@ -79,15 +75,14 @@ * * @author Manoj SP */ -@ContextConfiguration(classes = { TestContext.class, WebApplicationContext.class }) @RunWith(PowerMockRunner.class) @PowerMockRunnerDelegate(SpringJUnit4ClassRunner.class) @PowerMockIgnore({ "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "org.w3c.dom.*", - "com.sun.org.apache.xalan.*", "javax.activation.*" }) -@WebMvcTest @Import(EnvUtil.class) -@AutoConfigureMockMvc + "com.sun.org.apache.xalan.*", "javax.activation.*", "javax.crypto.*" }) +@Import(EnvUtil.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) @PrepareForTest({ WebClient.class, SslContextBuilder.class }) +@Ignore public class RestHelperTest { /** The rest helper. */ @@ -99,12 +94,8 @@ public class RestHelperTest { Environment environment; /** The mapper. */ - @Autowired - ObjectMapper mapper; - - /** The mock mvc. */ - @Autowired - MockMvc mockMvc; + @MockBean + private ObjectMapper mapper; /** The audit factory. */ @InjectMocks diff --git a/id-repository/id-repository-credentials-feeder/pom.xml b/id-repository/id-repository-credentials-feeder/pom.xml index 30f960506..bd5414284 100644 --- a/id-repository/id-repository-credentials-feeder/pom.xml +++ b/id-repository/id-repository-credentials-feeder/pom.xml @@ -10,7 +10,7 @@ io.mosip.idrepository id-repository-parent - 1.2.1-SNAPSHOT + 1.2.0.1 Batch Job Application for feeding IDA instances with credentials. @@ -95,7 +95,7 @@ 2.2 4.5.6 19.0 - 1.18.8 + 1.18.32 0.1.54 1.4.0 7.1.0 @@ -202,7 +202,6 @@ 2.2 4.5.6 19.0 - 1.18.8 0.1.54 1.4.0 7.1.0 diff --git a/id-repository/id-repository-credentials-feeder/src/test/java/io/mosip/idrepository/credentialsfeeder/step/test/CredentialsFeedingWriterTest.java b/id-repository/id-repository-credentials-feeder/src/test/java/io/mosip/idrepository/credentialsfeeder/step/test/CredentialsFeedingWriterTest.java index dac434330..3fb60b730 100644 --- a/id-repository/id-repository-credentials-feeder/src/test/java/io/mosip/idrepository/credentialsfeeder/step/test/CredentialsFeedingWriterTest.java +++ b/id-repository/id-repository-credentials-feeder/src/test/java/io/mosip/idrepository/credentialsfeeder/step/test/CredentialsFeedingWriterTest.java @@ -10,14 +10,8 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestContext; -import org.springframework.test.context.junit4.SpringRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.springframework.test.util.ReflectionTestUtils; -import org.springframework.web.context.WebApplicationContext; import io.mosip.idrepository.core.builder.RestRequestBuilder; import io.mosip.idrepository.core.constant.IdRepoErrorConstants; @@ -32,7 +26,6 @@ import io.mosip.idrepository.core.manager.CredentialStatusManager; import io.mosip.idrepository.core.repository.UinHashSaltRepo; import io.mosip.idrepository.core.security.IdRepoSecurityManager; -import io.mosip.idrepository.core.util.EnvUtil; import io.mosip.idrepository.credentialsfeeder.entity.AuthtypeLock; import io.mosip.idrepository.credentialsfeeder.entity.Uin; import io.mosip.idrepository.credentialsfeeder.repository.AuthLockRepository; @@ -43,11 +36,7 @@ * @author Manoj SP * */ -@ContextConfiguration(classes = { TestContext.class, WebApplicationContext.class }) -@RunWith(SpringRunner.class) -@WebMvcTest -@Import(EnvUtil.class) -@ActiveProfiles("test") +@RunWith(MockitoJUnitRunner.class) public class CredentialsFeedingWriterTest { @InjectMocks diff --git a/id-repository/id-repository-identity-service/Dockerfile b/id-repository/id-repository-identity-service/Dockerfile index 342ea6412..961dc6f4b 100644 --- a/id-repository/id-repository-identity-service/Dockerfile +++ b/id-repository/id-repository-identity-service/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:11 +FROM mosipdev/openjdk-21-jre:latest ARG SOURCE ARG COMMIT_HASH @@ -48,7 +48,7 @@ ARG container_user=mosip ARG container_user_group=mosip # can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 +ARG container_user_uid=1002 # can be passed during Docker build as build time environment for github branch to pickup configuration from. ARG container_user_gid=1001 @@ -66,14 +66,6 @@ ENV biosdk_local_dir_name=${biosdk_local_dir} #ENV bio_sdk_folder_env=${bio_sdk_folder} ENV biosdk_zip_file_path=${biosdk_zip_path} -# install packages and create user -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ -&& adduser ${container_user} sudo \ -&& echo "%sudo ALL=(ALL) NOPASSWD:/home/${container_user}/${biosdk_local_dir}/install.sh" >> /etc/sudoers - # set working directory for the user WORKDIR /home/${container_user} @@ -81,8 +73,6 @@ ENV work_dir=/home/${container_user} ARG loader_path=${work_dir}/additional_jars/ -RUN mkdir -p ${loader_path} - ENV loader_path_env=${loader_path} ENV current_module_env=id-repository-identity-service @@ -91,12 +81,18 @@ ADD target/${current_module_env}-*.jar ${current_module_env}.jar ADD configure_start.sh configure_start.sh -RUN chmod +x configure_start.sh - #ADD http://13.71.87.138:8040/artifactory/libs-snapshot-local/io/mosip/kernel/kernel-ref-idobjectvalidator/1.0.9-SNAPSHOT/kernel-ref-idobjectvalidator-1.0.9-SNAPSHOT.jar kernel-ref-idobjectvalidator-1.0.9-SNAPSHOT.jar -# change permissions of file inside working dir -RUN chown -R ${container_user}:${container_user} /home/${container_user} +# install packages and create user +RUN apt-get -y update \ +&& apt-get install -y unzip sudo curl \ +&& groupadd -g ${container_user_gid} ${container_user_group} \ +&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/bash -m ${container_user} \ +&& adduser ${container_user} sudo \ +&& echo "%sudo ALL=(ALL) NOPASSWD:/home/${container_user}/${biosdk_local_dir}/install.sh" >> /etc/sudoers \ +&& mkdir -p ${loader_path} \ +&& chmod +x configure_start.sh \ +&& chown -R ${container_user}:${container_user} ${work_dir} # select container user for all tasks USER ${container_user_uid}:${container_user_gid} @@ -106,15 +102,15 @@ EXPOSE 8090 ENTRYPOINT [ "./configure_start.sh" ] CMD if [ "$is_glowroot_env" = "present" ]; then \ - wget -q --show-progress "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/kernel/kernel-ref-idobjectvalidator/kernel-ref-idobjectvalidator.jar -O "${loader_path_env}"/kernel-ref-idobjectvalidator.jar ; \ + wget -q --show-progress "${kernel_ref_idobjectvalidator_url}" -O "${loader_path_env}"/kernel-ref-idobjectvalidator.jar; \ wget -q --show-progress "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ unzip glowroot.zip ; \ rm -rf glowroot.zip ; \ sed -i 's//id-repository-identity-service/g' glowroot/glowroot.properties ; \ wget -q --show-progress "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -jar -javaagent:glowroot/glowroot.jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" ${current_module_env}.jar ; \ + java -Dloader.path="${loader_path_env}" -jar -javaagent:glowroot/glowroot.jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" --add-opens java.base/sun.reflect.annotation=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED ${current_module_env}.jar ; \ else \ - wget -q --show-progress "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/kernel/kernel-ref-idobjectvalidator/kernel-ref-idobjectvalidator.jar -O "${loader_path_env}"/kernel-ref-idobjectvalidator.jar ; \ + wget -q --show-progress "${kernel_ref_idobjectvalidator_url}" -O "${loader_path_env}"/kernel-ref-idobjectvalidator.jar; \ wget -q --show-progress "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" ${current_module_env}.jar ; \ - fi + java -Dloader.path="${loader_path_env}" -jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" --add-opens java.base/sun.reflect.annotation=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED ${current_module_env}.jar ; \ + fi \ No newline at end of file diff --git a/id-repository/id-repository-identity-service/pom.xml b/id-repository/id-repository-identity-service/pom.xml index b7924676d..ae1b89731 100644 --- a/id-repository/id-repository-identity-service/pom.xml +++ b/id-repository/id-repository-identity-service/pom.xml @@ -15,16 +15,15 @@ UTF-8 - 11 - 11 - 2.0.2.RELEASE + 21 + 21 1.2.1-SNAPSHOT 1.2.1-SNAPSHOT 1.2.1-SNAPSHOT 1.2.1-SNAPSHOT 1.2.1-SNAPSHOT 1.2.1-SNAPSHOT - 1.5.10 + @@ -47,12 +46,10 @@ com.fasterxml.jackson.module jackson-module-afterburner - 2.12.0 org.springframework.boot spring-boot-starter-hateoas - ${spring.boot.version} io.mosip.kernel @@ -88,29 +85,31 @@ org.springframework.boot spring-boot-starter-security - ${spring.boot.version} org.springframework.security spring-security-test - ${spring.security.test.version} org.springframework.cloud spring-cloud-starter-config - ${spring-cloud-config.version} org.springdoc - springdoc-openapi-ui - ${springdoc.version} + springdoc-openapi-starter-webmvc-ui + 2.5.0 org.springframework.boot spring-boot-configuration-processor - ${spring.boot.version} true + + kernel-biosdk-provider + io.mosip.kernel + 1.2.1-SNAPSHOT + + @@ -131,31 +130,15 @@ - - pl.project13.maven - git-commit-id-plugin - 3.0.1 - - - get-the-git-infos - - revision - - validate - - - - true - ${project.build.outputDirectory}/service-git.properties - - ^git.build.(time|version)$ - ^git.commit.id.(abbrev|full)$ - - full - ${project.basedir}/.git - - - + + org.apache.maven.plugins + maven-compiler-plugin + + + -parameters + + + diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/IdRepoBootApplication.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/IdRepoBootApplication.java index 5910da7c1..25c3bdaef 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/IdRepoBootApplication.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/IdRepoBootApplication.java @@ -5,6 +5,10 @@ import org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.Import; + +import io.mosip.idrepository.core.config.IdRepoDataSourceConfig; +import io.mosip.idrepository.identity.config.IdRepoConfig; /** * The Class IdRepoApplication. @@ -12,7 +16,8 @@ * @author Manoj SP */ @SpringBootApplication(exclude = MailSenderAutoConfiguration.class) -@ComponentScan(basePackages={ "io.mosip.*" ,"${mosip.auth.adapter.impl.basepackage}"}, excludeFilters = { +@Import({ IdRepoConfig.class }) +@ComponentScan(basePackages={ "io.mosip.idrepository.*" ,"${mosip.auth.adapter.impl.basepackage}"}, excludeFilters = { @ComponentScan.Filter(type = FilterType.ASPECTJ, pattern = {"io.mosip.kernel.zkcryptoservice.*", "io.mosip.kernel.tokenidgenerator.*", @@ -27,7 +32,7 @@ "io.mosip.kernel.clientcrypto.*", "io.mosip.commons.khazana.impl.PosixAdapter", "io.mosip.commons.khazana.util.*" -}) }) +}),@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,classes = {IdRepoDataSourceConfig.class} ) }) public class IdRepoBootApplication { /** diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdRepoConfig.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdRepoConfig.java index 24521b950..772614d92 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdRepoConfig.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdRepoConfig.java @@ -1,57 +1,34 @@ package io.mosip.idrepository.identity.config; -import static io.mosip.idrepository.core.constant.IdRepoErrorConstants.CLIENT_ERROR; -import static io.mosip.idrepository.core.constant.IdRepoErrorConstants.MASTERDATA_RETRIEVE_ERROR; - -import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.Executor; -import javax.annotation.PostConstruct; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.ApplicationListener; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Primary; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.http.HttpStatus; -import org.springframework.http.client.ClientHttpResponse; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.web.client.DefaultResponseErrorHandler; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; - import io.mosip.idrepository.core.config.IdRepoDataSourceConfig; import io.mosip.idrepository.core.constant.IdRepoConstants; -import io.mosip.idrepository.core.constant.IdRepoErrorConstants; -import io.mosip.idrepository.core.exception.AuthenticationException; -import io.mosip.idrepository.core.exception.IdRepoAppUncheckedException; import io.mosip.idrepository.core.helper.IdRepoWebSubHelper; -import io.mosip.idrepository.core.helper.RestHelper; import io.mosip.idrepository.core.logger.IdRepoLogger; -import io.mosip.idrepository.core.manager.CredentialServiceManager; import io.mosip.idrepository.core.manager.CredentialStatusManager; -import io.mosip.idrepository.core.security.IdRepoSecurityManager; import io.mosip.idrepository.core.util.DummyPartnerCheckUtil; import io.mosip.idrepository.core.util.EnvUtil; -import io.mosip.kernel.core.exception.ExceptionUtils; -import io.mosip.kernel.core.exception.ServiceError; import io.mosip.kernel.core.logger.spi.Logger; import io.mosip.kernel.core.util.StringUtils; @@ -66,7 +43,7 @@ @EnableJpaRepositories(basePackages = "io.mosip.idrepository.*") @Import({ CredentialStatusManager.class, DummyPartnerCheckUtil.class }) public class IdRepoConfig extends IdRepoDataSourceConfig - implements WebMvcConfigurer, ApplicationListener { + implements WebMvcConfigurer { @Value("${" + IdRepoConstants.WEB_SUB_PUBLISH_URL + "}") public String publisherHubURL; @@ -75,8 +52,8 @@ public class IdRepoConfig extends IdRepoDataSourceConfig Logger mosipLogger = IdRepoLogger.getLogger(IdRepoConfig.class); /** The env. */ - @Autowired - private RestTemplate restTemplate; +// @Autowired +// private RestTemplate restTemplate; /** The db. */ // If sharding is enabled, need to uncomment @@ -94,63 +71,6 @@ public class IdRepoConfig extends IdRepoDataSourceConfig /** The id. */ private Map id; - @Autowired - private CredentialStatusManager credStatusManager; - - @Autowired - private IdRepoWebSubHelper websubHelper; - - @Autowired - private ObjectMapper mapper; - - @Override - public void onApplicationEvent(ApplicationReadyEvent event) { - websubHelper.subscribeForVidEvent(); - } - - @PostConstruct - public void init() { - mapper.registerModule(new Jdk8Module()).registerModule(new JavaTimeModule()); - SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL); - restTemplate.setErrorHandler(new DefaultResponseErrorHandler() { - - @Override - protected void handleError(ClientHttpResponse response, HttpStatus statusCode) throws IOException { - mosipLogger.error(IdRepoSecurityManager.getUser(), "restTemplate - handleError", "Rest Template logs", - "Status error : " + response.getRawStatusCode() + " " + response.getStatusCode() + " " - + response.getStatusText()); - if (response.getStatusCode().is4xxClientError()) { - if (response.getRawStatusCode() == 401 || response.getRawStatusCode() == 403) { - mosipLogger.error(IdRepoSecurityManager.getUser(), "restTemplate - handleError", - "request failed with status code :" + response.getRawStatusCode(), - "\n\n" + new String(super.getResponseBody(response))); - List errorList = ExceptionUtils - .getServiceErrorList(new String(super.getResponseBody(response))); - mosipLogger.error(IdRepoSecurityManager.getUser(), "restTemplate - handleError", - "Throwing AuthenticationException", errorList.toString()); - if (errorList.isEmpty()) { - throw new AuthenticationException(IdRepoErrorConstants.AUTHENTICATION_FAILED, - response.getRawStatusCode()); - } else { - throw new AuthenticationException(errorList.get(0).getErrorCode(), - errorList.get(0).getMessage(), response.getRawStatusCode()); - } - } else { - mosipLogger.error(IdRepoSecurityManager.getUser(), "restTemplate - handleError", - "Rest Template logs", "Status error - returning RestServiceException - CLIENT_ERROR -- " - + new String(super.getResponseBody(response))); - throw new IdRepoAppUncheckedException(CLIENT_ERROR); - } - } else { - mosipLogger.error(IdRepoSecurityManager.getUser(), "restTemplate - handleError", - "Rest Template logs", "Status error - returning RestServiceException - CLIENT_ERROR -- " - + new String(super.getResponseBody(response))); - throw new IdRepoAppUncheckedException(MASTERDATA_RETRIEVE_ERROR); - } - } - }); - } - /** * Gets the db. * @@ -263,26 +183,6 @@ public List uinStatus() { return Collections.unmodifiableList(uinStatus); } - @Scheduled(fixedDelayString = "${" + IdRepoConstants.CREDENTIAL_STATUS_JOB_DELAY + ":1000}") - public void credentialStatusHandlerJob() { - credStatusManager.triggerEventNotifications(); - } - - @Bean - public CredentialServiceManager credentialServiceManager(@Qualifier("selfTokenWebClient") WebClient webClient) { - return new CredentialServiceManager(restHelperWithAuth(webClient)); - } - - @Bean - public RestHelper restHelperWithAuth(@Qualifier("selfTokenWebClient") WebClient webClient) { - return new RestHelper(webClient); - } - - @Bean - public IdRepoSecurityManager securityManagerWithAuth(@Qualifier("selfTokenWebClient") WebClient webClient) { - return new IdRepoSecurityManager(restHelperWithAuth(webClient)); - } - @Bean @Primary public Executor executor() { diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdentityScheduleConfig.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdentityScheduleConfig.java new file mode 100644 index 000000000..a4efc81b5 --- /dev/null +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdentityScheduleConfig.java @@ -0,0 +1,21 @@ +package io.mosip.idrepository.identity.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.Scheduled; + +import io.mosip.idrepository.core.constant.IdRepoConstants; +import io.mosip.idrepository.core.manager.CredentialStatusManager; + +@Configuration +public class IdentityScheduleConfig { + + @Autowired + private CredentialStatusManager credStatusManager; + + @Scheduled(fixedDelayString = "${" + IdRepoConstants.CREDENTIAL_STATUS_JOB_DELAY + ":1000}") + public void credentialStatusHandlerJob() { + credStatusManager.triggerEventNotifications(); + } + +} diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdentitySecurityConfig.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdentitySecurityConfig.java new file mode 100644 index 000000000..89e700ae0 --- /dev/null +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdentitySecurityConfig.java @@ -0,0 +1,31 @@ +package io.mosip.idrepository.identity.config; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.client.WebClient; + +import io.mosip.idrepository.core.helper.RestHelper; +import io.mosip.idrepository.core.manager.CredentialServiceManager; +import io.mosip.idrepository.core.security.IdRepoSecurityManager; + + +@Configuration +public class IdentitySecurityConfig { + + @Bean + public RestHelper restHelperWithAuth(@Qualifier("selfTokenWebClient") WebClient webClient) { + return new RestHelper(webClient); + } + + @Bean + public IdRepoSecurityManager securityManagerWithAuth(@Qualifier("selfTokenWebClient") WebClient webClient) { + return new IdRepoSecurityManager(restHelperWithAuth(webClient)); + } + + @Bean + public CredentialServiceManager credentialServiceManager(@Qualifier("selfTokenWebClient") WebClient webClient) { + return new CredentialServiceManager(restHelperWithAuth(webClient)); + } + +} diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdentityWebsubConfig.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdentityWebsubConfig.java new file mode 100644 index 000000000..e98ce945d --- /dev/null +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/IdentityWebsubConfig.java @@ -0,0 +1,23 @@ +package io.mosip.idrepository.identity.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.ApplicationListener; +import org.springframework.context.annotation.Configuration; + +import io.mosip.idrepository.core.helper.IdRepoWebSubHelper; + +@Configuration +public class IdentityWebsubConfig implements ApplicationListener { + + @Autowired + private IdRepoWebSubHelper websubHelper; + + + + @Override + public void onApplicationEvent(ApplicationReadyEvent event) { + websubHelper.subscribeForVidEvent(); + } + +} diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/ObjectMapperConfig.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/ObjectMapperConfig.java new file mode 100644 index 000000000..8fe7e53b3 --- /dev/null +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/ObjectMapperConfig.java @@ -0,0 +1,24 @@ +package io.mosip.idrepository.identity.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; + +import jakarta.annotation.PostConstruct; + +@Configuration +public class ObjectMapperConfig { + + @Autowired + private ObjectMapper mapper; + + @PostConstruct + public void init() { + mapper.registerModule(new Jdk8Module()).registerModule(new JavaTimeModule()); + } + +} diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/RestTemplateConfig.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/RestTemplateConfig.java new file mode 100644 index 000000000..89d4c6b94 --- /dev/null +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/config/RestTemplateConfig.java @@ -0,0 +1,77 @@ +package io.mosip.idrepository.identity.config; + +import static io.mosip.idrepository.core.constant.IdRepoErrorConstants.CLIENT_ERROR; +import static io.mosip.idrepository.core.constant.IdRepoErrorConstants.MASTERDATA_RETRIEVE_ERROR; + +import java.io.IOException; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpStatus; +import org.springframework.http.client.ClientHttpResponse; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.web.client.DefaultResponseErrorHandler; +import org.springframework.web.client.RestTemplate; + +import io.mosip.idrepository.core.constant.IdRepoErrorConstants; +import io.mosip.idrepository.core.exception.AuthenticationException; +import io.mosip.idrepository.core.exception.IdRepoAppUncheckedException; +import io.mosip.idrepository.core.logger.IdRepoLogger; +import io.mosip.idrepository.core.security.IdRepoSecurityManager; +import io.mosip.kernel.core.exception.ExceptionUtils; +import io.mosip.kernel.core.exception.ServiceError; +import io.mosip.kernel.core.logger.spi.Logger; +import jakarta.annotation.PostConstruct; + +@Configuration +public class RestTemplateConfig { + + Logger mosipLogger = IdRepoLogger.getLogger(RestTemplateConfig.class); + + + @Autowired + private RestTemplate restTemplate; + + @PostConstruct + public void init() { + SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL); + restTemplate.setErrorHandler(new DefaultResponseErrorHandler() { + + protected void handleError(ClientHttpResponse response, HttpStatus statusCode) throws IOException { + mosipLogger.error(IdRepoSecurityManager.getUser(), "restTemplate - handleError", "Rest Template logs", + "Status error : " + response.getRawStatusCode() + " " + response.getStatusCode() + " " + + response.getStatusText()); + if (response.getStatusCode().is4xxClientError()) { + if (response.getRawStatusCode() == 401 || response.getRawStatusCode() == 403) { + mosipLogger.error(IdRepoSecurityManager.getUser(), "restTemplate - handleError", + "request failed with status code :" + response.getRawStatusCode(), + "\n\n" + new String(super.getResponseBody(response))); + List errorList = ExceptionUtils + .getServiceErrorList(new String(super.getResponseBody(response))); + mosipLogger.error(IdRepoSecurityManager.getUser(), "restTemplate - handleError", + "Throwing AuthenticationException", errorList.toString()); + if (errorList.isEmpty()) { + throw new AuthenticationException(IdRepoErrorConstants.AUTHENTICATION_FAILED, + response.getRawStatusCode()); + } else { + throw new AuthenticationException(errorList.get(0).getErrorCode(), + errorList.get(0).getMessage(), response.getRawStatusCode()); + } + } else { + mosipLogger.error(IdRepoSecurityManager.getUser(), "restTemplate - handleError", + "Rest Template logs", "Status error - returning RestServiceException - CLIENT_ERROR -- " + + new String(super.getResponseBody(response))); + throw new IdRepoAppUncheckedException(CLIENT_ERROR); + } + } else { + mosipLogger.error(IdRepoSecurityManager.getUser(), "restTemplate - handleError", + "Rest Template logs", "Status error - returning RestServiceException - CLIENT_ERROR -- " + + new String(super.getResponseBody(response))); + throw new IdRepoAppUncheckedException(MASTERDATA_RETRIEVE_ERROR); + } + } + }); + } + +} diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/controller/IdRepoController.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/controller/IdRepoController.java index d7a2c81f7..0ba63957b 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/controller/IdRepoController.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/controller/IdRepoController.java @@ -15,8 +15,8 @@ import java.util.Optional; import java.util.stream.Collectors; -import javax.annotation.Nullable; -import javax.annotation.Resource; +import jakarta.annotation.Nullable; +import jakarta.annotation.Resource; import io.mosip.idrepository.core.dto.*; import org.springframework.beans.factory.annotation.Autowired; @@ -224,7 +224,7 @@ public ResponseEntity addIdentity(@Validated @RequestBody IdReque @ApiResponse(responseCode = "401", description = "Unauthorized" ,content = @Content(schema = @Schema(hidden = true))), @ApiResponse(responseCode = "403", description = "Forbidden" ,content = @Content(schema = @Schema(hidden = true))), @ApiResponse(responseCode = "404", description = "Not Found" ,content = @Content(schema = @Schema(hidden = true)))}) - public ResponseEntity retrieveIdentity(@PathVariable String id, + public ResponseEntity retrieveIdentity(@PathVariable("id") String id, @RequestParam(name = TYPE, required = false) @Nullable String type, @RequestParam(name = ID_TYPE, required = false) @Nullable String idType, @RequestParam(name = FINGER_EXTRACTION_FORMAT, required = false) @Nullable String fingerExtractionFormat, diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/AnonymousProfileEntity.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/AnonymousProfileEntity.java index fcdf91b17..6ebf31ab5 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/AnonymousProfileEntity.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/AnonymousProfileEntity.java @@ -2,11 +2,11 @@ import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; @@ -22,8 +22,10 @@ public class AnonymousProfileEntity { @Id + @Column(name = "id") private String id; + @Column(name = "profile") private String profile; @NotNull diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/AuthtypeLock.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/AuthtypeLock.java index 53cec25eb..b9b7b17d5 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/AuthtypeLock.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/AuthtypeLock.java @@ -3,13 +3,13 @@ import java.io.Serializable; import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; import lombok.Data; import lombok.NoArgsConstructor; diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/ChannelInfo.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/ChannelInfo.java index 50bfd8a17..c7f2fe7b7 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/ChannelInfo.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/ChannelInfo.java @@ -2,11 +2,11 @@ import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Builder; @@ -22,10 +22,13 @@ public class ChannelInfo { @Id + @Column(name = "hashed_channel") private String hashedChannel; + @Column(name = "channel_type") private String channelType; + @Column(name = "no_of_records") private Integer noOfRecords; @NotNull diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/IdentityUpdateTracker.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/IdentityUpdateTracker.java index 69dc629ea..e60a3da7f 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/IdentityUpdateTracker.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/IdentityUpdateTracker.java @@ -1,9 +1,10 @@ package io.mosip.idrepository.identity.entity; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Lob; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Lob; +import jakarta.persistence.Table; import org.hibernate.annotations.Type; @@ -24,12 +25,12 @@ public class IdentityUpdateTracker { @Id + @Column(name = "id") private String id; - @Lob - @Type(type = "org.hibernate.type.BinaryType") @Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) + @Column(name = "identity_update_count") private byte[] identityUpdateCount; public byte[] getIdentityUpdateCount() { diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/Uin.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/Uin.java index 7de0711ef..733afafdc 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/Uin.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/Uin.java @@ -3,22 +3,19 @@ import java.time.LocalDateTime; import java.util.List; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.Lob; -import javax.persistence.OneToMany; -import javax.persistence.Table; - -import io.mosip.idrepository.core.entity.UinInfo; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; -import org.hibernate.annotations.Type; +import org.hibernate.annotations.JdbcTypeCode; import org.springframework.data.domain.Persistable; +import io.mosip.idrepository.core.entity.UinInfo; +import jakarta.persistence.Basic; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.Lob; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -61,33 +58,39 @@ public Uin(String uinRefId, String uin, String uinHash, byte[] uinData, String u /** The uin ref id. */ @Id - @Column(insertable = false, updatable = false, nullable = false) + @Column(name="uin_ref_id", insertable = false, updatable = false, nullable = false) private String uinRefId; /** The uin. */ + @Column(name="uin") private String uin; - + + @Column(name="uin_hash") private String uinHash; /** The uin data. */ - @Lob - @Type(type = "org.hibernate.type.BinaryType") @Basic(fetch = FetchType.LAZY) @Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) + @Column(name="uin_data", nullable = false) private byte[] uinData; /** The uin data hash. */ + @Column(name="uin_data_hash") private String uinDataHash; /** The reg id. */ + @Column(name="reg_id") private String regId; - + + @Column(name="bio_ref_id") private String bioRefId; /** The status code. */ + @Column(name="status_code") private String statusCode; + @Column(name="lang_code") private String langCode; /** The created by. */ @@ -107,6 +110,7 @@ public Uin(String uinRefId, String uin, String uinHash, byte[] uinData, String u private LocalDateTime updatedDateTime; /** The is deleted. */ + @Column(name="is_deleted") private Boolean isDeleted; /** The deleted date time. */ @@ -114,11 +118,9 @@ public Uin(String uinRefId, String uin, String uinHash, byte[] uinData, String u private LocalDateTime deletedDateTime; @OneToMany(fetch = FetchType.LAZY, mappedBy = "uin", cascade = CascadeType.ALL) - @NotFound(action = NotFoundAction.IGNORE) private List biometrics; @OneToMany(fetch = FetchType.LAZY, mappedBy = "uin", cascade = CascadeType.ALL) - @NotFound(action = NotFoundAction.IGNORE) private List documents; /** diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinBiometric.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinBiometric.java index 888d37735..3672d2998 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinBiometric.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinBiometric.java @@ -3,17 +3,16 @@ import java.io.Serializable; import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; - import com.fasterxml.jackson.annotation.JsonBackReference; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import lombok.Data; /** @@ -24,7 +23,7 @@ @Data @Entity @IdClass(BiometricPK.class) -@Table(schema = "idrepo") +@Table(schema = "idrepo", name = "uin_biometric") public class UinBiometric implements Serializable { public UinBiometric() { @@ -56,21 +55,27 @@ public UinBiometric(String uinRefId, String bioFileId, String biometricFileType, /** The uin ref id. */ @Id + @Column(name = "uin_ref_id") private String uinRefId; /** The bio file id. */ + @Column(name = "bio_file_id") private String bioFileId; @Id + @Column(name = "biometric_file_type") private String biometricFileType; /** The biometric file name. */ + @Column(name = "biometric_file_name") private String biometricFileName; /** The biometric file hash. */ + @Column(name = "biometric_file_hash") private String biometricFileHash; /** The lang code. */ + @Column(name = "lang_code") private String langCode; /** The created by. */ @@ -90,6 +95,7 @@ public UinBiometric(String uinRefId, String bioFileId, String biometricFileType, private LocalDateTime updatedDateTime; /** The is deleted. */ + @Column(name = "is_deleted") private Boolean isDeleted; /** The deleted date time. */ @@ -97,7 +103,7 @@ public UinBiometric(String uinRefId, String bioFileId, String biometricFileType, private LocalDateTime deletedDateTime; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "uinRefId", insertable = false, updatable = false) + @JoinColumn(name = "uin_ref_id", insertable = false, updatable = false) @JsonBackReference private Uin uin; } diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinBiometricDraft.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinBiometricDraft.java index aa6f0f8d6..c24acad9e 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinBiometricDraft.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinBiometricDraft.java @@ -3,14 +3,14 @@ import java.io.Serializable; import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import com.fasterxml.jackson.annotation.JsonBackReference; @@ -24,7 +24,7 @@ @Data @Entity @IdClass(BiometricDraftPK.class) -@Table(schema = "idrepo") +@Table(schema = "idrepo", name = "uin_biometric_draft") public class UinBiometricDraft implements Serializable { public UinBiometricDraft() { @@ -55,18 +55,23 @@ public UinBiometricDraft(String regId, String bioFileId, String biometricFileTyp /** The uin ref id. */ @Id + @Column(name = "reg_id") private String regId; /** The bio file id. */ + @Column(name = "bio_file_id") private String bioFileId; @Id + @Column(name = "biometric_file_type") private String biometricFileType; /** The biometric file name. */ + @Column(name = "biometric_file_name") private String biometricFileName; /** The biometric file hash. */ + @Column(name = "biometric_file_hash") private String biometricFileHash; /** The created by. */ @@ -86,6 +91,7 @@ public UinBiometricDraft(String regId, String bioFileId, String biometricFileTyp private LocalDateTime updatedDateTime; /** The is deleted. */ + @Column(name = "is_deleted") private Boolean isDeleted; /** The deleted date time. */ @@ -93,7 +99,7 @@ public UinBiometricDraft(String regId, String bioFileId, String biometricFileTyp private LocalDateTime deletedDateTime; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "regId", insertable = false, updatable = false) + @JoinColumn(name = "reg_id", insertable = false, updatable = false) @JsonBackReference private UinDraft uin; } diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinBiometricHistory.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinBiometricHistory.java index 97d6938b8..9d9d7f477 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinBiometricHistory.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinBiometricHistory.java @@ -2,11 +2,11 @@ import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Data; @@ -28,6 +28,7 @@ public class UinBiometricHistory { /** The uin ref id. */ @Id + @Column(name = "uin_ref_id") private String uinRefId; /** The effective date time. */ @@ -36,18 +37,23 @@ public class UinBiometricHistory { private LocalDateTime effectiveDateTime; /** The bio file id. */ + @Column(name = "bio_file_id") private String bioFileId; /** The bio file id. */ + @Column(name = "biometric_file_type") private String biometricFileType; /** The biometric file name. */ + @Column(name = "biometric_file_name") private String biometricFileName; /** The biometric file hash. */ + @Column(name = "biometric_file_hash") private String biometricFileHash; /** The lang code. */ + @Column(name = "lang_code") private String langCode; /** The created by. */ @@ -67,6 +73,7 @@ public class UinBiometricHistory { private LocalDateTime updatedDateTime; /** The is deleted. */ + @Column(name = "is_deleted") private Boolean isDeleted; /** The deleted date time. */ diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDocument.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDocument.java index 3ae9629bc..6d47132bf 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDocument.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDocument.java @@ -2,14 +2,14 @@ import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -30,7 +30,7 @@ @Entity @NoArgsConstructor @IdClass(DocumentPK.class) -@Table(schema = "idrepo") +@Table(schema = "idrepo", name="uin_document") @JsonIgnoreProperties(value = { "uin" }) public class UinDocument { @@ -56,29 +56,36 @@ public UinDocument(String uinRefId, String doccatCode, String doctypCode, String /** The uin ref id. */ @Id + @Column(name = "uin_ref_id") private String uinRefId; /** The doccat code. */ @Id + @Column(name = "doccat_code") private String doccatCode; /** The doctyp code. */ - @Id + @Column(name = "doctyp_code") private String doctypCode; /** The doc id. */ + @Column(name = "doc_id") private String docId; /** The doc name. */ + @Column(name = "doc_name") private String docName; /** The docfmt code. */ + @Column(name = "docfmt_code") private String docfmtCode; /** The doc hash. */ + @Column(name = "doc_hash") private String docHash; /** The lang code. */ + @Column(name = "lang_code") private String langCode; /** The created by. */ @@ -98,6 +105,7 @@ public UinDocument(String uinRefId, String doccatCode, String doctypCode, String private LocalDateTime updatedDateTime; /** The is deleted. */ + @Column(name = "is_deleted") private Boolean isDeleted; /** The deleted date time. */ @@ -105,7 +113,7 @@ public UinDocument(String uinRefId, String doccatCode, String doctypCode, String private LocalDateTime deletedDateTime; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "uinRefId", insertable = false, updatable = false) + @JoinColumn(name = "uin_ref_id", insertable = false, updatable = false) @JsonBackReference private Uin uin; } diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDocumentDraft.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDocumentDraft.java index 4140cb6cd..a7799c79a 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDocumentDraft.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDocumentDraft.java @@ -2,14 +2,14 @@ import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import com.fasterxml.jackson.annotation.JsonBackReference; @@ -30,7 +30,7 @@ @Entity @NoArgsConstructor @IdClass(DocumentDraftPK.class) -@Table(schema = "idrepo") +@Table(schema = "idrepo", name = "uin_document_draft" ) public class UinDocumentDraft { public UinDocumentDraft(String regId, String doccatCode, String doctypCode, String docId, String docName, @@ -52,28 +52,35 @@ public UinDocumentDraft(String regId, String doccatCode, String doctypCode, Stri this.deletedDateTime = deletedDateTime; } - /** The uin ref id. */ + /** The reg_id. */ @Id + @Column(name = "reg_id") private String regId; /** The doccat code. */ @Id + @Column(name = "doccat_code") private String doccatCode; /** The doctyp code. */ - @Id + //@Id + @Column(name = "doctyp_code") private String doctypCode; /** The doc id. */ + @Column(name = "doc_id") private String docId; /** The doc name. */ + @Column(name = "doc_name") private String docName; /** The docfmt code. */ + @Column(name = "docfmt_code") private String docfmtCode; /** The doc hash. */ + @Column(name = "doc_hash") private String docHash; /** The created by. */ @@ -93,6 +100,7 @@ public UinDocumentDraft(String regId, String doccatCode, String doctypCode, Stri private LocalDateTime updatedDateTime; /** The is deleted. */ + @Column(name = "is_deleted") private Boolean isDeleted; /** The deleted date time. */ @@ -100,7 +108,7 @@ public UinDocumentDraft(String regId, String doccatCode, String doctypCode, Stri private LocalDateTime deletedDateTime; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "regId", insertable = false, updatable = false) + @JoinColumn(name = "reg_id", insertable = false, updatable = false) @Setter(value = AccessLevel.NONE) @JsonBackReference private UinDraft uin; diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDocumentHistory.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDocumentHistory.java index 040f99756..1b1c9da94 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDocumentHistory.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDocumentHistory.java @@ -2,11 +2,11 @@ import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Data; @@ -28,6 +28,7 @@ public class UinDocumentHistory { /** The uin ref id. */ @Id + @Column(name = "uin_ref_id") private String uinRefId; /** The effective date time. */ @@ -36,24 +37,31 @@ public class UinDocumentHistory { private LocalDateTime effectiveDateTime; /** The doccat code. */ + @Column(name = "doccat_code") private String doccatCode; /** The doctyp code. */ + @Column(name = "doctyp_code") private String doctypCode; /** The doc id. */ + @Column(name = "doc_id") private String docId; /** The doc name. */ + @Column(name = "doc_name") private String docName; /** The docfmt code. */ + @Column(name = "docfmt_code") private String docfmtCode; /** The doc hash. */ + @Column(name = "doc_hash") private String docHash; /** The lang code. */ + @Column(name = "lang_code") private String langCode; /** The created by. */ @@ -73,6 +81,7 @@ public class UinDocumentHistory { private LocalDateTime updatedDateTime; /** The is deleted. */ + @Column(name = "is_deleted") private Boolean isDeleted; /** The deleted date time. */ diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDraft.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDraft.java index f8837b9dd..100555afd 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDraft.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinDraft.java @@ -4,20 +4,16 @@ import java.time.LocalDateTime; import java.util.List; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.Lob; -import javax.persistence.OneToMany; -import javax.persistence.Table; +import jakarta.persistence.Basic; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; import io.mosip.idrepository.core.entity.UinInfo; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; -import org.hibernate.annotations.Type; import org.springframework.data.domain.Persistable; import lombok.AccessLevel; @@ -36,7 +32,7 @@ @ToString(exclude = { "biometrics", "documents" }) @Entity @NoArgsConstructor -@Table(schema = "idrepo") +@Table(schema = "idrepo", name = "uin_draft") public class UinDraft implements Persistable, UinInfo, Serializable { /** @@ -65,26 +61,29 @@ public UinDraft(String uin, String uinHash, byte[] uinData, String uinDataHash, } @Id - @Column(insertable = false, updatable = false, nullable = false) + @Column(name="reg_id", insertable = false, updatable = false, nullable = false) private String regId; /** The uin. */ + @Column(name="uin") private String uin; + @Column(name="uin_hash") private String uinHash; /** The uin data. */ - @Lob - @Type(type = "org.hibernate.type.BinaryType") @Basic(fetch = FetchType.LAZY) @Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) + @Column(name="uin_data") private byte[] uinData; /** The uin data hash. */ + @Column(name="uin_data_hash") private String uinDataHash; /** The status code. */ + @Column(name="status_code") private String statusCode; /** The created by. */ @@ -104,6 +103,7 @@ public UinDraft(String uin, String uinHash, byte[] uinData, String uinDataHash, private LocalDateTime updatedDateTime; /** The is deleted. */ + @Column(name = "is_deleted") private Boolean isDeleted; /** The deleted date time. */ @@ -111,11 +111,9 @@ public UinDraft(String uin, String uinHash, byte[] uinData, String uinDataHash, private LocalDateTime deletedDateTime; @OneToMany(fetch = FetchType.LAZY, mappedBy = "uin", cascade = CascadeType.ALL) - @NotFound(action = NotFoundAction.IGNORE) private List biometrics; @OneToMany(fetch = FetchType.LAZY, mappedBy = "uin", cascade = CascadeType.ALL) - @NotFound(action = NotFoundAction.IGNORE) private List documents; /** diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinHistory.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinHistory.java index 1cc1da522..e3bfe0d1e 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinHistory.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/entity/UinHistory.java @@ -2,14 +2,14 @@ import java.time.LocalDateTime; -import javax.persistence.Basic; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Lob; -import javax.persistence.Table; +import jakarta.persistence.Basic; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.Id; +import jakarta.persistence.IdClass; +import jakarta.persistence.Lob; +import jakarta.persistence.Table; import io.mosip.idrepository.core.entity.UinInfo; import org.hibernate.annotations.Type; @@ -80,6 +80,7 @@ public UinHistory(String uinRefId, LocalDateTime effectiveDateTime, String uin, /** The uin ref id. */ @Id + @Column(name = "uin_ref_id") private String uinRefId; /** The effective date time. */ @@ -88,31 +89,37 @@ public UinHistory(String uinRefId, LocalDateTime effectiveDateTime, String uin, private LocalDateTime effectiveDateTime; /** The uin. */ + @Column(name = "uin") private String uin; /** The uin hash. */ + @Column(name = "uin_hash") private String uinHash; /** The uin data. */ - @Lob - @Type(type = "org.hibernate.type.BinaryType") @Basic(fetch = FetchType.LAZY) @Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) + @Column(name = "uin_data") private byte[] uinData; /** The uin data hash. */ + @Column(name = "uin_data_hash") private String uinDataHash; /** The reg id. */ + @Column(name = "reg_id") private String regId; /** The bio ref id. */ + @Column(name = "bio_ref_id") private String bioRefId; /** The status code. */ + @Column(name = "status_code") private String statusCode; + @Column(name = "lang_code") private String langCode; /** The created by. */ @@ -132,6 +139,7 @@ public UinHistory(String uinRefId, LocalDateTime effectiveDateTime, String uin, private LocalDateTime updatedDateTime; /** The is deleted. */ + @Column(name = "is_deleted") private Boolean isDeleted; /** The deleted date time. */ diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/helper/AnonymousProfileHelper.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/helper/AnonymousProfileHelper.java index 681aab655..cf4b6ee00 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/helper/AnonymousProfileHelper.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/helper/AnonymousProfileHelper.java @@ -7,7 +7,7 @@ import java.util.List; import java.util.Objects; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/helper/IdRepoServiceHelper.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/helper/IdRepoServiceHelper.java index ff56ab8a8..4ebf1b3c1 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/helper/IdRepoServiceHelper.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/helper/IdRepoServiceHelper.java @@ -33,7 +33,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import java.io.IOException; import java.io.InputStream; import java.net.URL; diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/httpfilter/IdRepoFilter.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/httpfilter/IdRepoFilter.java index 2981ff17b..3747b5c7c 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/httpfilter/IdRepoFilter.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/httpfilter/IdRepoFilter.java @@ -1,6 +1,6 @@ package io.mosip.idrepository.identity.httpfilter; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.springframework.stereotype.Component; diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/interceptor/IdRepoEntityInterceptor.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/interceptor/IdRepoEntityInterceptor.java index fbde5074c..77e03284d 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/interceptor/IdRepoEntityInterceptor.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/interceptor/IdRepoEntityInterceptor.java @@ -11,20 +11,23 @@ import java.util.List; import java.util.Objects; -import io.mosip.idrepository.core.entity.HandleInfo; -import io.mosip.idrepository.core.entity.UinInfo; -import io.mosip.idrepository.identity.entity.*; import org.apache.commons.codec.binary.StringUtils; -import org.hibernate.EmptyInterceptor; +import org.hibernate.Interceptor; import org.hibernate.type.Type; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +import io.mosip.idrepository.core.entity.HandleInfo; +import io.mosip.idrepository.core.entity.UinInfo; import io.mosip.idrepository.core.exception.IdRepoAppException; import io.mosip.idrepository.core.exception.IdRepoAppUncheckedException; import io.mosip.idrepository.core.logger.IdRepoLogger; import io.mosip.idrepository.core.security.IdRepoSecurityManager; +import io.mosip.idrepository.identity.entity.Uin; +import io.mosip.idrepository.identity.entity.UinDraft; +import io.mosip.idrepository.identity.entity.UinHistory; import io.mosip.kernel.core.logger.spi.Logger; import io.mosip.kernel.core.util.CryptoUtil; @@ -35,7 +38,7 @@ * @author Manoj SP */ @Component -public class IdRepoEntityInterceptor extends EmptyInterceptor { +public class IdRepoEntityInterceptor implements Interceptor { private static final String UIN = "uin"; private static final String HANDLE = "handle"; @@ -62,6 +65,7 @@ public class IdRepoEntityInterceptor extends EmptyInterceptor { private static final long serialVersionUID = 4985336846122302850L; /** The security manager. */ + @Lazy @Autowired private transient IdRepoSecurityManager securityManager; @@ -86,7 +90,7 @@ else if (entity instanceof UinInfo) { mosipLogger.error(IdRepoSecurityManager.getUser(), ID_REPO_ENTITY_INTERCEPTOR, "onSave", "\n" + e.getMessage()); throw new IdRepoAppUncheckedException(ENCRYPTION_DECRYPTION_FAILED, e); } - return super.onSave(entity, id, state, propertyNames, types); + return Interceptor.super.onSave(entity, id, state, propertyNames, types); } private void encryptDataOnSave(Serializable id, Object[] state, List propertyNamesList, @@ -145,7 +149,7 @@ public boolean onLoad(Object entity, Serializable id, Object[] state, String[] p mosipLogger.error(IdRepoSecurityManager.getUser(), ID_REPO_ENTITY_INTERCEPTOR, "onLoad", "\n" + e.getMessage()); throw new IdRepoAppUncheckedException(ENCRYPTION_DECRYPTION_FAILED, e); } - return super.onLoad(entity, id, state, propertyNames, types); + return Interceptor.super.onLoad(entity, id, state, propertyNames, types); } /* @@ -169,7 +173,7 @@ public boolean onFlushDirty(Object entity, Serializable id, Object[] currentStat mosipLogger.error(IdRepoSecurityManager.getUser(), ID_REPO_ENTITY_INTERCEPTOR, "onSave", "\n" + e.getMessage()); throw new IdRepoAppUncheckedException(ENCRYPTION_DECRYPTION_FAILED, e); } - return super.onFlushDirty(entity, id, currentState, previousState, propertyNames, types); + return Interceptor.super.onFlushDirty(entity, id, currentState, previousState, propertyNames, types); } private boolean encryptOnDirtyFlush(Serializable id, Object[] currentState, Object[] previousState, @@ -178,6 +182,6 @@ private boolean encryptOnDirtyFlush(Serializable id, Object[ List propertyNamesList = Arrays.asList(propertyNames); int indexOfData = propertyNamesList.indexOf(UIN_DATA); currentState[indexOfData] = encryptedData; - return super.onFlushDirty(uinEntity, id, currentState, previousState, propertyNames, types); + return Interceptor.super.onFlushDirty(uinEntity, id, currentState, previousState, propertyNames, types); } } \ No newline at end of file diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/provider/IdentityUpdateTrackerPolicyProvider.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/provider/IdentityUpdateTrackerPolicyProvider.java index 4e19e5027..dc7bb596f 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/provider/IdentityUpdateTrackerPolicyProvider.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/provider/IdentityUpdateTrackerPolicyProvider.java @@ -4,7 +4,7 @@ import java.net.URL; import java.util.Map; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.context.config.annotation.RefreshScope; diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/service/impl/IdRepoDraftServiceImpl.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/service/impl/IdRepoDraftServiceImpl.java index d10dd6355..632dc87cc 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/service/impl/IdRepoDraftServiceImpl.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/service/impl/IdRepoDraftServiceImpl.java @@ -44,7 +44,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import io.mosip.idrepository.core.constant.IdRepoConstants; import io.mosip.idrepository.core.dto.DraftResponseDto; import io.mosip.idrepository.core.dto.DraftUinResponseDto; import org.hibernate.exception.JDBCConnectionException; diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/service/impl/IdRepoProxyServiceImpl.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/service/impl/IdRepoProxyServiceImpl.java index 0d712829e..5d86fd2f1 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/service/impl/IdRepoProxyServiceImpl.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/service/impl/IdRepoProxyServiceImpl.java @@ -14,7 +14,7 @@ import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -import javax.annotation.Resource; +import jakarta.annotation.Resource; import io.mosip.idrepository.core.constant.*; import io.mosip.idrepository.core.dto.*; diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/service/impl/IdRepoServiceImpl.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/service/impl/IdRepoServiceImpl.java index ba5647411..70d4f48c1 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/service/impl/IdRepoServiceImpl.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/service/impl/IdRepoServiceImpl.java @@ -10,7 +10,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -import javax.annotation.Resource; +import jakarta.annotation.Resource; import io.mosip.idrepository.core.entity.Handle; import io.mosip.idrepository.core.repository.HandleRepo; diff --git a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/validator/IdRequestValidator.java b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/validator/IdRequestValidator.java index 8c1bb2640..34873dde5 100644 --- a/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/validator/IdRequestValidator.java +++ b/id-repository/id-repository-identity-service/src/main/java/io/mosip/idrepository/identity/validator/IdRequestValidator.java @@ -15,9 +15,9 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -import javax.annotation.Nonnull; -import javax.annotation.PostConstruct; -import javax.annotation.Resource; +import jakarta.annotation.Nonnull; +import jakarta.annotation.PostConstruct; +import jakarta.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; diff --git a/id-repository/id-repository-identity-service/src/main/resources/bootstrap.properties b/id-repository/id-repository-identity-service/src/main/resources/bootstrap.properties index 47256567a..96ba4329e 100644 --- a/id-repository/id-repository-identity-service/src/main/resources/bootstrap.properties +++ b/id-repository/id-repository-identity-service/src/main/resources/bootstrap.properties @@ -1,4 +1,4 @@ -spring.cloud.config.uri=https://dev.mosip.net/config +spring.cloud.config.uri=https://dev1.mosip.net/config spring.cloud.config.label=1.1.2 spring.cloud.config.name=id-repository spring.application.name=id-repository @@ -37,4 +37,6 @@ openapi.info.license.url=https://docs.mosip.io/platform/license ------OpenApi properties-------- mosipbox.public.url=http://localhost:8090 openapi.idRepoIdentityServiceServer.servers[0].url=${mosipbox.public.url}/idrepository/v1/identity -openapi.idRepoIdentityServiceServer.servers[0].description=Id Repository Identity Service \ No newline at end of file +openapi.idRepoIdentityServiceServer.servers[0].description=Id Repository Identity Service +spring.main.allow-bean-definition-overriding=true +spring.main.allow-circular-references=true \ No newline at end of file diff --git a/id-repository/id-repository-identity-service/src/test/java/io/mosip/idrepository/identity/helper/IdentityUpdateTrackerPolicyProviderTest.java b/id-repository/id-repository-identity-service/src/test/java/io/mosip/idrepository/identity/helper/IdentityUpdateTrackerPolicyProviderTest.java index 5670cb0de..d6ce95df1 100644 --- a/id-repository/id-repository-identity-service/src/test/java/io/mosip/idrepository/identity/helper/IdentityUpdateTrackerPolicyProviderTest.java +++ b/id-repository/id-repository-identity-service/src/test/java/io/mosip/idrepository/identity/helper/IdentityUpdateTrackerPolicyProviderTest.java @@ -9,7 +9,7 @@ import java.net.URL; import java.util.Map; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/id-repository/id-repository-identity-service/src/test/java/io/mosip/idrepository/identity/test/validator/IdRequestValidatorTest.java b/id-repository/id-repository-identity-service/src/test/java/io/mosip/idrepository/identity/test/validator/IdRequestValidatorTest.java index dd187d895..1bd9fca44 100644 --- a/id-repository/id-repository-identity-service/src/test/java/io/mosip/idrepository/identity/test/validator/IdRequestValidatorTest.java +++ b/id-repository/id-repository-identity-service/src/test/java/io/mosip/idrepository/identity/test/validator/IdRequestValidatorTest.java @@ -18,7 +18,7 @@ import java.util.List; import java.util.Map; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import io.mosip.idrepository.core.dto.IdentityMapping; import io.mosip.idrepository.identity.helper.IdRepoServiceHelper; diff --git a/id-repository/id-repository-salt-generator/pom.xml b/id-repository/id-repository-salt-generator/pom.xml index bd37db381..921b1cbe0 100644 --- a/id-repository/id-repository-salt-generator/pom.xml +++ b/id-repository/id-repository-salt-generator/pom.xml @@ -10,7 +10,7 @@ io.mosip.idrepository id-repository-parent - 1.2.1-SNAPSHOT + 1.2.0.1 Batch Job Application to for one-time populating of salt values for ID Repository salt tables. @@ -82,112 +82,7 @@ 2.2.10 20180813 1.1.1 - - - 3.6.1 - 3.7 - 2.6 - 1.11 - 4.3 - 1.9.2 - 2.2 - 4.5.6 - 19.0 - 1.18.8 - 0.1.54 - 1.4.0 - 7.1.0 - 2.0.0 - 5.5.13 - 2.3.23 - 1.7 - 2.0 - 1.5.2 - 2.1.1 - 1.66 - 63.1 - 1.0.0 - 3.3.3 - 3.1.0 - 4.1.0-incubating - 1.11.368 - 0.2.4 - 2.3.0 - 3.0.1 - 1.9.12 - 0.6.0 - 2.0.0.AM2 - 1.8.12 - 1.4.2 - 1.4.2 - UTF-8 - - - 11 - 11 - 3.8.0 - - - 3.0.2 - 3.1.0 - - - 3.2.0 - 2.3 - - - 2.0.2.RELEASE - 2.0.7.RELEASE - 5.0.5.RELEASE - 2.0.4.RELEASE - - - 2.0.7 - 1.5.21 - 2.9.2 - - - 3.6.2 - 3.7.0 - - - - 1.2 - 3.0.0 - 1.3 - 2.2 - 2.0.1.Final - 2.2.6 - - - 1.4.197 - 5.1.46 - 42.2.2 - 2.5.0 - 5.2.17.Final - 6.0.12.Final - - - 4.12 - 2.23.4 - 1.7.4 - 2.0.7 - - - 1.2.3 - 1.7.19 - 1.7.7 - 1.7.25 - - - 2.9.5 - 2.9.8 - 2.9.6 - 20180130 - 2.2.10 - 20180813 - 1.1.1 - + 3.6.1 3.7 @@ -198,7 +93,6 @@ 2.2 4.5.6 19.0 - 1.18.8 0.1.54 1.4.0 7.1.0 diff --git a/id-repository/id-repository-vid-service/Dockerfile b/id-repository/id-repository-vid-service/Dockerfile index b9c07e49c..ecebf865f 100644 --- a/id-repository/id-repository-vid-service/Dockerfile +++ b/id-repository/id-repository-vid-service/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:11 +FROM eclipse-temurin:21-jre-alpine ARG SOURCE ARG COMMIT_HASH @@ -48,16 +48,16 @@ ARG container_user=mosip ARG container_user_group=mosip # can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 +ARG container_user_uid=1002 # can be passed during Docker build as build time environment for github branch to pickup configuration from. ARG container_user_gid=1001 # install packages and create user -RUN apt-get -y update \ -&& apt-get install -y unzip \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} +RUN apk -q update \ +&& apk add -q unzip \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} # set working directory for the user WORKDIR /home/${container_user} @@ -82,14 +82,14 @@ EXPOSE 8091 CMD if [ "$is_glowroot_env" = "present" ]; then \ - wget -q --show-progress "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ + wget -q "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ unzip glowroot.zip ; \ rm -rf glowroot.zip ; \ sed -i 's//id-repository-vid-service/g' glowroot/glowroot.properties ; \ - wget -q --show-progress "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + wget -q "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ java -Dloader.path="${loader_path_env}" -jar -javaagent:glowroot/glowroot.jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" id-repository-vid-service.jar ; \ else \ - wget -q --show-progress "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + wget -q "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ java -Dloader.path="${loader_path_env}" -jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" id-repository-vid-service.jar ; \ fi diff --git a/id-repository/id-repository-vid-service/pom.xml b/id-repository/id-repository-vid-service/pom.xml index 5e5d50cae..5a7741270 100644 --- a/id-repository/id-repository-vid-service/pom.xml +++ b/id-repository/id-repository-vid-service/pom.xml @@ -14,8 +14,8 @@ UTF-8 - 11 - 11 + 21 + 21 2.0.2.RELEASE 1.2.1-SNAPSHOT 1.2.1-SNAPSHOT @@ -53,7 +53,6 @@ com.fasterxml.jackson.module jackson-module-afterburner - 2.12.0 io.mosip.kernel @@ -78,17 +77,14 @@ org.springframework.boot spring-boot-starter-security - ${spring.boot.version} org.springframework.security spring-security-test - ${spring.security.test.version} org.springframework.cloud spring-cloud-starter-config - ${spring-cloud-config.version} @@ -99,26 +95,23 @@ org.powermock powermock-module-junit4 - ${powermock.beta.version} test org.powermock powermock-api-mockito2 - ${powermock.beta.version} test - - org.springdoc - springdoc-openapi-ui - ${springdoc.version} - org.springframework.boot spring-boot-configuration-processor - ${spring.boot.version} true + + org.mvel + mvel2 + 2.5.2.Final + diff --git a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/VidBootApplication.java b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/VidBootApplication.java index 85c092457..898b68d27 100644 --- a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/VidBootApplication.java +++ b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/VidBootApplication.java @@ -8,18 +8,19 @@ import io.mosip.idrepository.core.security.IdRepoSecurityManager; import io.mosip.idrepository.core.util.DummyPartnerCheckUtil; -import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; /** * The Class IdRepoVidApplication. * * @author Prem Kumar */ -@SpringBootApplication(exclude = HibernateDaoConfig.class) +@SpringBootApplication @Import({ IdRepoSecurityManager.class, DummyPartnerCheckUtil.class }) @ComponentScan(basePackages = { "io.mosip.idrepository.vid.*", "io.mosip.idrepository.core.*", + "io.mosip.kernel.websub.api.config", "io.mosip.kernel.idvalidator.vid.impl", "io.mosip.kernel.idvalidator.uin.impl", "${mosip.auth.adapter.impl.basepackage}" }, excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = { - "io.mosip.idrepository.core.entity", "io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig" })) + "io.mosip.idrepository.core.entity", + "io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig" })) public class VidBootApplication { /** diff --git a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/config/RestTemplateConfig.java b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/config/RestTemplateConfig.java new file mode 100644 index 000000000..a2a249f4e --- /dev/null +++ b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/config/RestTemplateConfig.java @@ -0,0 +1,39 @@ +package io.mosip.idrepository.vid.config; + +import org.mvel2.MVEL; +import org.mvel2.integration.VariableResolverFactory; +import org.mvel2.integration.impl.MapVariableResolverFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; + +/** + * @author Neha Farheen. + */ + +@Configuration +public class RestTemplateConfig { + + + @Value("${config.server.file.storage.uri}") + private String configServerFileStorageURL; + + @Value("${credential.service.mvel.file}") + private String mvelFile; + + @Autowired + @Qualifier("restTemplate") + private RestTemplate restTemplate; + + @Bean("mask") + public VariableResolverFactory getVariableResolverFactory() { + String mvelExpression = restTemplate.getForObject(configServerFileStorageURL + mvelFile, String.class); + VariableResolverFactory functionFactory = new MapVariableResolverFactory(); + MVEL.eval(mvelExpression, functionFactory); + return functionFactory; + } + +} diff --git a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/config/VidRepoConfig.java b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/config/VidRepoConfig.java index df041b10d..5311c5657 100644 --- a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/config/VidRepoConfig.java +++ b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/config/VidRepoConfig.java @@ -15,13 +15,11 @@ import javax.sql.DataSource; -import org.hibernate.Interceptor; +import io.mosip.idrepository.vid.interceptor.IdRepoVidEntityInterceptor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy; -import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; @@ -35,7 +33,6 @@ import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.function.client.WebClient; import com.fasterxml.jackson.module.afterburner.AfterburnerModule; @@ -53,9 +50,6 @@ import io.mosip.idrepository.vid.repository.VidRepo; import io.mosip.kernel.core.logger.spi.Logger; import io.mosip.kernel.core.util.StringUtils; -import org.mvel2.MVEL; -import org.mvel2.integration.VariableResolverFactory; -import org.mvel2.integration.impl.MapVariableResolverFactory; /** * The Class Vid Repo Config. @@ -75,7 +69,7 @@ public class VidRepoConfig { /** The Interceptor. */ @Autowired - private Interceptor interceptor; + private IdRepoVidEntityInterceptor idRepoVidEntityInterceptor; /** The id. */ private Map id; @@ -129,8 +123,8 @@ public List allowedStatus() { public Map jpaProperties() { Map jpaProperties = new HashMap<>(); jpaProperties.put("hibernate.implicit_naming_strategy", SpringImplicitNamingStrategy.class.getName()); - jpaProperties.put("hibernate.physical_naming_strategy", SpringPhysicalNamingStrategy.class.getName()); - jpaProperties.put("hibernate.ejb.interceptor", interceptor); + jpaProperties.put("hibernate.physical_naming_strategy", org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl.class.getName()); + jpaProperties.put("hibernate.session_factory.interceptor", idRepoVidEntityInterceptor); jpaProperties.replace("hibernate.dialect", "org.hibernate.dialect.PostgreSQL92Dialect"); return jpaProperties; } @@ -232,23 +226,5 @@ private void logThreadQueueDetails(ThreadPoolTaskExecutor threadPoolTaskExecutor threadPoolTaskExecutor.getActiveCount(), threadPoolTaskExecutor.getThreadPoolExecutor().getTaskCount(), threadPoolQueueSize); } - - @Value("${config.server.file.storage.uri}") - private String configServerFileStorageURL; - - @Value("${credential.service.mvel.file}") - private String mvelFile; - @Autowired - @Qualifier("restTemplate") - private RestTemplate restTemplate; - - @Bean("mask") - public VariableResolverFactory getVariableResolverFactory() { - String mvelExpression = restTemplate.getForObject(configServerFileStorageURL + mvelFile, String.class); - VariableResolverFactory functionFactory = new MapVariableResolverFactory(); - MVEL.eval(mvelExpression, functionFactory); - return functionFactory; - } - } \ No newline at end of file diff --git a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/entity/Vid.java b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/entity/Vid.java index c964759e1..40a3995ce 100644 --- a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/entity/Vid.java +++ b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/entity/Vid.java @@ -2,10 +2,10 @@ import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Data; @@ -26,15 +26,19 @@ public class Vid implements Comparable { /** The Id value */ @Id + @Column(name = "id") private String id; /** The vid value */ + @Column(name = "vid") private String vid; /** The uin Hash value */ + @Column(name = "uin_hash") private String uinHash; /** The uin value */ + @Column(name = "uin") private String uin; /** The value to hold vid Type Code */ @@ -50,6 +54,7 @@ public class Vid implements Comparable { private LocalDateTime expiryDTimes; /** The value to hold status Code */ + @Column(name = "status_code") private String statusCode; /** The value to hold created By */ @@ -69,7 +74,7 @@ public class Vid implements Comparable { private LocalDateTime updatedDTimes; /** The boolean of isDeleted */ - @Column(nullable = true) + @Column(name="is_deleted", nullable = true) private boolean isDeleted; /** The value to hold deleted DTimes */ diff --git a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/httpfilter/IdRepoFilter.java b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/httpfilter/IdRepoFilter.java index 861ba5dde..bd39f1d68 100644 --- a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/httpfilter/IdRepoFilter.java +++ b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/httpfilter/IdRepoFilter.java @@ -1,6 +1,6 @@ package io.mosip.idrepository.vid.httpfilter; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.springframework.stereotype.Component; diff --git a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/interceptor/IdRepoVidEntityInterceptor.java b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/interceptor/IdRepoVidEntityInterceptor.java index 307a6bac2..a7d9d8eff 100644 --- a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/interceptor/IdRepoVidEntityInterceptor.java +++ b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/interceptor/IdRepoVidEntityInterceptor.java @@ -8,10 +8,11 @@ import java.util.Arrays; import java.util.List; -import org.hibernate.EmptyInterceptor; +import org.hibernate.Interceptor; import org.hibernate.type.Type; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import io.mosip.idrepository.core.exception.IdRepoAppException; @@ -29,7 +30,7 @@ * @author Manoj SP */ @Component -public class IdRepoVidEntityInterceptor extends EmptyInterceptor { +public class IdRepoVidEntityInterceptor implements Interceptor { @Value("${" + UIN_REFID + "}") private String uinRefId; @@ -44,6 +45,7 @@ public class IdRepoVidEntityInterceptor extends EmptyInterceptor { private static final long serialVersionUID = 4985336846122302850L; /** The IdRepo Security Manager */ + @Lazy @Autowired private transient IdRepoSecurityManager securityManager; @@ -73,7 +75,7 @@ public boolean onSave(Object entity, Serializable id, Object[] state, String[] p mosipLogger.error(IdRepoSecurityManager.getUser(), ID_REPO_ENTITY_INTERCEPTOR, "onSave", "\n" + e.getMessage()); throw new IdRepoAppUncheckedException(ENCRYPTION_DECRYPTION_FAILED, e); } - return super.onSave(entity, id, state, propertyNames, types); + return Interceptor.super.onSave(entity, id, state, propertyNames, types); } /* @@ -104,6 +106,6 @@ public boolean onFlushDirty(Object entity, Serializable id, Object[] currentStat mosipLogger.error(IdRepoSecurityManager.getUser(), ID_REPO_ENTITY_INTERCEPTOR, "onFlushDirty", "\n" + e.getMessage()); throw new IdRepoAppUncheckedException(ENCRYPTION_DECRYPTION_FAILED, e); } - return super.onFlushDirty(entity, id, currentState, currentState, propertyNames, types); + return Interceptor.super.onFlushDirty(entity, id, currentState, currentState, propertyNames, types); } } \ No newline at end of file diff --git a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/provider/VidPolicyProvider.java b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/provider/VidPolicyProvider.java index 952bc933e..246e6430c 100644 --- a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/provider/VidPolicyProvider.java +++ b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/provider/VidPolicyProvider.java @@ -11,7 +11,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.context.config.annotation.RefreshScope; diff --git a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/service/impl/VidServiceImpl.java b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/service/impl/VidServiceImpl.java index 5a11539f3..2b9a886f0 100644 --- a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/service/impl/VidServiceImpl.java +++ b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/service/impl/VidServiceImpl.java @@ -29,7 +29,7 @@ import java.util.Objects; import java.util.stream.Collectors; -import javax.annotation.Resource; +import jakarta.annotation.Resource; import org.hibernate.exception.JDBCConnectionException; import org.mvel2.MVEL; diff --git a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/validator/VidRequestValidator.java b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/validator/VidRequestValidator.java index 31a878232..4d2a4e27b 100644 --- a/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/validator/VidRequestValidator.java +++ b/id-repository/id-repository-vid-service/src/main/java/io/mosip/idrepository/vid/validator/VidRequestValidator.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.Objects; -import javax.annotation.Resource; +import jakarta.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/id-repository/pom.xml b/id-repository/pom.xml index 0098001a3..007727b4c 100644 --- a/id-repository/pom.xml +++ b/id-repository/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 io.mosip.idrepository id-repository-parent @@ -9,7 +11,7 @@ ID-Repository MOSIP ID-Repository https://github.com/mosip/id-repository - + MPL 2.0 @@ -33,27 +35,27 @@ - - - ossrh - CentralRepository - https://oss.sonatype.org/content/repositories/snapshots - default - - true - - - - central - MavenCentral - default - https://repo1.maven.org/maven2 - - false - - - - + + + ossrh + CentralRepository + https://oss.sonatype.org/content/repositories/snapshots + default + + true + + + + central + MavenCentral + default + https://repo1.maven.org/maven2 + + false + + + + ossrh @@ -64,85 +66,105 @@ https://oss.sonatype.org/service/local/staging/deploy/maven2/ - + id-repository-core id-repository-vid-service id-repository-identity-service - credential-request-generator - credential-service - id-repository-salt-generator - id-repository-credentials-feeder + credential-request-generator + credential-service + id-repository-salt-generator + id-repository-credentials-feeder - + ${parent.version} 3.0.2 3.1.0 2.22.0 - 0.8.5 + 0.8.11 3.7.0.1746 3.2.0 - **/constant/**,**/config/**,**/httpfilter/**,**/cache/**,**/dto/**,**/entity/**,**/model/**,**/exception/**,**/repository/**,**/security/**,**/*Config.java,**/*BootApplication.java,**/*VertxApplication.java,**/cbeffutil/** + + **/constant/**,**/config/**,**/httpfilter/**,**/cache/**,**/dto/**,**/entity/**,**/model/**,**/exception/**,**/repository/**,**/security/**,**/*Config.java,**/*BootApplication.java,**/*VertxApplication.java,**/cbeffutil/** **/dto/**,**/entity/**,**/config/**,**/api/** - 11 - 11 + 21 + 21 3.8.0 - + 2.0.2.RELEASE 2.0.7.RELEASE 5.0.5.RELEASE 2.0.0.RELEASE - + 4.5.6 1.18.8 0.6.0 2.9.2 1.4.197 - + 4.12 - 2.22.0 - + 3.4.3 1.2.1-SNAPSHOT + 1.2.1-SNAPSHOT + 0.8.11 - - + + + + io.mosip.kernel + kernel-bom + 1.2.1-SNAPSHOT + pom + import + + + + + + + + + org.junit.vintage + junit-vintage-engine + junit junit - ${junit.version} test - - + + + io.mosip.kernel + kernel-biometrics-api + 1.2.1-SNAPSHOT + + + javax.xml.bind jaxb-api - 2.3.1 - javax.activation - activation - 1.1 + javax.activation + activation org.glassfish.jaxb jaxb-runtime - 2.3.1 - org.mockito - mockito-core - ${mockito.version} - test + org.mockito + mockito-core + test + 3.11.2 - org.javassist - javassist - 3.27.0-GA + org.javassist + javassist @@ -151,8 +173,13 @@ kernel-logger-logback ${kernel.logger.logback.version} + + org.springdoc + springdoc-openapi-starter-webmvc-ui + 2.5.0 + - + @@ -160,10 +187,17 @@ maven-surefire-plugin ${maven.surefire.plugin.version} - ${skipTests} + false false - ${argLine} --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --illegal-access=permit + ${argLine} + --add-opens java.base/java.lang=ALL-UNNAMED + --add-opens java.base/sun.reflect.annotation=ALL-UNNAMED + --add-opens java.base/sun.security.jca=ALL-UNNAMED + --add-opens java.base/sun.security.util=ALL-UNNAMED + --add-opens java.base/jdk.internal.util=ALL-UNNAMED + --add-opens java.base/java.util=ALL-UNNAMED + --illegal-access=debug @@ -236,119 +270,126 @@ maven-javadoc-plugin ${maven.javadoc.version} - true none - maven-deploy-plugin - 2.8.1 - - - default-deploy - deploy - - deploy - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - - default-deploy - deploy - - deploy - - - - - ossrh - https://oss.sonatype.org/ - false - - + maven-deploy-plugin + 2.8.1 + + + default-deploy + deploy + + deploy + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + + default-deploy + deploy + + deploy + + + + + ossrh + https://oss.sonatype.org/ + false + + - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + - - org.apache.maven.plugins - maven-javadoc-plugin - 3.2.0 - - - attach-javadocs - - jar - - - - - none - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - --pinentry-mode - loopback - - - - - - - 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-javadoc-plugin + 3.2.0 + + + attach-javadocs + + jar + + + + + none + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + 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-compiler-plugin + + true + + @@ -415,7 +456,8 @@ --server.port=8090 - --server.servlet.path=/app/generic + + --server.servlet.path=/app/generic @@ -447,10 +489,10 @@ - http://localhost:8090/app/generic/v3/api-docs + + http://localhost:8090/app/generic/v3/api-docs ${name}-openapi.json ${project.build.directory} - false