From d58d604a7ba17876e3dc4af1d8b4e91a925f1d71 Mon Sep 17 00:00:00 2001
From: Pawan k <128481755+kumarpawantarento@users.noreply.github.com>
Date: Tue, 8 Aug 2023 17:26:56 +0530
Subject: [PATCH 01/43] RC-Synch
---
java/123.bat | 4 +
java/claim/Dockerfile | 2 +-
java/claim/pom.xml | 77 +++-
.../sunbirdrc/claim/config/EmailConfig.java | 20 +
.../controller/CredentialsController.java | 89 ++++
.../claim/controller/EmailController.java | 115 +++++
.../claim/controller/FileController.java | 55 +++
.../java/dev/sunbirdrc/claim/dto/BarCode.java | 28 ++
.../java/dev/sunbirdrc/claim/dto/FileDto.java | 12 +
.../java/dev/sunbirdrc/claim/dto/MailDto.java | 45 ++
.../dev/sunbirdrc/claim/dto/StudentDTO.java | 19 +
.../dev/sunbirdrc/claim/entity/Candidate.java | 80 ++++
.../dev/sunbirdrc/claim/entity/Claim.java | 7 +-
.../dev/sunbirdrc/claim/entity/ClaimUser.java | 32 ++
.../dev/sunbirdrc/claim/entity/Course.java | 59 +++
.../sunbirdrc/claim/entity/Credentials.java | 50 +++
.../dev/sunbirdrc/claim/entity/Learner.java | 33 ++
.../dev/sunbirdrc/claim/entity/Student.java | 27 ++
.../claim/entity/StudentDetails.java | 90 ++++
.../claim/entity/StudentRequest.java | 34 ++
.../dev/sunbirdrc/claim/entity/Subject.java | 40 ++
.../sunbirdrc/claim/entity/YearsOfCourse.java | 48 ++
.../claim/exception/BadRequestException.java | 14 +
.../claim/exception/FileWriteException.java | 14 +
.../exception/GCPFileUploadException.java | 14 +
.../exception/InvalidFileTypeException.java | 14 +
.../sunbirdrc/claim/model/ClaimStatus.java | 6 +-
.../claim/repository/CandidateRepository.java | 10 +
.../claim/repository/ClaimUserRepository.java | 9 +
.../claim/repository/CourseRepository.java | 9 +
.../repository/CredentialsRepository.java | 10 +
.../claim/repository/LearnerRepository.java | 14 +
.../repository/YearOfCourseRepository.java | 9 +
.../sunbirdrc/claim/service/ClaimService.java | 14 +-
.../claim/service/CredentialsService.java | 91 ++++
.../sunbirdrc/claim/service/EmailService.java | 102 +++++
.../sunbirdrc/claim/service/FileService.java | 14 +
.../claim/service/FileServiceImpl.java | 57 +++
.../dev/sunbirdrc/claim/status/Status.java | 8 +
.../sunbirdrc/claim/utils/GCPBucketUtil.java | 150 +++++++
.../src/main/resources/application.properties | 38 +-
.../claim/service/ClaimServiceTest.java | 5 +-
.../registry/app/SunbirdRCApplication.java | 1 +
.../controller/RegistryEntityController.java | 199 ++++++++-
.../sunbirdrc/registry/dao/Credential.java | 11 +
.../dev/sunbirdrc/registry/dao/Learner.java | 14 +
.../dao/digilocker/pulldoc/DataContent.java | 18 +
.../dao/digilocker/pulldoc/DocContent.java | 19 +
.../dao/digilocker/pulldoc/DocDetailsRq.java | 31 ++
.../dao/digilocker/pulldoc/DocDetailsRs.java | 31 ++
.../digilocker/pulldoc/DocDetailsType.java | 33 ++
.../registry/dao/digilocker/pulldoc/Main.java | 74 ++++
.../digilocker/pulldoc/PullDocRequest.java | 68 +++
.../digilocker/pulldoc/PullDocResponse.java | 39 ++
.../digilocker/pulldoc/ResponseStatus.java | 41 ++
.../pulluriresponse/DocDetails.java | 47 ++
.../digilocker/pulluriresponse/IssuedTo.java | 21 +
.../digilocker/pulluriresponse/Person.java | 51 +++
.../digilocker/pulluriresponse/Persons.java | 21 +
.../digilocker/pulluriresponse/PhotoBean.java | 30 ++
.../pulluriresponse/PullURIResponse.java | 30 ++
.../pulluriresponse/ResponseUriStatus.java | 41 ++
.../digilocker/pulldoc/DataContent.java | 18 +
.../digilocker/pulldoc/DocContent.java | 19 +
.../digilocker/pulldoc/DocDetailsRq.java | 31 ++
.../digilocker/pulldoc/DocDetailsRs.java | 31 ++
.../digilocker/pulldoc/DocDetailsType.java | 33 ++
.../registry/digilocker/pulldoc/Main.java | 74 ++++
.../digilocker/pulldoc/PullDocRequest.java | 68 +++
.../digilocker/pulldoc/PullDocResponse.java | 39 ++
.../digilocker/pulldoc/ResponseStatus.java | 41 ++
.../pulluriresponse/DocDetails.java | 47 ++
.../digilocker/pulluriresponse/IssuedTo.java | 21 +
.../digilocker/pulluriresponse/Person.java | 51 +++
.../digilocker/pulluriresponse/Persons.java | 21 +
.../digilocker/pulluriresponse/PhotoBean.java | 30 ++
.../pulluriresponse/PullURIResponse.java | 30 ++
.../pulluriresponse/ResponseUriStatus.java | 41 ++
.../registry/helper/RegistryHelper.java | 113 +++++
.../sunbirdrc/registry/model/dto/BarCode.java | 28 ++
.../sunbirdrc/registry/model/dto/MailDto.java | 43 ++
.../sunbirdrc/registry/model/dto/Status.java | 15 +
.../registry/service/ISearchService.java | 12 +-
.../service/impl/CertificateServiceImpl.java | 64 ++-
.../registry/util/ClaimRequestClient.java | 121 ++++-
.../registry/util/CredentialConstant.java | 27 ++
.../registry/util/DigiLockerUtils.java | 307 +++++++++++++
.../sunbirdrc/registry/util/DocDetails.java | 94 ++++
.../registry/util/HmacSecretKeyGenerator.java | 27 ++
.../registry/util/PullURIRequest.java | 21 +
.../src/main/resources/application.yml | 16 +-
.../resources/public/_schemas/regulator.json | 49 +++
.../_schemas/studentForeignVerification.json | 261 +++++++++++
.../public/_schemas/studentFromUP.json | 352 +++++++++++++++
.../public/_schemas/studentGoodStanding.json | 240 ++++++++++
.../public/_schemas/studentNursingArmy.json | 371 ++++++++++++++++
.../public/_schemas/studentOutsideUp.json | 413 ++++++++++++++++++
.../resources/public/_schemas/teacher.json | 49 +++
98 files changed, 5569 insertions(+), 37 deletions(-)
create mode 100644 java/123.bat
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/config/EmailConfig.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/controller/CredentialsController.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/controller/EmailController.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/controller/FileController.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/dto/BarCode.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/dto/FileDto.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/dto/MailDto.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/dto/StudentDTO.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/entity/Candidate.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/entity/ClaimUser.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/entity/Course.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/entity/Credentials.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/entity/Learner.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/entity/Student.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/entity/StudentDetails.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/entity/StudentRequest.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/entity/Subject.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/entity/YearsOfCourse.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/exception/BadRequestException.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/exception/FileWriteException.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/exception/GCPFileUploadException.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/exception/InvalidFileTypeException.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/repository/CandidateRepository.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/repository/ClaimUserRepository.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/repository/CourseRepository.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/repository/CredentialsRepository.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/repository/LearnerRepository.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/repository/YearOfCourseRepository.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/service/CredentialsService.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/service/EmailService.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/service/FileService.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/service/FileServiceImpl.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/status/Status.java
create mode 100644 java/claim/src/main/java/dev/sunbirdrc/claim/utils/GCPBucketUtil.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/Credential.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/Learner.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulldoc/DataContent.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulldoc/DocContent.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulldoc/DocDetailsRq.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulldoc/DocDetailsRs.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulldoc/DocDetailsType.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulldoc/Main.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulldoc/PullDocRequest.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulldoc/PullDocResponse.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulldoc/ResponseStatus.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulluriresponse/DocDetails.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulluriresponse/IssuedTo.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulluriresponse/Person.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulluriresponse/Persons.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulluriresponse/PhotoBean.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulluriresponse/PullURIResponse.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/dao/digilocker/pulluriresponse/ResponseUriStatus.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulldoc/DataContent.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulldoc/DocContent.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulldoc/DocDetailsRq.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulldoc/DocDetailsRs.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulldoc/DocDetailsType.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulldoc/Main.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulldoc/PullDocRequest.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulldoc/PullDocResponse.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulldoc/ResponseStatus.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulluriresponse/DocDetails.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulluriresponse/IssuedTo.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulluriresponse/Person.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulluriresponse/Persons.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulluriresponse/PhotoBean.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulluriresponse/PullURIResponse.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/digilocker/pulluriresponse/ResponseUriStatus.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/model/dto/BarCode.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/model/dto/MailDto.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/model/dto/Status.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/util/CredentialConstant.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/util/DigiLockerUtils.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/util/DocDetails.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/util/HmacSecretKeyGenerator.java
create mode 100644 java/registry/src/main/java/dev/sunbirdrc/registry/util/PullURIRequest.java
create mode 100644 java/registry/src/main/resources/public/_schemas/regulator.json
create mode 100644 java/registry/src/main/resources/public/_schemas/studentForeignVerification.json
create mode 100644 java/registry/src/main/resources/public/_schemas/studentFromUP.json
create mode 100644 java/registry/src/main/resources/public/_schemas/studentGoodStanding.json
create mode 100644 java/registry/src/main/resources/public/_schemas/studentNursingArmy.json
create mode 100644 java/registry/src/main/resources/public/_schemas/studentOutsideUp.json
create mode 100644 java/registry/src/main/resources/public/_schemas/teacher.json
diff --git a/java/123.bat b/java/123.bat
new file mode 100644
index 000000000..60da3f3fa
--- /dev/null
+++ b/java/123.bat
@@ -0,0 +1,4 @@
+set MAVEN_HOME=D:\apache-maven-3.9.1\
+set PATH=%PATH%;D:\apache-maven-3.9.1\bin\
+set CLASSPATH=%CLASSPATH%;D:\apache-maven-3.9.1\lib\
+mvn clean install -DskipTests
\ No newline at end of file
diff --git a/java/claim/Dockerfile b/java/claim/Dockerfile
index 4f1f5af6e..a0e02df45 100644
--- a/java/claim/Dockerfile
+++ b/java/claim/Dockerfile
@@ -1,4 +1,4 @@
-FROM openjdk:8-jdk-alpine
+FROM openjdk:17-oracle
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
\ No newline at end of file
diff --git a/java/claim/pom.xml b/java/claim/pom.xml
index 056ac0da1..bb17d8bdc 100644
--- a/java/claim/pom.xml
+++ b/java/claim/pom.xml
@@ -13,19 +13,74 @@
- 1.8
+ 11
+ 4.1.1
+ 2022.0.1
org.springframework.boot
spring-boot-starter
+
+ net.sourceforge.barbecue
+ barbecue
+ 1.5-beta1
+
+
+ net.sf.barcode4j
+ barcode4j
+ 2.1
+
+
+ com.google.zxing
+ core
+ 3.3.0
+
+
+ com.google.zxing
+ javase
+ 3.3.0
+
+
+ com.opencsv
+ opencsv
+ 5.5.2
+
org.springframework.boot
spring-boot-starter-data-jpa
-
+
+ org.springframework.cloud
+ spring-cloud-gcp-starter-vision
+ 1.2.8.RELEASE
+
+
+ org.springframework.cloud
+ spring-cloud-gcp-starter-storage
+ 1.2.8.RELEASE
+
+
+ com.google.cloud
+ spring-cloud-gcp-starter-storage
+ 4.3.1
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ 2022.0.1
+ pom
+ import
+
+
+ com.google.cloud
+ spring-cloud-gcp-dependencies
+ 4.1.1
+ pom
+ import
+
org.postgresql
@@ -84,7 +139,21 @@
2.0.3
compile
-
+
+ org.springframework.boot
+ spring-boot-starter-mail
+
+
+
+ org.jsoup
+ jsoup
+ 1.15.3
+
+
+ org.json
+ json
+ 20210307
+
@@ -96,4 +165,4 @@
-
+
\ No newline at end of file
diff --git a/java/claim/src/main/java/dev/sunbirdrc/claim/config/EmailConfig.java b/java/claim/src/main/java/dev/sunbirdrc/claim/config/EmailConfig.java
new file mode 100644
index 000000000..d3d5634d5
--- /dev/null
+++ b/java/claim/src/main/java/dev/sunbirdrc/claim/config/EmailConfig.java
@@ -0,0 +1,20 @@
+package dev.sunbirdrc.claim.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.mail.SimpleMailMessage;
+
+@Configuration
+public class EmailConfig
+{
+ @Bean
+ public SimpleMailMessage emailTemplate()
+ {
+ SimpleMailMessage message = new SimpleMailMessage();
+ message.setTo("kumarpawans@gmail.com");
+ message.setFrom("shishir.suman@tarento.com");
+ message.setSubject("Identity Card link for UPSMF");
+ message.setText("FATAL - Application crash. Save your job !!");
+ return message;
+ }
+}
\ No newline at end of file
diff --git a/java/claim/src/main/java/dev/sunbirdrc/claim/controller/CredentialsController.java b/java/claim/src/main/java/dev/sunbirdrc/claim/controller/CredentialsController.java
new file mode 100644
index 000000000..fb0ba994a
--- /dev/null
+++ b/java/claim/src/main/java/dev/sunbirdrc/claim/controller/CredentialsController.java
@@ -0,0 +1,89 @@
+package dev.sunbirdrc.claim.controller;
+
+import dev.sunbirdrc.claim.entity.Learner;
+import dev.sunbirdrc.claim.service.CredentialsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/api/v1/credentials")
+public class CredentialsController {
+ @Autowired
+ private CredentialsService credentialService;
+
+ public CredentialsController(CredentialsService credentialService) {
+ this.credentialService = credentialService;
+ }
+
+
+ @PostMapping("/save")
+ public ResponseEntity saveLearnerWithCredentials(@RequestBody Learner learner) {
+ credentialService.saveLearnerWithCredentials(learner);
+ return ResponseEntity.ok("Learner with credentials saved successfully");
+ }
+
+
+ @GetMapping("/get")
+ public ResponseEntity> getAllLearnerWithCredentials() {
+ List learner = credentialService.getAllLearnerWithCredentials();
+ return ResponseEntity.ok(learner);
+ }
+
+ @GetMapping("/get/{learnerId}")
+ public ResponseEntity getLearnerWithCredentialsById(@PathVariable Long learnerId) {
+ Learner learner = credentialService.getLearnerWithCredentialsById(learnerId);
+ if (learner != null) {
+ return ResponseEntity.ok(learner);
+ } else {
+ return ResponseEntity.notFound().build();
+ }
+ }
+ @GetMapping("/getByName/{learnerName}")
+ public ResponseEntity> getLearnerWithCredentialsByName(@PathVariable String learnerName) {
+ List learners = credentialService.getLearnerWithCredentialsByName(learnerName);
+ if (!learners.isEmpty()) {
+ return ResponseEntity.ok(learners);
+ } else {
+ return ResponseEntity.notFound().build();
+ }
+ }
+ @GetMapping("/getByRollNumber/{rollNumber}")
+ public ResponseEntity getLearnerWithCredentialsByRollNumber(@PathVariable String rollNumber) {
+ Learner learner = credentialService.getLearnerWithCredentialsByRollNumber(rollNumber);
+ if (learner != null) {
+ return ResponseEntity.ok(learner);
+ } else {
+ return ResponseEntity.notFound().build();
+ }
+ }
+
+
+ @PutMapping("/update/{learnerId}")
+ public ResponseEntity updateLearnerWithCredentials(@PathVariable Long learnerId, @RequestBody Learner learner) {
+ Learner existinglearner = credentialService.getLearnerWithCredentialsById(learnerId);
+ if (existinglearner != null) {
+ learner.setId(existinglearner.getId());
+ Learner updatedLearner = credentialService.updateLearnerWithCredentials(learner);
+ return ResponseEntity.ok(updatedLearner);
+ } else {
+ return ResponseEntity.notFound().build();
+ }
+ }
+
+ @DeleteMapping("/delete/{learnerId}")
+ public ResponseEntity deleteLearnerWithCredentials(@PathVariable Long learnerId) {
+ Learner existinglearner = credentialService.getLearnerWithCredentialsById(learnerId);
+ if (existinglearner != null) {
+ credentialService.deleteLearnerWithCredentials(learnerId);
+ return ResponseEntity.ok("Learner with credentials deleted successfully");
+ } else {
+ return ResponseEntity.notFound().build();
+ }
+ }
+
+
+}
+
diff --git a/java/claim/src/main/java/dev/sunbirdrc/claim/controller/EmailController.java b/java/claim/src/main/java/dev/sunbirdrc/claim/controller/EmailController.java
new file mode 100644
index 000000000..4016b1b7d
--- /dev/null
+++ b/java/claim/src/main/java/dev/sunbirdrc/claim/controller/EmailController.java
@@ -0,0 +1,115 @@
+package dev.sunbirdrc.claim.controller;
+
+import dev.sunbirdrc.claim.dto.BarCode;
+import dev.sunbirdrc.claim.dto.MailDto;
+import dev.sunbirdrc.claim.service.EmailService;
+import net.sourceforge.barbecue.Barcode;
+import net.sourceforge.barbecue.BarcodeFactory;
+import net.sourceforge.barbecue.BarcodeImageHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.imageio.ImageIO;
+import javax.xml.bind.DatatypeConverter;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.util.Map;
+
+
+@Controller
+public class EmailController {
+
+ @Autowired
+ private EmailService emailService;
+ private static final Logger logger = LoggerFactory.getLogger(EmailController.class);
+ private static final Font BARCODE_TEXT_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 8);
+ @Autowired
+ public EmailController(EmailService emailService) {
+ this.emailService = emailService;
+ }
+
+ @RequestMapping(value = "/api/v1/sendMail", method = RequestMethod.POST)
+ public ResponseEntity
+
+ "We are pleased to inform you that a ${credType} has been issued to you. You can view and download the credential by using the following link.
+
+ ${idLink}
+
+ Thank you,
+ < Registration Credential Issuing Authority >
+
+
diff --git a/java/claim/src/main/resources/templates/pending-item-mail.ftl b/java/claim/src/main/resources/templates/pending-item-mail.ftl
new file mode 100644
index 000000000..98d67435c
--- /dev/null
+++ b/java/claim/src/main/resources/templates/pending-item-mail.ftl
@@ -0,0 +1,12 @@
+
+
+ Hi ${name}
+
+ "We are pleased to inform you that a ${credType} has been issued to you. You can view and download the credential by using the following link.
+
+ ${idLink}
+
+ Thank you,
+ < Registration Credential Issuing Authority >
+
+
diff --git a/java/registry/src/main/java/dev/sunbirdrc/registry/model/dto/PendingMailDTO.java b/java/registry/src/main/java/dev/sunbirdrc/registry/model/dto/PendingMailDTO.java
new file mode 100644
index 000000000..349f9143e
--- /dev/null
+++ b/java/registry/src/main/java/dev/sunbirdrc/registry/model/dto/PendingMailDTO.java
@@ -0,0 +1,15 @@
+package dev.sunbirdrc.registry.model.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class PendingMailDTO {
+ private String name;
+ private String emailAddress;
+ private String council;
+ private String itemName;
+}
From 21e8169ee54451bf73c7360fbffc08374eab4559 Mon Sep 17 00:00:00 2001
From: rkrahu
Date: Wed, 16 Aug 2023 12:51:20 +0530
Subject: [PATCH 19/43] Mail integration up-to pending Item
---
java/claim/pom.xml | 4 +
.../claim/config/PropertyMapper.java | 11 ++
.../claim/controller/EmailController.java | 14 ++
.../sunbirdrc/claim/dto/PendingMailDTO.java | 11 ++
.../sunbirdrc/claim/service/EmailService.java | 125 ++++++++++++++++++
.../src/main/resources/application.properties | 16 ++-
.../resources/templates/pending-item-mail.ftl | 4 +-
.../controller/RegistryEntityController.java | 31 +++++
.../registry/util/ClaimRequestClient.java | 10 +-
9 files changed, 217 insertions(+), 9 deletions(-)
diff --git a/java/claim/pom.xml b/java/claim/pom.xml
index bb17d8bdc..39b13a0c3 100644
--- a/java/claim/pom.xml
+++ b/java/claim/pom.xml
@@ -154,6 +154,10 @@
json
20210307
+
+ org.freemarker
+ freemarker
+
diff --git a/java/claim/src/main/java/dev/sunbirdrc/claim/config/PropertyMapper.java b/java/claim/src/main/java/dev/sunbirdrc/claim/config/PropertyMapper.java
index e0e537548..b5302aa38 100644
--- a/java/claim/src/main/java/dev/sunbirdrc/claim/config/PropertyMapper.java
+++ b/java/claim/src/main/java/dev/sunbirdrc/claim/config/PropertyMapper.java
@@ -1,4 +1,15 @@
package dev.sunbirdrc.claim.config;
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+@Data
public class PropertyMapper {
+ @Value("${simple.mail.message.from}")
+ private String simpleMailMessageFrom;
+
+ @Value("${foreign.pending.item.subject}")
+ private String foreignPendingItemSubject;
}
diff --git a/java/claim/src/main/java/dev/sunbirdrc/claim/controller/EmailController.java b/java/claim/src/main/java/dev/sunbirdrc/claim/controller/EmailController.java
index 4016b1b7d..da3f0d72d 100644
--- a/java/claim/src/main/java/dev/sunbirdrc/claim/controller/EmailController.java
+++ b/java/claim/src/main/java/dev/sunbirdrc/claim/controller/EmailController.java
@@ -1,7 +1,9 @@
package dev.sunbirdrc.claim.controller;
import dev.sunbirdrc.claim.dto.BarCode;
+import dev.sunbirdrc.claim.dto.CertificateMailDto;
import dev.sunbirdrc.claim.dto.MailDto;
+import dev.sunbirdrc.claim.dto.PendingMailDTO;
import dev.sunbirdrc.claim.service.EmailService;
import net.sourceforge.barbecue.Barcode;
import net.sourceforge.barbecue.BarcodeFactory;
@@ -111,5 +113,17 @@ private String prepareBody(String idLink, String name, String credType) {
return body;
}
+ @RequestMapping(value = "/api/v1/sendCertificateMail", method = RequestMethod.POST)
+ public ResponseEntity sendCertificateMail(@RequestBody CertificateMailDto certificateMailDto) {
+ emailService.sendCertificateMail(certificateMailDto);
+ return new ResponseEntity<>("Mail is sending", HttpStatus.OK);
+ }
+
+ @RequestMapping(value = "/api/v1/sendPendingForeignItemMail", method = RequestMethod.POST)
+ public ResponseEntity sendPendingItemMail(@RequestHeader HttpHeaders headers,
+ @RequestBody PendingMailDTO pendingMailDTO) {
+ emailService.sendPendingMail(pendingMailDTO);
+ return new ResponseEntity<>("Mail is sending", HttpStatus.OK);
+ }
}
diff --git a/java/claim/src/main/java/dev/sunbirdrc/claim/dto/PendingMailDTO.java b/java/claim/src/main/java/dev/sunbirdrc/claim/dto/PendingMailDTO.java
index 90147742f..50c3cf3d0 100644
--- a/java/claim/src/main/java/dev/sunbirdrc/claim/dto/PendingMailDTO.java
+++ b/java/claim/src/main/java/dev/sunbirdrc/claim/dto/PendingMailDTO.java
@@ -1,4 +1,15 @@
package dev.sunbirdrc.claim.dto;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
public class PendingMailDTO {
+ private String name;
+ private String emailAddress;
+ private String council;
+ private String itemName;
}
diff --git a/java/claim/src/main/java/dev/sunbirdrc/claim/service/EmailService.java b/java/claim/src/main/java/dev/sunbirdrc/claim/service/EmailService.java
index a40f8dcd3..1777c7096 100644
--- a/java/claim/src/main/java/dev/sunbirdrc/claim/service/EmailService.java
+++ b/java/claim/src/main/java/dev/sunbirdrc/claim/service/EmailService.java
@@ -1,27 +1,56 @@
package dev.sunbirdrc.claim.service;
+import dev.sunbirdrc.claim.config.PropertyMapper;
+import dev.sunbirdrc.claim.controller.EmailController;
+import dev.sunbirdrc.claim.dto.CertificateMailDto;
+import dev.sunbirdrc.claim.dto.MailDto;
+import dev.sunbirdrc.claim.dto.PendingMailDTO;
+import dev.sunbirdrc.claim.exception.ClaimMailException;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.mail.MailException;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.mail.javamail.MimeMessagePreparator;
+import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
+import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
import javax.mail.Message;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.io.File;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.HashMap;
+import java.util.Map;
@Service("emailService")
public class EmailService
{
+ private static final Logger logger = LoggerFactory.getLogger(EmailController.class);
@Autowired
private JavaMailSender mailSender;
@Autowired
private SimpleMailMessage preConfiguredMessage;
+
+ @Autowired
+ private Configuration freeMarkerConfiguration;
+
+ @Value("${simple.mail.message.from}")
+ private String simpleMailMessageFrom;
+
+ @Autowired
+ private PropertyMapper propertyMapper;
/**
* This method will send compose and send the message
@@ -99,4 +128,100 @@ public void prepare(MimeMessage mimeMessage) throws Exception
System.err.println(ex.getMessage());
}
}
+
+ @Async
+ public void sendCertificateMail(CertificateMailDto certificateMailDto) {
+ String subject = certificateMailDto.getCredentialsType();
+
+ try {
+ MimeMessage mimeMessage = mailSender.createMimeMessage();
+
+ MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, true);
+
+ mimeMessageHelper.setSubject(subject);
+ mimeMessageHelper.setFrom(new InternetAddress(propertyMapper.getSimpleMailMessageFrom(), certificateMailDto.getName()));
+ mimeMessageHelper.setTo(certificateMailDto.getEmailAddress());
+ mimeMessageHelper.setText(generateAttachedCertificateMailContent(certificateMailDto), true);
+
+
+ byte[] doc = Base64.getDecoder().decode(certificateMailDto.getCertificateBase64());
+ mimeMessageHelper.addAttachment("certificate.pdf", new ByteArrayResource(doc));
+
+ mailSender.send(mimeMessageHelper.getMimeMessage());
+ } catch (Exception e) {
+ logger.error("Exception while sending mail: ", e);
+ throw new ClaimMailException("Exception while composing and sending mail with OTP");
+ }
+ }
+
+ private String generateAttachedCertificateMailContent(CertificateMailDto certificateMailDto) {
+ String processedTemplateString = null;
+
+ Map mailMap = new HashMap<>();
+ mailMap.put("name", certificateMailDto.getName());
+ mailMap.put("credType", certificateMailDto.getCredentialsType());
+ mailMap.put("idLink", certificateMailDto.getCertificate());
+
+ try {
+ freeMarkerConfiguration.setClassForTemplateLoading(this.getClass(), "/templates/");
+ Template template = freeMarkerConfiguration.getTemplate("credentials-mail.ftl");
+ processedTemplateString = FreeMarkerTemplateUtils.processTemplateIntoString(template, mailMap);
+
+ } catch (TemplateException e) {
+ logger.error("TemplateException while creating mail template for certificate ", e);
+ throw new ClaimMailException("Error while creating mail template for certificate");
+ } catch (IOException e) {
+ logger.error("IOException while creating mail template for certificate ", e);
+ throw new ClaimMailException("Error while creating mail template for certificate");
+ }
+ return processedTemplateString;
+ }
+
+ @Async
+ public void sendPendingMail(PendingMailDTO pendingMailDTO) {
+
+ try {
+ MimeMessage mimeMessage = mailSender.createMimeMessage();
+
+ MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, true);
+
+ mimeMessageHelper.setSubject(propertyMapper.getForeignPendingItemSubject());
+ mimeMessageHelper.setFrom(new InternetAddress(propertyMapper.getSimpleMailMessageFrom(),pendingMailDTO.getName()));
+ mimeMessageHelper.setTo(pendingMailDTO.getEmailAddress());
+ mimeMessageHelper.setText(generateCertificateMailContent(pendingMailDTO), true);
+
+ mailSender.send(mimeMessageHelper.getMimeMessage());
+ } catch (Exception e) {
+ logger.error("Exception while sending mail: ", e);
+ throw new ClaimMailException("Exception while composing and sending mail with OTP");
+ }
+
+ }
+
+ /**
+ * @param mailDto
+ * @return
+ */
+ private String generateCertificateMailContent(PendingMailDTO pendingMailDTO) {
+ String processedTemplateString = null;
+
+ Map mailMap = new HashMap<>();
+ mailMap.put("name", pendingMailDTO.getName());
+ mailMap.put("council", pendingMailDTO.getCouncil());
+ mailMap.put("itemName", pendingMailDTO.getItemName());
+
+ try {
+ freeMarkerConfiguration.setClassForTemplateLoading(this.getClass(), "/templates/");
+ Template template = freeMarkerConfiguration.getTemplate("pending-item-mail.ftl");
+ processedTemplateString = FreeMarkerTemplateUtils.processTemplateIntoString(template, mailMap);
+
+ } catch (TemplateException e) {
+ logger.error("TemplateException while creating mail template for certificate ", e);
+ throw new ClaimMailException("Error while creating mail template for certificate");
+ } catch (IOException e) {
+ logger.error("IOException while creating mail template for certificate ", e);
+ throw new ClaimMailException("Error while creating mail template for certificate");
+ }
+ return processedTemplateString;
+ }
}
diff --git a/java/claim/src/main/resources/application.properties b/java/claim/src/main/resources/application.properties
index cada3cd1e..d60a5fb9d 100644
--- a/java/claim/src/main/resources/application.properties
+++ b/java/claim/src/main/resources/application.properties
@@ -1,6 +1,6 @@
server.port=8082
-spring.datasource.url=${connectionInfo_uri:jdbc:postgresql://localhost:5432/registry}
+spring.datasource.url=${connectionInfo_uri:jdbc:postgresql://localhost:5432/registry5}
spring.datasource.username=${connectionInfo_username:postgres}
spring.datasource.password=${connectionInfo_password:postgres}
@@ -9,11 +9,11 @@ spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
sunbirdrc.url=${sunbirdrc_url:http://localhost:8081}
-spring.mail.host=smtp.sendgrid.net
-spring.mail.port=587
-spring.mail.username=apikey
-
-spring.mail.password=
+spring.mail.host=smtp.gmail.com
+spring.mail.port=465
+spring.mail.username=upsmf.otp@upsmfac.org
+spring.mail.password=OTP22023##
+spring.mail.properties.mail.smtp.ssl.enable = true
# Other properties
@@ -42,4 +42,8 @@ gcp.file.validity=2
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB
+# Mail config
+simple.mail.message.from = r.kishor.rahu@gmail.com
+foreign.pending.item.subject = Pending Item
+
diff --git a/java/claim/src/main/resources/templates/pending-item-mail.ftl b/java/claim/src/main/resources/templates/pending-item-mail.ftl
index 98d67435c..876281666 100644
--- a/java/claim/src/main/resources/templates/pending-item-mail.ftl
+++ b/java/claim/src/main/resources/templates/pending-item-mail.ftl
@@ -2,9 +2,9 @@
Hi ${name}
- "We are pleased to inform you that a ${credType} has been issued to you. You can view and download the credential by using the following link.
+ We have pending item for ${council}, which have been requested
- ${idLink}
+ Item name:
${itemName}
Thank you,
< Registration Credential Issuing Authority >
diff --git a/java/registry/src/main/java/dev/sunbirdrc/registry/controller/RegistryEntityController.java b/java/registry/src/main/java/dev/sunbirdrc/registry/controller/RegistryEntityController.java
index 827152ba3..e92abd721 100644
--- a/java/registry/src/main/java/dev/sunbirdrc/registry/controller/RegistryEntityController.java
+++ b/java/registry/src/main/java/dev/sunbirdrc/registry/controller/RegistryEntityController.java
@@ -23,11 +23,13 @@
import dev.sunbirdrc.registry.middleware.util.Constants;
import dev.sunbirdrc.registry.middleware.util.JSONUtil;
import dev.sunbirdrc.registry.middleware.util.OSSystemFields;
+import dev.sunbirdrc.registry.model.dto.PendingMailDTO;
import dev.sunbirdrc.registry.service.FileStorageService;
import dev.sunbirdrc.registry.service.impl.CertificateServiceImpl;
import dev.sunbirdrc.registry.transform.Configuration;
import dev.sunbirdrc.registry.transform.Data;
import dev.sunbirdrc.registry.transform.ITransformer;
+import dev.sunbirdrc.registry.util.ClaimRequestClient;
import org.agrona.Strings;
import dev.sunbirdrc.registry.util.DigiLockerUtils;
import dev.sunbirdrc.registry.util.DocDetails;
@@ -84,6 +86,9 @@ public class RegistryEntityController extends AbstractController {
@Value("${certificate.enableExternalTemplates:false}")
boolean externalTemplatesEnabled;
+ @Autowired
+ private ClaimRequestClient claimRequestClient;
+
@RequestMapping(value = "/api/v1/{entityName}/invite", method = RequestMethod.POST)
public ResponseEntity invite(
@PathVariable String entityName,
@@ -1207,4 +1212,30 @@ public ResponseEntity putSingleEntityFile(
}
}
+ @RequestMapping(value = "/api/v1/{entityName}/sendPendingForeignItemMail", method = RequestMethod.POST)
+ public ResponseEntity sendPendingForeignItemMail(@PathVariable String entityName,
+ @RequestBody PendingMailDTO pendingMailDTO,
+ HttpServletRequest request) {
+
+ ResponseParams responseParams = new ResponseParams();
+ Response response = new Response(Response.API_ID.SEND, "OK", responseParams);
+
+ try {
+ registryHelper.authorizeInviteEntity(request, entityName);
+
+ String mailStatus = claimRequestClient.sendPendingForeignItemMail(pendingMailDTO);
+
+ response.setResult(mailStatus);
+ responseParams.setStatus(Response.Status.SUCCESSFUL);
+
+ } catch (Exception exception) {
+ logger.error("Exception : {}", exception.getMessage());
+ responseParams.setStatus(Response.Status.UNSUCCESSFUL);
+ responseParams.setErrmsg(exception.getMessage());
+ return new ResponseEntity<>(responseParams, HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+ return new ResponseEntity<>(response, HttpStatus.OK);
+ }
+
}
diff --git a/java/registry/src/main/java/dev/sunbirdrc/registry/util/ClaimRequestClient.java b/java/registry/src/main/java/dev/sunbirdrc/registry/util/ClaimRequestClient.java
index 6d824bcad..bd2c088c1 100644
--- a/java/registry/src/main/java/dev/sunbirdrc/registry/util/ClaimRequestClient.java
+++ b/java/registry/src/main/java/dev/sunbirdrc/registry/util/ClaimRequestClient.java
@@ -9,6 +9,7 @@
import dev.sunbirdrc.registry.model.dto.BarCode;
import dev.sunbirdrc.registry.model.dto.FileDto;
import dev.sunbirdrc.registry.model.dto.MailDto;
+import dev.sunbirdrc.registry.model.dto.PendingMailDTO;
import lombok.NonNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
@@ -47,6 +48,8 @@ public class ClaimRequestClient {
private static final String CLAIM_MULTI_FILE_UPLOAD = "/api/v1/files/upload/multiple";
private static String URL_APPENDER = "/";
+ private static final String MAIL_SEND_PENDING_FOREIGN_ITEM_URL = "/api/v1/sendPendingForeignItemMail";
+
ClaimRequestClient(@Value("${claims.url}") String claimRequestUrl, RestTemplate restTemplate) {
this.claimRequestUrl = claimRequestUrl;
this.restTemplate = restTemplate;
@@ -206,7 +209,12 @@ public List uploadCLaimMultipleFiles(@NonNull MultipartFile[] files, St
return fileDtoList;
}
-
+ public String sendPendingForeignItemMail(PendingMailDTO pendingMailDTO) {
+ String mailStatus = restTemplate.postForObject(
+ claimRequestUrl + MAIL_SEND_PENDING_FOREIGN_ITEM_URL, pendingMailDTO, String.class);
+ logger.info("Pending foreign item mail status: " + mailStatus);
+ return mailStatus;
+ }
From 3f240856e58c94dd4e02595a6c78db4aa6b104d0 Mon Sep 17 00:00:00 2001
From: rkrahu
Date: Wed, 16 Aug 2023 17:49:30 +0530
Subject: [PATCH 20/43] Added new feature to persist user credential through
API
---
java/pom.xml | 1 +
java/user-management/.gitignore | 38 +
java/user-management/pom.xml | 103 +++
.../sunbirdrc/UserManagementApplication.java | 22 +
.../config/ExceptionHandlerConfig.java | 82 ++
.../dev/sunbirdrc/config/KeycloakConfig.java | 54 ++
.../config/PropertiesValueMapper.java | 54 ++
.../dev/sunbirdrc/config/RedisConfig.java | 62 ++
.../sunbirdrc/config/WebSecurityConfig.java | 61 ++
.../sunbirdrc/controller/UserController.java | 155 ++++
.../main/java/dev/sunbirdrc/dto/AdminDTO.java | 17 +
.../java/dev/sunbirdrc/dto/AdminLoginDTO.java | 21 +
.../dto/BulkCustomUserResponseDTO.java | 17 +
.../java/dev/sunbirdrc/dto/BulkUserDTO.java | 16 +
.../java/dev/sunbirdrc/dto/CustomUserDTO.java | 33 +
.../sunbirdrc/dto/CustomUserDeleteDTO.java | 17 +
.../dev/sunbirdrc/dto/CustomUserLoginDTO.java | 21 +
.../sunbirdrc/dto/CustomUserResponseDTO.java | 17 +
.../sunbirdrc/dto/CustomUserUpdateDTO.java | 26 +
.../dev/sunbirdrc/dto/CustomUsernameDTO.java | 18 +
.../dev/sunbirdrc/dto/UserDetailsDTO.java | 44 ++
.../java/dev/sunbirdrc/dto/UserLoginDTO.java | 21 +
.../java/dev/sunbirdrc/dto/UserOtpDTO.java | 25 +
.../sunbirdrc/dto/UserTokenDetailsDTO.java | 25 +
.../dev/sunbirdrc/entity/UserCredential.java | 29 +
.../dev/sunbirdrc/entity/UserDetails.java | 40 +
.../exception/AuthorizationException.java | 11 +
.../exception/CipherEncoderException.java | 11 +
.../exception/InvalidInputDataException.java | 11 +
.../exception/KeycloakUserException.java | 11 +
.../dev/sunbirdrc/exception/OtpException.java | 11 +
.../exception/RoleNotFoundException.java | 11 +
.../exception/UserConflictException.java | 11 +
.../exception/UserCredentialsException.java | 10 +
.../exception/UserNotFoundException.java | 12 +
.../repository/UserCredentialRepository.java | 13 +
.../repository/UserDetailsRepository.java | 9 +
.../dev/sunbirdrc/service/MailService.java | 145 ++++
.../dev/sunbirdrc/service/UserService.java | 741 ++++++++++++++++++
.../dev/sunbirdrc/utils/CipherEncoder.java | 97 +++
.../java/dev/sunbirdrc/utils/OtpUtil.java | 80 ++
.../java/dev/sunbirdrc/utils/RedisUtil.java | 36 +
.../dev/sunbirdrc/utils/UserConstant.java | 17 +
.../src/main/resources/application.properties | 76 ++
.../templates/otp-verification-mail.ftl | 16 +
.../user-creation-notification-mail.ftl | 13 +
46 files changed, 2361 insertions(+)
create mode 100644 java/user-management/.gitignore
create mode 100644 java/user-management/pom.xml
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/UserManagementApplication.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/config/ExceptionHandlerConfig.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/config/KeycloakConfig.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/config/PropertiesValueMapper.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/config/RedisConfig.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/config/WebSecurityConfig.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/controller/UserController.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/dto/AdminDTO.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/dto/AdminLoginDTO.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/dto/BulkCustomUserResponseDTO.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/dto/BulkUserDTO.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/dto/CustomUserDTO.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/dto/CustomUserDeleteDTO.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/dto/CustomUserLoginDTO.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/dto/CustomUserResponseDTO.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/dto/CustomUserUpdateDTO.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/dto/CustomUsernameDTO.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/dto/UserDetailsDTO.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/dto/UserLoginDTO.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/dto/UserOtpDTO.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/dto/UserTokenDetailsDTO.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/entity/UserCredential.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/entity/UserDetails.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/exception/AuthorizationException.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/exception/CipherEncoderException.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/exception/InvalidInputDataException.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/exception/KeycloakUserException.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/exception/OtpException.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/exception/RoleNotFoundException.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/exception/UserConflictException.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/exception/UserCredentialsException.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/exception/UserNotFoundException.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/repository/UserCredentialRepository.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/repository/UserDetailsRepository.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/service/MailService.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/service/UserService.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/utils/CipherEncoder.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/utils/OtpUtil.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/utils/RedisUtil.java
create mode 100644 java/user-management/src/main/java/dev/sunbirdrc/utils/UserConstant.java
create mode 100644 java/user-management/src/main/resources/application.properties
create mode 100644 java/user-management/src/main/resources/templates/otp-verification-mail.ftl
create mode 100644 java/user-management/src/main/resources/templates/user-creation-notification-mail.ftl
diff --git a/java/pom.xml b/java/pom.xml
index 73c2c8b5b..10e18168f 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -41,6 +41,7 @@
claim
apitest
plugins
+ user-management
diff --git a/java/user-management/.gitignore b/java/user-management/.gitignore
new file mode 100644
index 000000000..5ff6309b7
--- /dev/null
+++ b/java/user-management/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/java/user-management/pom.xml b/java/user-management/pom.xml
new file mode 100644
index 000000000..d68a2b948
--- /dev/null
+++ b/java/user-management/pom.xml
@@ -0,0 +1,103 @@
+
+
+ 4.0.0
+
+ dev.sunbirdrc
+ user-management
+ 1.0-SNAPSHOT
+ user-management
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.5.0
+
+
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+ org.projectlombok
+ lombok
+
+
+ org.springframework.boot
+ spring-boot-starter-oauth2-resource-server
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.postgresql
+ postgresql
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+ redis.clients
+ jedis
+
+
+ org.freemarker
+ freemarker
+
+
+ org.springframework.boot
+ spring-boot-starter-mail
+
+
+ org.keycloak
+ keycloak-admin-client
+ 11.0.3
+
+
+ org.jboss.resteasy
+ resteasy-client
+ 3.1.3.Final
+
+
+ org.keycloak
+ keycloak-spring-security-adapter
+ 14.0.0
+ compile
+
+
+ org.keycloak
+ keycloak-spring-boot-adapter-core
+ 11.0.2
+ compile
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
\ No newline at end of file
diff --git a/java/user-management/src/main/java/dev/sunbirdrc/UserManagementApplication.java b/java/user-management/src/main/java/dev/sunbirdrc/UserManagementApplication.java
new file mode 100644
index 000000000..713d7d050
--- /dev/null
+++ b/java/user-management/src/main/java/dev/sunbirdrc/UserManagementApplication.java
@@ -0,0 +1,22 @@
+package dev.sunbirdrc;
+
+
+import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.scheduling.annotation.EnableAsync;
+
+
+@EnableAsync
+@SpringBootApplication
+public class UserManagementApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(UserManagementApplication.class, args);
+ }
+
+// @Bean
+// public KeycloakSpringBootConfigResolver keycloakSpringBootConfigResolver(){
+// return new KeycloakSpringBootConfigResolver();
+// }
+}
\ No newline at end of file
diff --git a/java/user-management/src/main/java/dev/sunbirdrc/config/ExceptionHandlerConfig.java b/java/user-management/src/main/java/dev/sunbirdrc/config/ExceptionHandlerConfig.java
new file mode 100644
index 000000000..47f660cb4
--- /dev/null
+++ b/java/user-management/src/main/java/dev/sunbirdrc/config/ExceptionHandlerConfig.java
@@ -0,0 +1,82 @@
+package dev.sunbirdrc.config;
+
+import dev.sunbirdrc.exception.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.validation.FieldError;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@RestControllerAdvice
+public class ExceptionHandlerConfig {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionHandlerConfig.class);
+
+ @ExceptionHandler(MethodArgumentNotValidException.class)
+ public ResponseEntity