diff --git a/.gitignore b/.gitignore
index ee8da6cd39d..b5174c70f51 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,28 @@
frontend/micro-ui-internals/node_modules/*
.idea
index.lock
+*.bak
+
+# dependencies
+/node_modules
+/packages/lib/*
+/packages/egov-ui-kit
+/packages/egov-ui-framework
+/packages/pgr-citizen
+/packages/pgr-employee
+/packages/pt-citizen
+/packages/pt-employee
+/packages/egov-tradelicence
+/packages/egov-pt
+/packages/egov-workflow
+/packages/egov-hrms
+/packages/egov-mp
+/packages/egov-uc
+/packages/egov-noc
+
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+lerna-debug.log*
+
+
diff --git a/CODEOWNERS b/CODEOWNERS
index 8baf2d23c82..096527c2e33 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -1,12 +1,9 @@
-* @gajendran-egov @sathishp-eGov
-*.yaml @gajendran-egov @sathishp-eGov
+* @gajendran-egov @sathishp-eGov @kavi-egov
+*.yaml @gajendran-egov @sathishp-eGov @kavi-egov
-* business-services/ @sathishp-eGov @talele08 @kavi-egov @sirishrao-egov
-* core-services/ @sathishp-eGov @talele08 @kavi-egov @sirishrao-egov
-* municipal-services/ @sathishp-eGov @talele08 @kavi-egov @sirishrao-egov
-* frontend/ @sathishp-eGov @talele08 @kavi-egov @sirishrao-egov
-* edcr/ @pradeep
-* finance/ @elzan
+business-services/ @sathishp-eGov @talele08 @kavi-egov @sirishrao-egov @subhashini-egov @talele08
+core-services/ @sathishp-eGov @talele08 @kavi-egov @sirishrao-egov @subhashini-egov @talele08
+municipal-services/ @sathishp-eGov @talele08 @kavi-egov @sirishrao-egov @subhashini-egov @talele08 @kapil-eGov @AmanKumar-eGov
##Frontend
frontend/micro-ui/ @sathishp-eGov @jagankumar-egov @saurabh-egov @sirishrao-egov
@@ -14,3 +11,7 @@ frontend/micro-ui-internals/ @sathishp-eGov @jagankumar-egov @saurabh-egov @siri
frontend/mono-ui/ @sathishp-eGov @jagankumar-egov @sirishrao-egov
+##Frontend
+frontend/micro-ui/ @sathishp-eGov @jagankumar-egov @sirishrao-egov @subhashini-egov @talele08
+frontend/micro-ui-internals/ @sathishp-eGov @jagankumar-egov @sirishrao-egov @subhashini-egov @talele08
+frontend/mono-ui/ @sathishp-eGov @jagankumar-egov @sirishrao-egov @subhashini-egov @talele08
diff --git a/README.md b/README.md
index 3750c3097ce..a236b2f58cb 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
-# UPYOG (Urban Platform for deliverY of Online Governance)
-
-UPYOG is a set of Open APIs, services, and reference implementations, setup as a public good, to allow government entities, businesses, startups, and civil society to use a unique digital Infrastructure and build solutions for urban India at a large scale. It provides a set of open standards, specifications and documentation to create a level playing field and enable ecosystem players to innovate on the stack. As a public good, the platform is provided without profit or restriction to all members of society.
+# DIGIT Urban Stack
+
+DIGIT is a set of Open APIs, services, and reference implementations, setup as a public good, to allow government entities, businesses, startups, and civil society to use a unique digital Infrastructure and build solutions for urban India at a large scale. It provides a set of open standards, specifications and documentation to create a level playing field and enable ecosystem players to innovate on the stack. As a public good, the platform is provided without profit or restriction to all members of society.
UPYOG focuses on inclusion and is designed on the principle of enhancing both platform openness and choice for citizens. The platform uses open APIs and standards, creating a powerful framework to drive convergence across the multiple systems currently in use, and to lower the barrier to entry for locally-developed solutions. Keeping in mind that most Indians use the internet through their phones, we follow and advocate a “mobile-first” approach, while supporting multi-channel access to accommodate diverse needs and preferences.
diff --git a/build/build-config.yml b/build/build-config.yml
index d9e13d00ae9..1c05982da7b 100644
--- a/build/build-config.yml
+++ b/build/build-config.yml
@@ -300,14 +300,13 @@ config:
image-name: "internal-gateway"
dockerfile: "build/maven/Dockerfile"
- - name: "builds/upyog/core-services/egov-user-event"
+ - name: "builds/upyog/municipal-services/egov-user-event"
build:
- - work-dir: "core-services/egov-user-event"
+ - work-dir: "municipal-services/egov-user-event"
image-name: "egov-user-event"
dockerfile: "build/maven/Dockerfile"
- - work-dir: "core-services/egov-user-event/src/main/resources/db"
- image-name: "egov-user-event-db"
- dockerfile: "build/maven/Dockerfile"
+ - work-dir: "municipal-services/egov-user-event/src/main/resources/db"
+ image-name: "egov-user-event-db"
- name: "builds/upyog/core-services/pdf-service"
build:
@@ -380,11 +379,16 @@ config:
- work-dir: "core-services/libraries/tracer"
image-name: "tracer"
- - name: "builds/upyog/core-services/nlp-engine"
+ - name: "builds/digit-dev/core-services/libraries/digit-models"
+ build:
+ - work-dir: "core-services/libraries/digit-models"
+ image-name: "digit-models"
+
+ - name: "builds/digit-dev/core-services/nlp-engine"
build:
- work-dir: "core-services/nlp-engine"
image-name: "nlp-engine"
- dockerfile: "nlp-engine/Dockerfile"
+ dockerfile: "core-services/nlp-engine/Dockerfile"
- name: "builds/upyog/core-services/xstate-chatbot"
build:
@@ -392,6 +396,14 @@ config:
image-name: "xstate-chatbot"
- work-dir: "core-services/xstate-chatbot/nodejs/db"
image-name: "xstate-chatbot-db"
+
+ - name: "builds/digit-dev/core-services/xstate-webchat"
+ build:
+ - work-dir: "core-services/xstate-webchat/nodejs"
+ image-name: "xstate-webchat"
+ - work-dir: "core-services/xstate-webchat/nodejs/db"
+ image-name: "xstate-webchat-db"
+
- name: "builds/upyog/core-services/xstate-webchat"
build:
@@ -616,14 +628,14 @@ config:
- work-dir: "municipal-services/birth-death-services/src/main/resources/db"
image-name: "birth-death-services-db"
- - name: "builds/upyog/municipal-services/birth-registration"
+ - name: "builds/upyog/tutorials/backend-developer-guide/btr-services"
build:
- - work-dir: "municipal-services/birth-registration"
- image-name: "birth-registration"
+ - work-dir: "tutorials/backend-developer-guide/btr-services"
+ image-name: "btr-services"
dockerfile: "build/maven/Dockerfile"
- - work-dir: "municipal-services/birth-registration/src/main/resources/db"
- image-name: "birth-registration-db"
-
+ - work-dir: "tutorials/backend-developer-guide/btr-services/src/main/resources/db"
+ image-name: "btr-services-db"
+
# Utilities
- name: "builds/upyog/utilities/egov-weekly-impact-notifier"
diff --git a/build/maven/Dockerfile b/build/maven/Dockerfile
index 6d1e68565fc..529da5f0545 100644
--- a/build/maven/Dockerfile
+++ b/build/maven/Dockerfile
@@ -12,7 +12,7 @@ COPY build/maven/start.sh ./start.sh
# RUN mvn -B dependency:go-offline
COPY ${WORK_DIR}/src ./src
-RUN mvn -B -f /app/pom.xml package
+RUN mvn -B -f /app/pom.xml package -Dmaven.test.skip=true -DskipTests
# Create runtime image
diff --git a/business-services/billing-service/pom.xml b/business-services/billing-service/pom.xml
index 48b7f7fbd1a..ce474992851 100644
--- a/business-services/billing-service/pom.xml
+++ b/business-services/billing-service/pom.xml
@@ -24,9 +24,26 @@
3.3.9
1.18.8
2.6
+ 1.2.0.Final
+ org.cache2k
+ cache2k-api
+ ${cache2k-version}
+
+
+ org.cache2k
+ cache2k-core
+ ${cache2k-version}
+ runtime
+
+
+ org.cache2k
+ cache2k-spring
+ ${cache2k-version}
+
+
org.springframework.boot
spring-boot-starter-web
@@ -52,6 +69,18 @@
org.springframework.kafka
spring-kafka
+
+ org.powermock
+ powermock-api-mockito
+ 1.6.5
+ test
+
+
+ org.powermock
+ powermock-module-junit4
+ 1.6.5
+ test
+
org.springframework.boot
spring-boot-devtools
diff --git a/business-services/billing-service/src/main/java/org/egov/demand/config/ApplicationProperties.java b/business-services/billing-service/src/main/java/org/egov/demand/config/ApplicationProperties.java
index 30fc7fe1221..00e246c19ab 100644
--- a/business-services/billing-service/src/main/java/org/egov/demand/config/ApplicationProperties.java
+++ b/business-services/billing-service/src/main/java/org/egov/demand/config/ApplicationProperties.java
@@ -192,7 +192,20 @@ public class ApplicationProperties {
@Value("${amendment.id.format.name}")
private String amendmentIdFormatName;
-
+
@Value("${statelevel.rolecode.excluded.list}")
private List statelevelRolecodeExclusionList;
+
+ @Value("${egov.shortener.url}")
+ private String egovShortenerUrl;
+
+ @Value("${notification.url}")
+ private String notificationUrl;
+
+ @Value("${notification.sms.link}")
+ private String smsNotificationLink;
+
+ @Value("${egov.shortener.host}")
+ private String shortenerHost;
+
}
\ No newline at end of file
diff --git a/business-services/billing-service/src/main/java/org/egov/demand/consumer/notification/NotificationConsumer.java b/business-services/billing-service/src/main/java/org/egov/demand/consumer/notification/NotificationConsumer.java
index 470723d504a..1e66b00fe61 100644
--- a/business-services/billing-service/src/main/java/org/egov/demand/consumer/notification/NotificationConsumer.java
+++ b/business-services/billing-service/src/main/java/org/egov/demand/consumer/notification/NotificationConsumer.java
@@ -1,5 +1,6 @@
package org.egov.demand.consumer.notification;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
@@ -9,12 +10,15 @@
import org.apache.commons.lang3.StringUtils;
import org.egov.common.contract.request.RequestInfo;
import org.egov.demand.model.Bill;
+import org.egov.demand.util.Constants;
import org.egov.demand.model.BillDetail;
+import org.egov.demand.config.ApplicationProperties;
import org.egov.demand.model.BillDetailV2;
import org.egov.demand.model.BillV2;
-import org.egov.demand.util.Constants;
+import org.egov.demand.repository.ServiceRequestRepository;
import org.egov.demand.web.contract.BillRequest;
import org.egov.demand.web.contract.BillRequestV2;
+import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.annotation.KafkaListener;
@@ -38,52 +42,59 @@ public class NotificationConsumer {
@Value("${egov.localization.search.endpoint}")
private String localizationEndpoint;
-
+
@Value("${bill.notification.fallback.locale}")
private String fallBackLocale;
-
+
@Value("${kafka.topics.notification.sms}")
private String smsTopic;
@Value("${kafka.topics.cancel.bill.topic.name}")
private String billCancelTopic;
-
+
@Value("${kafka.topics.notification.sms.key}")
private String smsTopickey;
-
- @Autowired
- private ObjectMapper objectMapper;
-
+
+ @Autowired
+ private ObjectMapper objectMapper;
+ @Autowired
+ private ApplicationProperties config;
+
@Autowired
private KafkaTemplate producer;
-
+
@Autowired
private RestTemplate restTemplate;
-
- private static final String BILLING_LOCALIZATION_MODULE = "billing-services";
+
+ @Autowired
+ private ServiceRequestRepository serviceRequestRepository;
+
+ private static final String WS_LOCALIZATION_MODULE = "rainmaker-ws";
+ private static final String WS_CONNECTION_BILL_GENERATION = "WATER_CONNECTION_BILL_GENERATION_SMS_MESSAGE";
+ private static final String BILLING_LOCALIZATION_MODULE = "billing-services";
public static final String PAYMENT_MSG_LOCALIZATION_CODE = "BILLINGSERVICE_BUSINESSSERVICE_BILL_GEN_NOTIF_MSG";
public static final String BILL_CANCELLATION_MSG_LOCALIZATION_CODE = "BILLINGSERVICE_BILL_CANCELLATION_NOTIF_MSG";
public static final String BUSINESSSERVICELOCALIZATION_CODE_PREFIX = "BILLINGSERVICE_BUSINESSSERVICE_";
-
+
public static final String LOCALIZATION_CODES_JSONPATH = "$.messages.*.code";
public static final String LOCALIZATION_MSGS_JSONPATH = "$.messages.*.message";
-
+
public static final String BUSINESSSERVICE_MDMS_MASTER = "BusinessService";
public static final String BUSINESSSERVICE_CODES_JSONPATH = "$.MdmsRes.BillingService.BusinessService";
public static final String USERNAME_REPLACE_STRING = "{username}";
public static final String PERIOD_REPLACE_STRING = "{period}";
public static final String TAX_REPLACE_STRING = "{amt}";
-
+
public static final String MODULE_REPLACE_STRING = "{module}";
public static final String MODULE_REPLACE_STRING_VALUE = "Property Tax";
-
+
public static final String MODULE_PRIMARYKEY_REPLACE_STRING = "{primarykeystring}";
public static final String MODULE_PRIMARYKEY_REPLACE_STRING_VALUE = "property-id";
-
+
public static final String SERVICENUMBER_OF_MODULE_REPLACE_STRING = "{servicenumber}";
public static final String EXPIRY_DATE_REPLACE_STRING = "{expirydate}";
-
+
/**
* Kafka consumer
*
@@ -94,11 +105,11 @@ public class NotificationConsumer {
public void listen(Map record, @Header(KafkaHeaders.RECEIVED_TOPIC) String topic) {
try {
- if(topic.equals(billCancelTopic)){
+ if (topic.equals(billCancelTopic)) {
BillRequestV2 req = objectMapper.convertValue(record, BillRequestV2.class);
sendNotificationForBillCancellation(req);
- }else {
- BillRequest req = objectMapper.convertValue(record, BillRequest.class);
+ } else {
+ BillRequestV2 req = objectMapper.convertValue(record, BillRequestV2.class);
sendNotification(req);
}
} catch (Exception e) {
@@ -138,7 +149,8 @@ private String buildSmsBodyForBillCancellation(BillV2 bill, RequestInfo requestI
content = content.replace("{OWNER_NAME}", bill.getPayerName());
content = content.replace("{SERVICE}", bill.getBusinessService());
content = content.replace("{BILLING_PERIOD}", getPeriod(detail.getFromPeriod(), detail.getToPeriod()));
- content = content.replace("{REASON_FOR_CANCELLATION}", bill.getAdditionalDetails().get(Constants.CANCELLATION_REASON_MSG).textValue());
+ content = content.replace("{REASON_FOR_CANCELLATION}",
+ bill.getAdditionalDetails().get(Constants.CANCELLATION_REASON_MSG).textValue());
}
return content;
@@ -148,8 +160,32 @@ private String buildSmsBodyForBillCancellation(BillV2 bill, RequestInfo requestI
* Method to send notifications.
*
* @param billReq
- * @throws Exception
+ * @throws Exception
*/
+
+ private void sendNotification(BillRequestV2 billReq) {
+
+ billReq.getBills().forEach(bill -> {
+ if (bill.getMobileNumber() != null && bill.getTotalAmount().compareTo(BigDecimal.ZERO) > 0
+ && (bill.getBusinessService().equalsIgnoreCase("WS")
+ || bill.getBusinessService().equalsIgnoreCase("SW"))) {
+ String phNo = bill.getMobileNumber();
+ String message = buildSmsBody(bill, billReq.getRequestInfo());
+ log.info("sendNotification :: phone:: " + phNo + " message " + message + "bill ::" + bill);
+ if (!StringUtils.isEmpty(message)) {
+ Map request = new HashMap<>();
+ request.put("mobileNumber", phNo);
+ request.put("message", message);
+ producer.send(smsTopic, smsTopickey, request);
+ log.info("******Notification sent Successfully*******");
+ } else {
+ log.error("No message configured! Notification will not be sent.");
+ }
+ }
+ });
+ log.info("skipping sendNotification loop end::" + billReq);
+ }
+
private void sendNotification(BillRequest billReq) {
billReq.getBills().forEach(bill -> {
@@ -182,7 +218,7 @@ private String buildSmsBody(Bill bill, RequestInfo requestInfo) {
BillDetail detail = bill.getBillDetails().get(0);
- // notification is enabled only for PT
+ // notification is enabled only for PT
if (bill.getMobileNumber() == null || !detail.getBusinessService().equals("PT"))
return null;
@@ -195,20 +231,68 @@ private String buildSmsBody(Bill bill, RequestInfo requestInfo) {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(detail.getExpiryDate());
-
+
content = content.replace(USERNAME_REPLACE_STRING, bill.getPayerName());
- content = content.replace(EXPIRY_DATE_REPLACE_STRING,
- " "+ cal.get(Calendar.DATE) + "/" + cal.get(Calendar.MONTH) + "/" + cal.get(Calendar.YEAR)+ " ".toUpperCase());
+ content = content.replace(EXPIRY_DATE_REPLACE_STRING, " " + cal.get(Calendar.DATE) + "/"
+ + cal.get(Calendar.MONTH) + "/" + cal.get(Calendar.YEAR) + " ".toUpperCase());
content = content.replace(PERIOD_REPLACE_STRING, getPeriod(detail.getFromPeriod(), detail.getToPeriod()));
content = content.replace(SERVICENUMBER_OF_MODULE_REPLACE_STRING, detail.getConsumerCode().split(":")[0]);
content = content.replace(MODULE_REPLACE_STRING, MODULE_REPLACE_STRING_VALUE);
content = content.replace(MODULE_PRIMARYKEY_REPLACE_STRING, MODULE_PRIMARYKEY_REPLACE_STRING_VALUE);
content = content.replace(TAX_REPLACE_STRING, detail.getTotalAmount().toString());
-
+
+ }
+ return content;
+ }
+
+ private String buildSmsBody(BillV2 bill, RequestInfo requestInfo) {
+
+ log.info("build Sms Body ::");
+
+ BillDetailV2 detail = bill.getBillDetails().get(0);
+
+ String tenantId = bill.getTenantId();
+ String content = null;
+
+ content = fetchContentFromLocalization(requestInfo, tenantId, WS_LOCALIZATION_MODULE,
+ "WATER_CONNECTION_BILL_GENERATION_SMS_MESSAGE");
+ if (!StringUtils.isEmpty(content)) {
+ Calendar cal = Calendar.getInstance();
+ log.info("detail.getExpiryDate()1 " + detail.getExpiryDate());
+ cal.setTimeInMillis(detail.getExpiryDate());
+ int month = cal.get(Calendar.MONTH) + 1;
+ content = content.replace("",
+ " " + cal.get(Calendar.DATE) + "/" + month + "/" + cal.get(Calendar.YEAR) + " ".toUpperCase());
+ content = content.replace("", bill.getPayerName());
+ if (bill.getBusinessService().contains("WS")) {
+ content = content.replace("", "Water Charges");
+ } else {
+ content = content.replace("", "Sewerage Charges");
+ }
+ log.info("::append content ::" + content);
+ String actionLink = config.getSmsNotificationLink().replace("$consumerCode", bill.getConsumerCode())
+ .replace("$tenantId", bill.getTenantId());
+ actionLink = config.getNotificationUrl() + actionLink;
+ actionLink = getShortnerURL(actionLink);
+ log.info("Action link " + actionLink);
+ content = content.replace("", actionLink);
+
+ content = content.replace("", bill.getTotalAmount().toString());
+ log.info("content WS" + content);
}
+ // }
return content;
}
+ public String getShortnerURL(String actualURL) {
+ net.minidev.json.JSONObject obj = new net.minidev.json.JSONObject();
+ obj.put("url", actualURL);
+ String url = config.getShortenerHost() + config.getEgovShortenerUrl();
+ // Object response = serviceRequestRepository.getShorteningURL(new
+ // StringBuilder(url).toString(), obj);
+ return serviceRequestRepository.getShorteningURL(new StringBuilder(url), obj);
+ }
+
private String getPeriod(Long fromPeriod, Long toPeriod) {
StringBuilder period = new StringBuilder();
@@ -220,7 +304,7 @@ private String getPeriod(Long fromPeriod, Long toPeriod) {
period.append(cal.get(Calendar.YEAR));
return period.toString();
}
-
+
/**
* Generic method to fetch data from localization.
*
@@ -231,22 +315,24 @@ private String getPeriod(Long fromPeriod, Long toPeriod) {
* @return
*/
private String fetchContentFromLocalization(RequestInfo requestInfo, String tenantId, String module, String code) {
-
+
String message = null;
List codes = new ArrayList<>();
List messages = new ArrayList<>();
Object result = null;
String locale = "";
-
- if(requestInfo.getMsgId().contains("|"))
- locale= requestInfo.getMsgId().split("[\\|]")[1]; // Conventionally locale is sent in the second(1) index of msgid split by |
-
- if(StringUtils.isEmpty(locale))
+
+ if (requestInfo.getMsgId().contains("|"))
+ locale = requestInfo.getMsgId().split("[\\|]")[1]; // Conventionally locale is sent in the second(1) index
+ // of msgid split by |
+
+ if (StringUtils.isEmpty(locale))
locale = fallBackLocale;
-
+
StringBuilder uri = new StringBuilder();
uri.append(localizationHost).append(localizationEndpoint);
- uri.append("?tenantId=").append(tenantId.split("\\.")[0]).append("&locale=").append(locale).append("&module=").append(module);
+ uri.append("?tenantId=").append(tenantId.split("\\.")[0]).append("&locale=").append(locale).append("&module=")
+ .append(module);
Map request = new HashMap<>();
request.put("RequestInfo", requestInfo);
try {
@@ -258,7 +344,8 @@ private String fetchContentFromLocalization(RequestInfo requestInfo, String tena
}
if (null != result) {
for (int i = 0; i < codes.size(); i++) {
- if(codes.get(i).equals(code)) message = messages.get(i);
+ if (codes.get(i).equals(code))
+ message = messages.get(i);
}
}
return message;
diff --git a/business-services/billing-service/src/main/java/org/egov/demand/model/AuditDetails.java b/business-services/billing-service/src/main/java/org/egov/demand/model/AuditDetails.java
index 6d9d09346a4..7662016d42e 100644
--- a/business-services/billing-service/src/main/java/org/egov/demand/model/AuditDetails.java
+++ b/business-services/billing-service/src/main/java/org/egov/demand/model/AuditDetails.java
@@ -7,6 +7,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
+import lombok.ToString;
/**
* Collection of audit related fields used by most models
@@ -16,6 +17,7 @@
@AllArgsConstructor
@NoArgsConstructor
@Builder
+@ToString
public class AuditDetails {
@JsonProperty("createdBy")
diff --git a/business-services/billing-service/src/main/java/org/egov/demand/model/BillDetailV2.java b/business-services/billing-service/src/main/java/org/egov/demand/model/BillDetailV2.java
index 2425c930870..9e8006aed7f 100644
--- a/business-services/billing-service/src/main/java/org/egov/demand/model/BillDetailV2.java
+++ b/business-services/billing-service/src/main/java/org/egov/demand/model/BillDetailV2.java
@@ -48,6 +48,15 @@ public class BillDetailV2 {
@JsonProperty("toPeriod")
private Long toPeriod;
+
+ @JsonProperty("businessService")
+ private String businessService;
+
+ @JsonProperty("consumerCode")
+ private String consumerCode;
+
+ @JsonProperty("totalAmount")
+ private BigDecimal totalAmount;
@JsonProperty("additionalDetails")
private Object additionalDetails;
diff --git a/business-services/billing-service/src/main/java/org/egov/demand/model/BillSearchCriteria.java b/business-services/billing-service/src/main/java/org/egov/demand/model/BillSearchCriteria.java
index f3237eb6358..7e0ac109a5d 100644
--- a/business-services/billing-service/src/main/java/org/egov/demand/model/BillSearchCriteria.java
+++ b/business-services/billing-service/src/main/java/org/egov/demand/model/BillSearchCriteria.java
@@ -60,4 +60,10 @@ public class BillSearchCriteria {
@Pattern(regexp = "^[0-9]{10}$", message = "MobileNumber should be 10 digit number")
private String mobileNumber;
+
+ private Long periodFrom;
+
+ private Long periodTo;
+
+
}
diff --git a/business-services/billing-service/src/main/java/org/egov/demand/model/GenerateBillCriteria.java b/business-services/billing-service/src/main/java/org/egov/demand/model/GenerateBillCriteria.java
index 148b957f7a5..19f115faac1 100644
--- a/business-services/billing-service/src/main/java/org/egov/demand/model/GenerateBillCriteria.java
+++ b/business-services/billing-service/src/main/java/org/egov/demand/model/GenerateBillCriteria.java
@@ -39,6 +39,8 @@
*/
package org.egov.demand.model;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -46,7 +48,8 @@
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
-
+import org.egov.demand.model.enums.DemandStatus;
+import org.springframework.util.StringUtils;
import org.egov.demand.model.BillV2.BillStatus;
import org.hibernate.validator.constraints.SafeHtml;
@@ -87,6 +90,10 @@ public class GenerateBillCriteria {
@Pattern(regexp = "^[0-9]{10}$", message = "MobileNumber should be 10 digit number")
private String mobileNumber;
+ private Long periodFrom;
+
+ private Long periodTo;
+
public DemandCriteria toDemandCriteria() {
Set consumerCodeSet = new HashSet<>();
@@ -95,14 +102,18 @@ public DemandCriteria toDemandCriteria() {
Set demandIdSet = new HashSet<>();
demandIdSet.add(demandId);
+
return DemandCriteria.builder()
+ .status(DemandStatus.ACTIVE.toString())
.businessService(businessService)
.consumerCode(consumerCodeSet)
.mobileNumber(mobileNumber)
- .isPaymentCompleted(false)
.demandId(demandIdSet)
.tenantId(tenantId)
+ .isPaymentCompleted(false)
.email(email)
+ .periodFrom(periodFrom)
+ .periodTo(periodTo)
.build();
}
@@ -121,6 +132,8 @@ public BillSearchCriteria toBillSearchCriteria() {
.tenantId(tenantId)
.isOrderBy(true)
.email(email)
+ .periodFrom(periodFrom)
+ .periodTo(periodTo)
.build();
}
diff --git a/business-services/billing-service/src/main/java/org/egov/demand/model/TaxHeadMasterCriteria.java b/business-services/billing-service/src/main/java/org/egov/demand/model/TaxHeadMasterCriteria.java
index b81dc8f24ba..e37e8312018 100644
--- a/business-services/billing-service/src/main/java/org/egov/demand/model/TaxHeadMasterCriteria.java
+++ b/business-services/billing-service/src/main/java/org/egov/demand/model/TaxHeadMasterCriteria.java
@@ -12,6 +12,7 @@
import lombok.Setter;
import lombok.ToString;
import lombok.Builder.Default;
+import lombok.EqualsAndHashCode;
@Setter
@Getter
@@ -19,6 +20,7 @@
@AllArgsConstructor
@ToString
@Builder
+@EqualsAndHashCode
public class TaxHeadMasterCriteria {
@NotNull
diff --git a/business-services/billing-service/src/main/java/org/egov/demand/repository/AmendmentRepository.java b/business-services/billing-service/src/main/java/org/egov/demand/repository/AmendmentRepository.java
index 9459560efb8..1efcd293fc3 100644
--- a/business-services/billing-service/src/main/java/org/egov/demand/repository/AmendmentRepository.java
+++ b/business-services/billing-service/src/main/java/org/egov/demand/repository/AmendmentRepository.java
@@ -5,6 +5,8 @@
import static org.egov.demand.repository.querybuilder.AmendmentQueryBuilder.AMENDMENT_UPDATE_QUERY;
import static org.egov.demand.repository.querybuilder.AmendmentQueryBuilder.DOCUMET_INSERT_QUERY;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@@ -47,6 +49,8 @@ public void saveAmendment (AmendmentRequest amendmentRequest) {
namedJdbcTemplate.update(AMENDMENT_INSERT_QUERY, getAmendmentSqlParameter(amendmentRequest));
saveTaxDetail(amendment.getDemandDetails(), amendment.getId());
+
+ if (amendment.getDocuments() != null && !amendment.getDocuments().isEmpty())
savedocs(amendment.getDocuments(), amendment.getId());
}
diff --git a/business-services/billing-service/src/main/java/org/egov/demand/repository/BillRepositoryV2.java b/business-services/billing-service/src/main/java/org/egov/demand/repository/BillRepositoryV2.java
index b50f834242d..78db0fc5d82 100644
--- a/business-services/billing-service/src/main/java/org/egov/demand/repository/BillRepositoryV2.java
+++ b/business-services/billing-service/src/main/java/org/egov/demand/repository/BillRepositoryV2.java
@@ -21,6 +21,7 @@
import org.egov.demand.repository.rowmapper.BillRowMapperV2;
import org.egov.demand.util.Util;
import org.egov.demand.web.contract.BillRequestV2;
+import org.egov.demand.web.contract.CancelBillCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -54,6 +55,15 @@ public List findBill(BillSearchCriteria billCriteria){
return jdbcTemplate.query(queryStr, preparedStatementValues.toArray(), searchBillRowMapper);
}
+public String getLatestActiveBillId(CancelBillCriteria cancelBillCriteria){
+
+ List
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/config/AppProperties.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/config/AppProperties.java
index f1768bb08fc..ee33c60e0a2 100644
--- a/core-services/egov-pg-service/src/main/java/org/egov/pg/config/AppProperties.java
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/config/AppProperties.java
@@ -116,7 +116,7 @@ public AppProperties(Environment environment){
this.bankAccountPath = environment.getRequiredProperty("egov.bankaccountservice.path");
this.paymentCreatePath = environment.getRequiredProperty("egov.collectionservice.payment.create.path");
this.paymentValidatePath = environment.getRequiredProperty("egov.collectionservice.payment.validate.path");
- this.userServiceHost = environment.getRequiredProperty("egov.userservice.host");
+ this.userServiceHost = environment.getRequiredProperty("egov.user.host");
this.userServiceCreatePath = environment.getRequiredProperty("egov.userservice.create.path");
this.userServiceSearchPath = environment.getRequiredProperty("egov.userservice.search.path");
this.isUserCreationEnable = Boolean.valueOf(environment.getRequiredProperty("pg.is.user.create.enabled"));
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/models/Transaction.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/models/Transaction.java
index dd935a6edd4..87e86df1d7e 100644
--- a/core-services/egov-pg-service/src/main/java/org/egov/pg/models/Transaction.java
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/models/Transaction.java
@@ -26,7 +26,11 @@
@Builder
@ToString
public class Transaction {
-
+@SafeHtml
+@JsonProperty("businessService")
+ @NotNull
+ @Size(min = 1)
+ private String businessService;
@SafeHtml
@JsonProperty("tenantId")
@NotNull
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/repository/BankAccountRepository.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/repository/BankAccountRepository.java
index df18c7e2b30..50681bda5df 100644
--- a/core-services/egov-pg-service/src/main/java/org/egov/pg/repository/BankAccountRepository.java
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/repository/BankAccountRepository.java
@@ -29,9 +29,10 @@ public class BankAccountRepository {
this.appProperties = appProperties;
}
- public BankAccount getBankAccountsById( RequestInfo requestInfo, String tenantId) {
+ public BankAccount getBankAccountsById( RequestInfo requestInfo, String tenantId, String businessService) {
MultiValueMap queryParams = new LinkedMultiValueMap<>();
queryParams.add("tenantId", tenantId);
+ queryParams.add("businessService", businessService);
String uri = UriComponentsBuilder
.fromHttpUrl(appProperties.getBankAccountHost())
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/EnrichmentService.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/EnrichmentService.java
index fe9a8ab9cb6..34fd58cc997 100644
--- a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/EnrichmentService.java
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/EnrichmentService.java
@@ -47,8 +47,12 @@ void enrichCreateTransaction(TransactionRequest transactionRequest) {
Transaction transaction = transactionRequest.getTransaction();
RequestInfo requestInfo = transactionRequest.getRequestInfo();
- BankAccount bankAccount = bankAccountRepository.getBankAccountsById(requestInfo, transaction.getTenantId());
- transaction.setAdditionalFields(singletonMap(TransactionAdditionalFields.BANK_ACCOUNT_NUMBER, bankAccount.getAccountNumber()));
+ BankAccount bankAccount = bankAccountRepository.getBankAccountsById(requestInfo, transaction.getTenantId(), transaction.getBusinessService());
+ String accountWithSeprator = bankAccount.getAccountNumber();
+ String accountNumber=accountWithSeprator;
+ if(accountWithSeprator.contains("/"))
+ accountNumber = accountWithSeprator.substring(accountWithSeprator.lastIndexOf("/")+1);
+ transaction.setAdditionalFields(singletonMap(TransactionAdditionalFields.BANK_ACCOUNT_NUMBER, accountNumber));
// Generate ID from ID Gen service and assign to txn object
String txnId = idGenService.generateTxnId(transactionRequest);
@@ -105,6 +109,7 @@ void enrichUpdateTransaction(TransactionRequest transactionRequest, Transaction
newTxn.setConsumerCode(currentTxnStatus.getConsumerCode());
newTxn.setTxnStatusMsg(currentTxnStatus.getTxnStatusMsg());
newTxn.setReceipt(currentTxnStatus.getReceipt());
+ newTxn.setBusinessService(currentTxnStatus.getBusinessService());
}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/TransactionService.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/TransactionService.java
index 9a1cabb518e..731b44fa26a 100644
--- a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/TransactionService.java
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/TransactionService.java
@@ -87,7 +87,12 @@ public Transaction initiateTransaction(TransactionRequest transactionRequest) {
else{
URI uri = gatewayService.initiateTxn(transaction);
transaction.setRedirectUrl(uri.toString());
-
+ if (uri.getRawQuery() != null && transaction.getGateway().equals("RAZORPAY")) {
+ String param = uri.getRawQuery();
+ String[] orderId = param.split("orderId=");
+ if (orderId!=null && orderId.length > 1)
+ transaction.setGatewayTxnId(orderId[1]);
+ }
dump.setTxnRequest(uri.toString());
}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Addon.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Addon.java
new file mode 100644
index 00000000000..0708f4adcf0
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Addon.java
@@ -0,0 +1,10 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import org.json.JSONObject;
+
+public class Addon extends Entity {
+
+ public Addon(JSONObject jsonObject) {
+ super(jsonObject);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/AddonClient.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/AddonClient.java
new file mode 100644
index 00000000000..cd999d0f321
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/AddonClient.java
@@ -0,0 +1,17 @@
+package org.egov.pg.service.gateways.razorpay;
+
+public class AddonClient extends ApiClient {
+
+ AddonClient(String auth) {
+ super(auth);
+ }
+
+ // To create an Addon, use the createAddon method of SubscriptionClient
+ public Addon fetch(String id) throws RazorpayException {
+ return get(String.format(Constants.ADDON_GET, id), null);
+ }
+
+ public void delete(String id) throws RazorpayException {
+ delete(String.format(Constants.ADDON_DELETE, id), null);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/ApiClient.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/ApiClient.java
new file mode 100644
index 00000000000..7547e6a5f76
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/ApiClient.java
@@ -0,0 +1,194 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.apache.commons.text.WordUtils;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import okhttp3.Response;
+
+class ApiClient {
+
+ String auth;
+
+ private final String ENTITY = "entity";
+
+ private final String COLLECTION = "collection";
+
+ private final String ERROR = "error";
+
+ private final String DESCRIPTION = "description";
+
+ private final String STATUS_CODE = "code";
+
+ private final int STATUS_OK = 200;
+
+ private final int STATUS_MULTIPLE_CHOICE = 300;
+
+ ApiClient(String auth) {
+ this.auth = auth;
+ }
+
+ public T get(String path, JSONObject requestObject) throws RazorpayException {
+ Response response = ApiUtils.getRequest(path, requestObject, auth);
+ return processResponse(response);
+ }
+
+ public T post(String path, JSONObject requestObject) throws RazorpayException {
+ Response response = ApiUtils.postRequest(path, requestObject, auth);
+ return processResponse(response);
+ }
+
+ public T put(String path, JSONObject requestObject) throws RazorpayException {
+ Response response = ApiUtils.putRequest(path, requestObject, auth);
+ return processResponse(response);
+ }
+
+ public T patch(String path, JSONObject requestObject) throws RazorpayException {
+ Response response = ApiUtils.patchRequest(path, requestObject, auth);
+ return processResponse(response);
+ }
+
+ public void delete(String path, JSONObject requestObject) throws RazorpayException {
+ Response response = ApiUtils.deleteRequest(path, requestObject, auth);
+ processDeleteResponse(response);
+ }
+
+ ArrayList getCollection(String path, JSONObject requestObject)
+ throws RazorpayException {
+ Response response = ApiUtils.getRequest(path, requestObject, auth);
+ return processCollectionResponse(response);
+ }
+
+ private T parseResponse(JSONObject jsonObject) throws RazorpayException {
+ if (jsonObject.has(ENTITY)) {
+ Class cls = getClass(jsonObject.getString(ENTITY));
+ try {
+ return cls.getConstructor(JSONObject.class).newInstance(jsonObject);
+ } catch (Exception e) {
+ throw new RazorpayException("Unable to parse response because of " + e.getMessage());
+ }
+ }
+
+ throw new RazorpayException("Unable to parse response");
+ }
+
+ private ArrayList parseCollectionResponse(JSONObject jsonObject)
+ throws RazorpayException {
+
+ ArrayList modelList = new ArrayList();
+ if (jsonObject.has(ENTITY) && COLLECTION.equals(jsonObject.getString(ENTITY))) {
+ JSONArray jsonArray = jsonObject.getJSONArray("items");
+ try {
+ for (int i = 0; i < jsonArray.length(); i++) {
+ JSONObject jsonObj = jsonArray.getJSONObject(i);
+ T t = parseResponse(jsonObj);
+ modelList.add(t);
+ }
+ return modelList;
+ } catch (RazorpayException e) {
+ throw e;
+ }
+ }
+
+ throw new RazorpayException("Unable to parse response");
+ }
+
+ T processResponse(Response response) throws RazorpayException {
+ if (response == null) {
+ throw new RazorpayException("Invalid Response from server");
+ }
+
+ int statusCode = response.code();
+ String responseBody = null;
+ JSONObject responseJson = null;
+
+ try {
+ responseBody = response.body().string();
+ responseJson = new JSONObject(responseBody);
+ } catch (IOException e) {
+ throw new RazorpayException(e.getMessage());
+ }
+
+ if (statusCode >= STATUS_OK && statusCode < STATUS_MULTIPLE_CHOICE) {
+ return parseResponse(responseJson);
+ }
+
+ throwException(statusCode, responseJson);
+ return null;
+ }
+
+ ArrayList processCollectionResponse(Response response)
+ throws RazorpayException {
+ if (response == null) {
+ throw new RazorpayException("Invalid Response from server");
+ }
+
+ int statusCode = response.code();
+ String responseBody = null;
+ JSONObject responseJson = null;
+
+ try {
+ responseBody = response.body().string();
+ responseJson = new JSONObject(responseBody);
+ } catch (IOException e) {
+ throw new RazorpayException(e.getMessage());
+ }
+
+ if (statusCode >= STATUS_OK && statusCode < STATUS_MULTIPLE_CHOICE) {
+ return parseCollectionResponse(responseJson);
+ }
+
+ throwException(statusCode, responseJson);
+ return null;
+ }
+
+ private void processDeleteResponse(Response response) throws RazorpayException {
+ if (response == null) {
+ throw new RazorpayException("Invalid Response from server");
+ }
+
+ int statusCode = response.code();
+ String responseBody = null;
+ JSONObject responseJson = null;
+
+ try {
+ responseBody = response.body().string();
+ responseJson = new JSONObject(responseBody);
+ } catch (IOException e) {
+ throw new RazorpayException(e.getMessage());
+ }
+
+ if (statusCode < STATUS_OK || statusCode >= STATUS_MULTIPLE_CHOICE) {
+ throwException(statusCode, responseJson);
+ }
+ }
+
+ private void throwException(int statusCode, JSONObject responseJson) throws RazorpayException {
+ if (responseJson.has(ERROR)) {
+ JSONObject errorResponse = responseJson.getJSONObject(ERROR);
+ String code = errorResponse.getString(STATUS_CODE);
+ String description = errorResponse.getString(DESCRIPTION);
+ throw new RazorpayException(code + ":" + description);
+ }
+ throwServerException(statusCode, responseJson.toString());
+ }
+
+ private void throwServerException(int statusCode, String responseBody) throws RazorpayException {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Status Code: ").append(statusCode).append("\n");
+ sb.append("Server response: ").append(responseBody);
+ throw new RazorpayException(sb.toString());
+ }
+
+ private Class getClass(String entity) {
+ try {
+ String entityClass = "org.egov.pg.service.gateways.razorpay." + WordUtils.capitalize(entity, '_').replaceAll("_", "");
+ return Class.forName(entityClass);
+ } catch (ClassNotFoundException e) {
+ return null;
+ }
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/ApiUtils.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/ApiUtils.java
new file mode 100644
index 00000000000..13034115c15
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/ApiUtils.java
@@ -0,0 +1,179 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import java.io.IOException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509TrustManager;
+
+import org.json.JSONObject;
+
+import okhttp3.HttpUrl;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import okhttp3.logging.HttpLoggingInterceptor;
+
+class ApiUtils {
+
+ private static OkHttpClient client;
+ private static Map headers = new HashMap();
+
+ private static String version = null;
+
+ static void createHttpClientInstance(boolean enableLogging) throws RazorpayException {
+ if (client == null) {
+ HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
+ if (enableLogging) {
+ loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
+ } else {
+ loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.NONE);
+ }
+
+ try {
+ client = new OkHttpClient.Builder()
+ .readTimeout(60, TimeUnit.SECONDS)
+ .writeTimeout(60, TimeUnit.SECONDS)
+ .addInterceptor(loggingInterceptor)
+ .sslSocketFactory(new CustomTLSSocketFactory(), createDefaultTrustManager())
+ .build();
+ } catch (Exception e) {
+ throw new RazorpayException(e);
+ }
+ }
+
+ Properties properties = new Properties();
+ try {
+ properties.load(ApiUtils.class.getResourceAsStream("/project.properties"));
+ version = (String) properties.get("version");
+ } catch (IOException e) {
+ throw new RazorpayException(e.getMessage());
+ }
+ }
+
+ private enum Method {
+ GET, POST, PUT, PATCH, DELETE
+ }
+
+ static Response postRequest(String path, JSONObject requestObject, String auth)
+ throws RazorpayException {
+
+ HttpUrl.Builder builder = getBuilder(path);
+
+ String requestContent = requestObject == null ? "" : requestObject.toString();
+ RequestBody requestBody = RequestBody.create(Constants.MEDIA_TYPE_JSON, requestContent);
+
+ Request request =
+ createRequest(Method.POST.name(), builder.build().toString(), requestBody, auth);
+ return processRequest(request);
+ }
+
+ static Response putRequest(String path, JSONObject requestObject, String auth)
+ throws RazorpayException {
+
+ HttpUrl.Builder builder = getBuilder(path);
+
+ String requestContent = requestObject == null ? "" : requestObject.toString();
+ RequestBody requestBody = RequestBody.create(Constants.MEDIA_TYPE_JSON, requestContent);
+
+ Request request =
+ createRequest(Method.PUT.name(), builder.build().toString(), requestBody, auth);
+ return processRequest(request);
+ }
+
+ static Response patchRequest(String path, JSONObject requestObject, String auth)
+ throws RazorpayException {
+
+ HttpUrl.Builder builder = getBuilder(path);
+
+ String requestContent = requestObject == null ? "" : requestObject.toString();
+ RequestBody requestBody = RequestBody.create(Constants.MEDIA_TYPE_JSON, requestContent);
+
+ Request request =
+ createRequest(Method.PATCH.name(), builder.build().toString(), requestBody, auth);
+ return processRequest(request);
+ }
+
+ static Response getRequest(String path, JSONObject requestObject, String auth)
+ throws RazorpayException {
+
+ HttpUrl.Builder builder = getBuilder(path);
+ addQueryParams(builder, requestObject);
+
+ Request request = createRequest(Method.GET.name(), builder.build().toString(), null, auth);
+ return processRequest(request);
+ }
+
+ static Response deleteRequest(String path, JSONObject requestObject, String auth)
+ throws RazorpayException {
+
+ HttpUrl.Builder builder = getBuilder(path);
+ addQueryParams(builder, requestObject);
+
+ Request request = createRequest(Method.DELETE.name(), builder.build().toString(), null, auth);
+ return processRequest(request);
+ }
+
+ private static HttpUrl.Builder getBuilder(String path) {
+ return new HttpUrl.Builder().scheme(Constants.SCHEME).host(Constants.HOSTNAME)
+ .port(Constants.PORT).addPathSegment(Constants.VERSION).addPathSegments(path);
+ }
+
+ private static Request createRequest(String method, String url, RequestBody requestBody,
+ String auth) {
+ Request.Builder builder =
+ new Request.Builder().url(url).addHeader(Constants.AUTH_HEADER_KEY, auth);
+ builder.addHeader(Constants.USER_AGENT,
+ "Razorpay/v1 JAVASDK/" + version + " Java/" + System.getProperty("java.version"));
+
+ for (Map.Entry header : headers.entrySet()) {
+ builder.addHeader(header.getKey(), header.getValue());
+ }
+
+ return builder.method(method, requestBody).build();
+ }
+
+ private static void addQueryParams(HttpUrl.Builder builder, JSONObject request) {
+ if (request == null)
+ return;
+
+ Iterator> keys = request.keys();
+ while (keys.hasNext()) {
+ String key = (String) keys.next();
+ builder.addQueryParameter(key, request.get(key).toString());
+ }
+ }
+
+ private static Response processRequest(Request request) throws RazorpayException {
+ try {
+ return client.newCall(request).execute();
+ } catch (IOException e) {
+ throw new RazorpayException(e.getMessage());
+ }
+ }
+
+ static void addHeaders(Map header) {
+ headers.putAll(header);
+ }
+
+ private static X509TrustManager createDefaultTrustManager() throws NoSuchAlgorithmException, KeyStoreException {
+ TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+ trustManagerFactory.init((KeyStore) null);
+ TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
+ if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) {
+ throw new IllegalStateException("Unexpected default trust managers:" + Arrays.toString(trustManagers));
+ }
+ X509TrustManager trustManager = (X509TrustManager) trustManagers[0];
+ return trustManager;
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/BankTransfer.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/BankTransfer.java
new file mode 100644
index 00000000000..cb0bd147954
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/BankTransfer.java
@@ -0,0 +1,9 @@
+package org.egov.pg.service.gateways.razorpay;
+import org.json.JSONObject;
+
+public class BankTransfer extends Entity {
+
+ public BankTransfer(JSONObject jsonObject) {
+ super(jsonObject);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Card.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Card.java
new file mode 100644
index 00000000000..1780dc79f25
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Card.java
@@ -0,0 +1,10 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import org.json.JSONObject;
+
+public class Card extends Entity {
+
+ public Card(JSONObject jsonObject) {
+ super(jsonObject);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/CardClient.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/CardClient.java
new file mode 100644
index 00000000000..04a4f5ea37a
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/CardClient.java
@@ -0,0 +1,12 @@
+package org.egov.pg.service.gateways.razorpay;
+
+public class CardClient extends ApiClient {
+
+ CardClient(String auth) {
+ super(auth);
+ }
+
+ public Card fetch(String id) throws RazorpayException {
+ return get(String.format(Constants.CARD_GET, id), null);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Constants.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Constants.java
new file mode 100644
index 00000000000..979ec83160a
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Constants.java
@@ -0,0 +1,78 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import okhttp3.MediaType;
+
+public class Constants {
+
+ // API constants
+ static final String SCHEME = "https";
+ static final String HOSTNAME = "api.razorpay.com";
+ static final Integer PORT = 443;
+ static final String VERSION = "v1";
+
+ static final String AUTH_HEADER_KEY = "Authorization";
+ static final String USER_AGENT = "User-Agent";
+ static final MediaType MEDIA_TYPE_JSON = MediaType.parse("application/json; charset=utf-8");
+
+ // API URI
+ static final String PAYMENT_GET = "payments/%s";
+ static final String PAYMENT_LIST = "payments";
+ static final String PAYMENT_CAPTURE = "payments/%s/capture";
+ static final String PAYMENT_REFUND = "payments/%s/refund";
+ static final String PAYMENT_TRANSFER_CREATE = "payments/%s/transfers";
+ static final String PAYMENT_TRANSFER_GET = "payments/%s/transfers";
+ static final String PAYMENT_BANK_TRANSFER_GET = "payments/%s/bank_transfer";
+
+ static final String PAYMENT_REFUND_LIST = "payments/%s/refunds";
+ static final String PAYMENT_REFUND_GET = "payments/%s/refunds/%s";
+
+ static final String REFUND_GET = "refunds/%s";
+ static final String REFUND_LIST = "refunds";
+ static final String REFUND_CREATE = "refunds";
+
+ static final String ORDER_CREATE = "orders";
+ static final String ORDER_GET = "orders/%s";
+ static final String ORDER_LIST = "orders";
+ static final String ORDER_PAYMENT_LIST = "orders/%s/payments";
+
+ static final String INVOICE_CREATE = "invoices";
+ static final String INVOICE_GET = "invoices/%s";
+ static final String INVOICE_LIST = "invoices";
+ static final String INVOICE_CANCEL = "invoices/%s/cancel";
+
+ static final String CARD_GET = "cards/%s";
+
+ static final String CUSTOMER_CREATE = "customers";
+ static final String CUSTOMER_GET = "customers/%s";
+ static final String CUSTOMER_EDIT = "customers/%s";
+
+ static final String TOKEN_LIST = "customers/%s/tokens";
+ static final String TOKEN_GET = "customers/%s/tokens/%s";
+ static final String TOKEN_DELETE = "customers/%s/tokens/%s";
+
+ static final String TRANSFER_CREATE = "transfers";
+ static final String TRANSFER_GET = "transfers/%s";
+ static final String TRANSFER_EDIT = "transfers/%s";
+ static final String TRANSFER_LIST = "transfers";
+ static final String TRANSFER_REVERSAL_CREATE = "transfers/%s/reversals";
+
+ static final String PLAN_CREATE = "plans";
+ static final String PLAN_GET = "plans/%s";
+ static final String PLAN_LIST = "plans";
+
+ static final String SUBSCRIPTION_CREATE = "subscriptions";
+ static final String SUBSCRIPTION_GET = "subscriptions/%s";
+ static final String SUBSCRIPTION_LIST = "subscriptions";
+ static final String SUBSCRIPTION_CANCEL = "subscriptions/%s/cancel";
+ static final String SUBSCRIPTION_ADDON_CREATE = "subscriptions/%s/addons";
+
+ static final String ADDON_GET = "addons/%s";
+ static final String ADDON_DELETE = "addons/%s";
+
+ static final String VIRTUAL_ACCOUNT_CREATE = "virtual_accounts";
+ static final String VIRTUAL_ACCOUNT_GET = "virtual_accounts/%s";
+ static final String VIRTUAL_ACCOUNT_LIST = "virtual_accounts";
+ static final String VIRTUAL_ACCOUNT_EDIT = "virtual_accounts/%s";
+ static final String VIRTUAL_ACCOUNT_CLOSE = "virtual_accounts/%s/close";
+ static final String VIRTUAL_ACCOUNT_PAYMENTS = "virtual_accounts/%s/payments";
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/CustomTLSSocketFactory.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/CustomTLSSocketFactory.java
new file mode 100644
index 00000000000..a281f7a45b7
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/CustomTLSSocketFactory.java
@@ -0,0 +1,75 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+
+class CustomTLSSocketFactory extends SSLSocketFactory {
+
+ private SSLSocketFactory internalSSLSocketFactory;
+
+ CustomTLSSocketFactory() throws KeyManagementException, NoSuchAlgorithmException {
+ SSLContext context = SSLContext.getInstance("TLS");
+ context.init(null, null, null);
+ internalSSLSocketFactory = context.getSocketFactory();
+ }
+
+ @Override
+ public String[] getDefaultCipherSuites() {
+ return internalSSLSocketFactory.getDefaultCipherSuites();
+ }
+
+ @Override
+ public String[] getSupportedCipherSuites() {
+ return internalSSLSocketFactory.getSupportedCipherSuites();
+ }
+
+ @Override
+ public Socket createSocket() throws IOException {
+ return enableTLSOnSocket(internalSSLSocketFactory.createSocket());
+ }
+
+ @Override
+ public Socket createSocket(Socket s, String host, int port, boolean autoClose)
+ throws IOException {
+ return enableTLSOnSocket(internalSSLSocketFactory.createSocket(s, host, port, autoClose));
+ }
+
+ @Override
+ public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
+ return enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port));
+ }
+
+ @Override
+ public Socket createSocket(String host, int port, InetAddress localHost, int localPort)
+ throws IOException, UnknownHostException {
+ return enableTLSOnSocket(
+ internalSSLSocketFactory.createSocket(host, port, localHost, localPort));
+ }
+
+ @Override
+ public Socket createSocket(InetAddress host, int port) throws IOException {
+ return enableTLSOnSocket(internalSSLSocketFactory.createSocket(host, port));
+ }
+
+ @Override
+ public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)
+ throws IOException {
+ return enableTLSOnSocket(
+ internalSSLSocketFactory.createSocket(address, port, localAddress, localPort));
+ }
+
+ private Socket enableTLSOnSocket(Socket socket) {
+ if (socket != null && (socket instanceof SSLSocket)) {
+ ((SSLSocket) socket).setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2"});
+ }
+ return socket;
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Customer.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Customer.java
new file mode 100644
index 00000000000..e2566c93571
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Customer.java
@@ -0,0 +1,10 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import org.json.JSONObject;
+
+public class Customer extends Entity {
+
+ public Customer(JSONObject jsonObject) {
+ super(jsonObject);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/CustomerClient.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/CustomerClient.java
new file mode 100644
index 00000000000..91f546e0bb6
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/CustomerClient.java
@@ -0,0 +1,36 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import java.util.List;
+
+import org.json.JSONObject;
+
+public class CustomerClient extends ApiClient {
+
+ CustomerClient(String auth) {
+ super(auth);
+ }
+
+ public Customer create(JSONObject request) throws RazorpayException {
+ return post(Constants.CUSTOMER_CREATE, request);
+ }
+
+ public Customer fetch(String id) throws RazorpayException {
+ return get(String.format(Constants.CUSTOMER_GET, id), null);
+ }
+
+ public Customer edit(String id, JSONObject request) throws RazorpayException {
+ return put(String.format(Constants.CUSTOMER_EDIT, id), request);
+ }
+
+ public List fetchTokens(String id) throws RazorpayException {
+ return getCollection(String.format(Constants.TOKEN_LIST, id), null);
+ }
+
+ public Token fetchToken(String id, String tokenId) throws RazorpayException {
+ return get(String.format(Constants.TOKEN_GET, id, tokenId), null);
+ }
+
+ public void deleteToken(String id, String tokenId) throws RazorpayException {
+ delete(String.format(Constants.TOKEN_DELETE, id, tokenId), null);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Entity.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Entity.java
new file mode 100644
index 00000000000..dbebedded02
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Entity.java
@@ -0,0 +1,45 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import java.util.Date;
+
+import org.json.JSONObject;
+
+public abstract class Entity {
+
+ private JSONObject modelJson;
+
+ private final String CREATED_AT = "created_at";
+ private final String CAPTURED_AT = "captured_at";
+
+ Entity(JSONObject jsonObject) {
+ this.modelJson = jsonObject;
+ }
+
+ public T get(String key) {
+ // Return null if key not in JSONObject
+ if (!has(key)) {
+ return null;
+ }
+ // Return Date for timestamps
+ if (key.equals(CREATED_AT) || key.equals(CAPTURED_AT)) {
+ return (T) new Date(modelJson.getLong(key) * 1000);
+ }
+ Object value = modelJson.get(key);
+ if (value == null) {
+ return null;
+ }
+ return (T) value.getClass().cast(value);
+ }
+
+ public JSONObject toJson() {
+ return modelJson;
+ }
+
+ public boolean has(String key) {
+ return modelJson.has(key);
+ }
+
+ public String toString() {
+ return modelJson.toString();
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Invoice.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Invoice.java
new file mode 100644
index 00000000000..c1b392e20f8
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Invoice.java
@@ -0,0 +1,10 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import org.json.JSONObject;
+
+public class Invoice extends Entity {
+
+ public Invoice(JSONObject jsonObject) {
+ super(jsonObject);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/InvoiceClient.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/InvoiceClient.java
new file mode 100644
index 00000000000..c5196860c92
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/InvoiceClient.java
@@ -0,0 +1,32 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import java.util.List;
+
+import org.json.JSONObject;
+
+public class InvoiceClient extends ApiClient {
+
+ InvoiceClient(String auth) {
+ super(auth);
+ }
+
+ public Invoice create(JSONObject request) throws RazorpayException {
+ return post(Constants.INVOICE_CREATE, request);
+ }
+
+ public List fetchAll() throws RazorpayException {
+ return fetchAll(null);
+ }
+
+ public List fetchAll(JSONObject request) throws RazorpayException {
+ return getCollection(Constants.INVOICE_LIST, request);
+ }
+
+ public Invoice fetch(String id) throws RazorpayException {
+ return get(String.format(Constants.INVOICE_GET, id), null);
+ }
+
+ public Invoice cancel(String id) throws RazorpayException {
+ return post(String.format(Constants.INVOICE_CANCEL, id), null);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Order.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Order.java
new file mode 100644
index 00000000000..bdcdd51ebb4
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Order.java
@@ -0,0 +1,10 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import org.json.JSONObject;
+
+public class Order extends Entity {
+
+ public Order(JSONObject jsonObject) {
+ super(jsonObject);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/OrderClient.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/OrderClient.java
new file mode 100644
index 00000000000..213f4fc2a76
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/OrderClient.java
@@ -0,0 +1,32 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import java.util.List;
+
+import org.json.JSONObject;
+
+public class OrderClient extends ApiClient {
+
+ OrderClient(String auth) {
+ super(auth);
+ }
+
+ public Order create(JSONObject request) throws RazorpayException {
+ return post(Constants.ORDER_CREATE, request);
+ }
+
+ public List fetchAll() throws RazorpayException {
+ return fetchAll(null);
+ }
+
+ public List fetchAll(JSONObject request) throws RazorpayException {
+ return getCollection(Constants.ORDER_LIST, request);
+ }
+
+ public Order fetch(String id) throws RazorpayException {
+ return get(String.format(Constants.ORDER_GET, id), null);
+ }
+
+ public List fetchPayments(String id) throws RazorpayException {
+ return getCollection(String.format(Constants.ORDER_PAYMENT_LIST, id), null);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Payment.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Payment.java
new file mode 100644
index 00000000000..82e827f7cd4
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Payment.java
@@ -0,0 +1,10 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import org.json.JSONObject;
+
+public class Payment extends Entity {
+
+ public Payment(JSONObject jsonObject) {
+ super(jsonObject);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/PaymentClient.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/PaymentClient.java
new file mode 100644
index 00000000000..9d26c1b2921
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/PaymentClient.java
@@ -0,0 +1,83 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import java.util.List;
+
+import org.json.JSONObject;
+
+import okhttp3.Response;
+
+public class PaymentClient extends ApiClient {
+
+ private RefundClient refundClient;
+
+ PaymentClient(String auth) {
+ super(auth);
+ refundClient = new RefundClient(auth);
+ }
+
+ public Payment fetch(String id) throws RazorpayException {
+ return get(String.format(Constants.PAYMENT_GET, id), null);
+ }
+
+ public List fetchAll(JSONObject request) throws RazorpayException {
+ return getCollection(Constants.PAYMENT_LIST, request);
+ }
+
+ public List fetchAll() throws RazorpayException {
+ return fetchAll(null);
+ }
+
+ public Payment capture(String id, JSONObject request) throws RazorpayException {
+ return post(String.format(Constants.PAYMENT_CAPTURE, id), request);
+ }
+
+ public Refund refund(String id) throws RazorpayException {
+ return refund(id, null);
+ }
+
+ public Refund refund(String id, JSONObject request) throws RazorpayException {
+ return post(String.format(Constants.PAYMENT_REFUND, id), request);
+ }
+
+ public Refund refund(JSONObject request) throws RazorpayException {
+ return refundClient.create(request);
+ }
+
+ public Refund fetchRefund(String id, String refundId) throws RazorpayException {
+ return get(String.format(Constants.PAYMENT_REFUND_GET, id, refundId), null);
+ }
+
+ public Refund fetchRefund(String refundId) throws RazorpayException {
+ return refundClient.fetch(refundId);
+ }
+
+ public List fetchAllRefunds(String id, JSONObject request) throws RazorpayException {
+ return getCollection(String.format(Constants.PAYMENT_REFUND_LIST, id), request);
+ }
+
+ public List fetchAllRefunds(String id) throws RazorpayException {
+ return fetchAllRefunds(id, null);
+ }
+
+ public List fetchAllRefunds(JSONObject request) throws RazorpayException {
+ return refundClient.fetchAll(request);
+ }
+
+ public List transfer(String id, JSONObject request) throws RazorpayException {
+ Response response =
+ ApiUtils.postRequest(String.format(Constants.PAYMENT_TRANSFER_CREATE, id), request, auth);
+ return processCollectionResponse(response);
+ }
+
+ public List fetchAllTransfers(String id) throws RazorpayException {
+ return fetchAllTransfers(id, null);
+ }
+
+ public List fetchAllTransfers(String id, JSONObject request) throws RazorpayException {
+ return getCollection(String.format(Constants.PAYMENT_TRANSFER_GET, id), request);
+ }
+
+ public BankTransfer fetchBankTransfers(String id) throws RazorpayException {
+ return get(String.format(Constants.PAYMENT_BANK_TRANSFER_GET, id), null);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Plan.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Plan.java
new file mode 100644
index 00000000000..7478f047082
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Plan.java
@@ -0,0 +1,10 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import org.json.JSONObject;
+
+public class Plan extends Entity {
+
+ public Plan(JSONObject jsonObject) {
+ super(jsonObject);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/PlanClient.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/PlanClient.java
new file mode 100644
index 00000000000..97680080e2c
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/PlanClient.java
@@ -0,0 +1,28 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import java.util.List;
+
+import org.json.JSONObject;
+
+public class PlanClient extends ApiClient {
+
+ PlanClient(String auth) {
+ super(auth);
+ }
+
+ public Plan create(JSONObject request) throws RazorpayException {
+ return post(Constants.PLAN_CREATE, request);
+ }
+
+ public Plan fetch(String id) throws RazorpayException {
+ return get(String.format(Constants.PLAN_GET, id), null);
+ }
+
+ public List fetchAll() throws RazorpayException {
+ return fetchAll(null);
+ }
+
+ public List fetchAll(JSONObject request) throws RazorpayException {
+ return getCollection(Constants.PLAN_LIST, request);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/RazorpayClient.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/RazorpayClient.java
new file mode 100644
index 00000000000..752b8f8b91b
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/RazorpayClient.java
@@ -0,0 +1,45 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import java.util.Map;
+
+import okhttp3.Credentials;
+
+public class RazorpayClient {
+
+ public PaymentClient Payments;
+ public RefundClient Refunds;
+ public OrderClient Orders;
+ public InvoiceClient Invoices;
+ public CardClient Cards;
+ public CustomerClient Customers;
+ public TransferClient Transfers;
+ public SubscriptionClient Subscriptions;
+ public AddonClient Addons;
+ public PlanClient Plans;
+ public VirtualAccountClient VirtualAccounts;
+
+ public RazorpayClient(String key, String secret) throws RazorpayException {
+ this(key, secret, false);
+ }
+
+ public RazorpayClient(String key, String secret, Boolean enableLogging) throws RazorpayException {
+ ApiUtils.createHttpClientInstance(enableLogging);
+ String auth = Credentials.basic(key, secret);
+ Payments = new PaymentClient(auth);
+ Refunds = new RefundClient(auth);
+ Orders = new OrderClient(auth);
+ Invoices = new InvoiceClient(auth);
+ Cards = new CardClient(auth);
+ Customers = new CustomerClient(auth);
+ Transfers = new TransferClient(auth);
+ Subscriptions = new SubscriptionClient(auth);
+ Addons = new AddonClient(auth);
+ Plans = new PlanClient(auth);
+ VirtualAccounts = new VirtualAccountClient(auth);
+ }
+
+ public RazorpayClient addHeaders(Map headers) {
+ ApiUtils.addHeaders(headers);
+ return this;
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/RazorpayException.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/RazorpayException.java
new file mode 100644
index 00000000000..a5cf3a2237f
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/RazorpayException.java
@@ -0,0 +1,21 @@
+package org.egov.pg.service.gateways.razorpay;
+
+public class RazorpayException extends Exception {
+
+ public RazorpayException(String message) {
+ super(message);
+ }
+
+ public RazorpayException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public RazorpayException(Throwable cause) {
+ super(cause);
+ }
+
+ public RazorpayException(String message, Throwable cause, boolean enableSuppression,
+ boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/RazorpayGateway.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/RazorpayGateway.java
new file mode 100644
index 00000000000..9efd711b4ba
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/RazorpayGateway.java
@@ -0,0 +1,258 @@
+package org.egov.pg.service.gateways.razorpay;
+
+import java.net.URI;
+import java.security.SignatureException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import javax.xml.bind.DatatypeConverter;
+import org.egov.pg.constants.TransactionAdditionalFields;
+import org.egov.pg.models.Transaction;
+import org.egov.pg.service.Gateway;
+import org.egov.pg.utils.Utils;
+import org.egov.tracer.model.ServiceCallException;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.util.UriComponents;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * Razorpay Gateway implementation
+ */
+
+@Component
+@Slf4j
+public class RazorpayGateway implements Gateway{
+ private static final String GATEWAY_NAME = "RAZORPAY";
+ private final String MERCHANT_ID;
+ private final String SECURE_SECRET;
+ private final String LOCALE;
+ private final String CURRENCY;
+ private final String PAYMENT_CAPTURE;
+ private RazorpayClient client;
+ private final String MERCHANT_URL_PAY;
+ private final boolean ACTIVE;
+
+
+ @Autowired
+ public RazorpayGateway(ObjectMapper objectMapper, Environment environment) {
+ ACTIVE = Boolean.valueOf(environment.getRequiredProperty("razorpay.active"));
+ CURRENCY = environment.getRequiredProperty("razorpay.currency");
+ LOCALE = environment.getRequiredProperty("razorpay.locale");
+ MERCHANT_ID = environment.getRequiredProperty("razorpay.merchant.id");
+ SECURE_SECRET = environment.getRequiredProperty("razorpay.merchant.secret.key");
+ MERCHANT_URL_PAY = environment.getRequiredProperty("razorpay.url.debit");
+ PAYMENT_CAPTURE = environment.getRequiredProperty("razorpay.payment_capture");
+ try {
+ this.client = new RazorpayClient(this.MERCHANT_ID, this.SECURE_SECRET);
+ } catch (RazorpayException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Override
+ public URI generateRedirectURI(Transaction transaction) {
+ Map fields = new HashMap<>();
+ fields.put("amount", String.valueOf(Utils.formatAmtAsPaise(transaction.getTxnAmount())));
+ fields.put("merchant_key", MERCHANT_ID);
+ fields.put("locale", LOCALE);
+ fields.put("currency", CURRENCY);
+ fields.put("returnURL", transaction.getCallbackUrl());
+ fields.put("merchTxnRef", transaction.getTxnId());
+ fields.put("payment_capture", PAYMENT_CAPTURE);
+
+ JSONObject request = new JSONObject();
+ request.put("amount", String.valueOf(Utils.formatAmtAsPaise(transaction.getTxnAmount())));
+ request.put("payment_capture", PAYMENT_CAPTURE);
+ request.put("currency", CURRENCY);
+ JSONArray transfers = new JSONArray();
+ JSONObject transfer = new JSONObject();
+ transfer.put("amount", String.valueOf(Utils.formatAmtAsPaise(transaction.getTxnAmount())));
+ transfer.put("currency", CURRENCY);
+ transfer.put("account", transaction.getAdditionalFields().get(TransactionAdditionalFields.BANK_ACCOUNT_NUMBER));
+ JSONObject notesData=new JSONObject();
+ notesData.put("ConsumerCode",transaction.getConsumerCode());
+ notesData.put("ConsumerName",transaction.getUser().getName());
+ notesData.put("MobileNumber",transaction.getUser().getMobileNumber());
+ notesData.put("ServiceType",transaction.getBusinessService());
+ notesData.put("TenantId",transaction.getTenantId());
+ notesData.put("BillId",transaction.getBillId());
+ request.put("notes", notesData);
+
+ transfers.put(transfer);
+ request.put("transfers", transfers);
+ Order order = null;
+ try {
+ order = client.Orders.create(request);
+ } catch (RazorpayException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ MultiValueMap params = new LinkedMultiValueMap<>();
+ fields.forEach(params::add);
+ final String encriptionType = "SHA256";
+ params.add("secureHashType", encriptionType);
+ params.add("orderId", order.get("id"));
+ params.add("amount", String.valueOf(Utils.formatAmtAsPaise(transaction.getTxnAmount())));
+
+ UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(MERCHANT_URL_PAY).queryParams
+ (params).build().encode();
+ return uriComponents.toUri();
+ }
+
+
+ @Override
+ public Transaction fetchStatus(Transaction currentStatus, Map params) {
+ final Object generatedSignature;
+ try {
+ RazorpayClient razorpay = null;
+ Order order = null;
+ List ordernew = null;
+ int j=0,k=0;
+ generatedSignature = hmac_sha256(params.get("razorpayOrderId") + "|" + params.get("razorpayPaymentId"), SECURE_SECRET);
+ //Payment payment = client.Payments.fetch(params.get("razorpayPaymentId"));
+ if (generatedSignature.equals(params.get("razorpaySignature")))
+ {
+
+ return Transaction.builder()
+ .txnId(currentStatus.getTxnId())
+ .txnAmount(currentStatus.getTxnAmount())
+ .txnStatus(Transaction.TxnStatusEnum.SUCCESS)
+ .gatewayTxnId(params.get("razorpayOrderId"))
+ .gatewayPaymentMode(params.get("razorpayOrderId"))
+ .build();
+ }
+ else
+ {
+ razorpay = new RazorpayClient(MERCHANT_ID,SECURE_SECRET);
+ order = razorpay.Orders.fetch(currentStatus.getGatewayTxnId());
+ order.get("status");
+ log.info("Order id :"+currentStatus.getGatewayTxnId());
+ log.info("Order id status:"+order.get("status"));
+ ordernew = razorpay.Orders.fetchPayments(currentStatus.getGatewayTxnId());
+ if(ordernew.isEmpty() ||(order.get("status")).equals("created")|| (order.get("status").equals("attempted")))
+ {
+ log.info("************ Inside created and attempted status ***************");
+ return Transaction.builder()
+ .txnId(currentStatus.getTxnId())
+ .txnAmount(currentStatus.getTxnAmount())
+ .txnStatus(Transaction.TxnStatusEnum.FAILURE)
+ .gatewayTxnId(currentStatus.getGatewayTxnId())
+ .gatewayPaymentMode(currentStatus.getGatewayTxnId())
+ .build();
+ }
+ if(!ordernew.isEmpty())
+ {
+ for(int i=0;i fetchAll(JSONObject request) throws RazorpayException {
+ return getCollection(Constants.REFUND_LIST, request);
+ }
+
+ public Refund fetch(String id) throws RazorpayException {
+ return get(String.format(Constants.REFUND_GET, id), null);
+ }
+
+ public List fetchAll() throws RazorpayException {
+ return fetchAll(null);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Reversal.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Reversal.java
new file mode 100644
index 00000000000..c3b59f05ccf
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Reversal.java
@@ -0,0 +1,9 @@
+package org.egov.pg.service.gateways.razorpay;
+import org.json.JSONObject;
+
+public class Reversal extends Entity {
+
+ public Reversal(JSONObject jsonObject) {
+ super(jsonObject);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Subscription.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Subscription.java
new file mode 100644
index 00000000000..eb83ec0132c
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Subscription.java
@@ -0,0 +1,9 @@
+package org.egov.pg.service.gateways.razorpay;
+import org.json.JSONObject;
+
+public class Subscription extends Entity {
+
+ public Subscription(JSONObject jsonObject) {
+ super(jsonObject);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/SubscriptionClient.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/SubscriptionClient.java
new file mode 100644
index 00000000000..bc6401a42be
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/SubscriptionClient.java
@@ -0,0 +1,35 @@
+package org.egov.pg.service.gateways.razorpay;
+import java.util.List;
+
+import org.json.JSONObject;
+
+public class SubscriptionClient extends ApiClient {
+
+ SubscriptionClient(String auth) {
+ super(auth);
+ }
+
+ public Subscription create(JSONObject request) throws RazorpayException {
+ return post(Constants.SUBSCRIPTION_CREATE, request);
+ }
+
+ public Subscription fetch(String id) throws RazorpayException {
+ return get(String.format(Constants.SUBSCRIPTION_GET, id), null);
+ }
+
+ public List fetchAll() throws RazorpayException {
+ return fetchAll(null);
+ }
+
+ public List fetchAll(JSONObject request) throws RazorpayException {
+ return getCollection(Constants.SUBSCRIPTION_LIST, request);
+ }
+
+ public Subscription cancel(String id) throws RazorpayException {
+ return post(String.format(Constants.SUBSCRIPTION_CANCEL, id), null);
+ }
+
+ public Addon createAddon(String id, JSONObject request) throws RazorpayException {
+ return post(String.format(Constants.SUBSCRIPTION_ADDON_CREATE, id), request);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Token.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Token.java
new file mode 100644
index 00000000000..0b48d0237b8
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Token.java
@@ -0,0 +1,9 @@
+package org.egov.pg.service.gateways.razorpay;
+import org.json.JSONObject;
+
+public class Token extends Entity {
+
+ public Token(JSONObject jsonObject) {
+ super(jsonObject);
+ }
+}
\ No newline at end of file
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Transfer.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Transfer.java
new file mode 100644
index 00000000000..452808f69f0
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Transfer.java
@@ -0,0 +1,9 @@
+package org.egov.pg.service.gateways.razorpay;
+import org.json.JSONObject;
+
+public class Transfer extends Entity {
+
+ public Transfer(JSONObject jsonObject) {
+ super(jsonObject);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/TransferClient.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/TransferClient.java
new file mode 100644
index 00000000000..0e3ed1a7912
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/TransferClient.java
@@ -0,0 +1,35 @@
+package org.egov.pg.service.gateways.razorpay;
+import java.util.List;
+
+import org.json.JSONObject;
+
+public class TransferClient extends ApiClient {
+
+ TransferClient(String auth) {
+ super(auth);
+ }
+
+ public Transfer create(JSONObject request) throws RazorpayException {
+ return post(Constants.TRANSFER_CREATE, request);
+ }
+
+ public Transfer edit(String id, JSONObject request) throws RazorpayException {
+ return patch(String.format(Constants.TRANSFER_EDIT, id), request);
+ }
+
+ public Reversal reversal(String id, JSONObject request) throws RazorpayException {
+ return post(String.format(Constants.TRANSFER_REVERSAL_CREATE, id), request);
+ }
+
+ public Transfer fetch(String id) throws RazorpayException {
+ return get(String.format(Constants.TRANSFER_GET, id), null);
+ }
+
+ public List fetchAll() throws RazorpayException {
+ return fetchAll(null);
+ }
+
+ public List fetchAll(JSONObject request) throws RazorpayException {
+ return getCollection(Constants.TRANSFER_LIST, request);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Utils.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Utils.java
new file mode 100644
index 00000000000..0248be4ab8c
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/Utils.java
@@ -0,0 +1,170 @@
+package org.egov.pg.service.gateways.razorpay;
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+
+import org.apache.commons.codec.binary.Hex;
+import org.egov.tracer.model.CustomException;
+import org.json.JSONObject;
+
+public class Utils {
+ // This is an array for creating hex chars
+ private static final char[] HEX_TABLE = new char[]{
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+
+ private static final DecimalFormat CURRENCY_FORMATTER_RUPEE = new DecimalFormat("0.00");
+ private static final DecimalFormat CURRENCY_FORMATTER_PAISE = new DecimalFormat("0");
+
+ private Utils() {
+ };
+
+ public static String formatAmtAsRupee(String txnAmount) {
+ return CURRENCY_FORMATTER_RUPEE.format(Double.valueOf(txnAmount));
+ }
+
+ public static String formatAmtAsPaise(String txnAmount) {
+ return CURRENCY_FORMATTER_PAISE.format(Double.valueOf(txnAmount) * 100);
+ }
+
+ public static String convertPaiseToRupee(String paise){
+ return new BigDecimal(paise).movePointLeft(2).toPlainString();
+ }
+
+ public static boolean verifyPaymentSignature(JSONObject attributes, String apiSecret)
+ throws RazorpayException {
+ String expectedSignature = attributes.getString("razorpay_signature");
+ String orderId = attributes.getString("razorpay_order_id");
+ String paymentId = attributes.getString("razorpay_payment_id");
+ String payload = orderId + '|' + paymentId;
+ return verifySignature(payload, expectedSignature, apiSecret);
+ }
+
+ public static boolean verifyWebhookSignature(String payload, String expectedSignature,
+ String webhookSecret) throws RazorpayException {
+ return verifySignature(payload, expectedSignature, webhookSecret);
+ }
+
+ public static boolean verifySignature(String payload, String expectedSignature, String secret)
+ throws RazorpayException {
+ String actualSignature = getHash(payload, secret);
+ return isEqual(actualSignature.getBytes(), expectedSignature.getBytes());
+ }
+
+ public static String getHash(String payload, String secret) throws RazorpayException {
+ Mac sha256_HMAC;
+ try {
+ sha256_HMAC = Mac.getInstance("HmacSHA256");
+ SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256");
+ sha256_HMAC.init(secret_key);
+ byte[] hash = sha256_HMAC.doFinal(payload.getBytes());
+ return new String(Hex.encodeHex(hash));
+ } catch (Exception e) {
+ throw new RazorpayException(e.getMessage());
+ }
+ }
+
+ /**
+ * We are not using String.equals() method because of security issue mentioned in
+ * StackOverflow
+ *
+ * @param a
+ * @param b
+ * @return boolean
+ */
+ private static boolean isEqual(byte[] a, byte[] b) {
+ if (a.length != b.length) {
+ return false;
+ }
+ int result = 0;
+ for (int i = 0; i < a.length; i++) {
+ result |= a[i] ^ b[i];
+ }
+ return result == 0;
+ }
+
+
+ private static byte[] fromHexString(String s, int offset, int length) {
+ if ((length % 2) != 0)
+ return null;
+ byte[] byteArray = new byte[length / 2];
+ int j = 0;
+ int end = offset + length;
+ for (int i = offset; i < end; i += 2) {
+ int high_nibble = Character.digit(s.charAt(i), 16);
+ int low_nibble = Character.digit(s.charAt(i + 1), 16);
+ if (high_nibble == -1 || low_nibble == -1) {
+ // illegal format
+ return null;
+ }
+ byteArray[j++] = (byte) (((high_nibble << 4) & 0xf0) | (low_nibble & 0x0f));
+ }
+ return byteArray;
+ }
+
+ /**
+ * Returns Hex output of byte array
+ */
+ private static String hex(byte[] input) {
+ // create a StringBuffer 2x the size of the hash array
+ StringBuilder sb = new StringBuilder(input.length * 2);
+
+ // retrieve the byte array data, convert it to hex
+ // and add it to the StringBuilder
+ for (byte anInput : input) {
+ sb.append(HEX_TABLE[(anInput >> 4) & 0xf]);
+ sb.append(HEX_TABLE[anInput & 0xf]);
+ }
+ return sb.toString();
+ }
+
+ static String SHAhashAllFields(Map fields, String secret) {
+
+ // create a list and sort it
+ List fieldNames = new ArrayList<>(fields.keySet());
+ Collections.sort(fieldNames);
+
+ // create a buffer for the SHA256 input
+ StringBuilder buf = new StringBuilder();
+
+
+ // iterate through the list and add the remaining field values
+ Iterator itr = fieldNames.iterator();
+ while (itr.hasNext()) {
+ String fieldName = (String) itr.next();
+ String fieldValue = fields.get(fieldName);
+ if ((fieldValue != null) && (fieldValue.length() > 0)) {
+ buf.append(fieldName).append("=").append(fieldValue);
+ if (itr.hasNext()) {
+ buf.append('&');
+ }
+ }
+ }
+ byte[] mac = null;
+ try {
+ byte[] b = fromHexString(secret, 0, secret.length());
+ SecretKey key = new SecretKeySpec(b, "HmacSHA256");
+ Mac m = Mac.getInstance("HmacSHA256");
+ m.init(key);
+
+ m.update(buf.toString().getBytes("ISO-8859-1"));
+ mac = m.doFinal();
+ } catch (NoSuchAlgorithmException | UnsupportedEncodingException | InvalidKeyException e) {
+ throw new CustomException("CHECKSUM_GEN_FAILED", "Hash generation failed, gateway redirect URI " +
+ "cannot be generated");
+ }
+ return hex(mac);
+
+ } // end hashAllFields()
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/VirtualAccount.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/VirtualAccount.java
new file mode 100644
index 00000000000..7e585ff4ef2
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/VirtualAccount.java
@@ -0,0 +1,9 @@
+package org.egov.pg.service.gateways.razorpay;
+import org.json.JSONObject;
+
+public class VirtualAccount extends Entity {
+
+ public VirtualAccount(JSONObject jsonObject) {
+ super(jsonObject);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/VirtualAccountClient.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/VirtualAccountClient.java
new file mode 100644
index 00000000000..4e4fe748501
--- /dev/null
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/gateways/razorpay/VirtualAccountClient.java
@@ -0,0 +1,43 @@
+package org.egov.pg.service.gateways.razorpay;
+import java.util.List;
+
+import org.json.JSONObject;
+
+public class VirtualAccountClient extends ApiClient {
+
+ VirtualAccountClient(String auth) {
+ super(auth);
+ }
+
+ public VirtualAccount create(JSONObject request) throws RazorpayException {
+ return post(Constants.VIRTUAL_ACCOUNT_CREATE, request);
+ }
+
+ public VirtualAccount fetch(String id) throws RazorpayException {
+ return get(String.format(Constants.VIRTUAL_ACCOUNT_GET, id), null);
+ }
+
+ public List fetchAll() throws RazorpayException {
+ return fetchAll(null);
+ }
+
+ public List fetchAll(JSONObject request) throws RazorpayException {
+ return getCollection(Constants.VIRTUAL_ACCOUNT_LIST, request);
+ }
+
+ public VirtualAccount edit(String id, JSONObject request) throws RazorpayException {
+ return patch(String.format(Constants.VIRTUAL_ACCOUNT_EDIT, id), request);
+ }
+
+ public VirtualAccount close(String id) throws RazorpayException {
+ return post(String.format(Constants.VIRTUAL_ACCOUNT_CLOSE, id), null);
+ }
+
+ public List fetchPayments(String id) throws RazorpayException {
+ return fetchPayments(id, null);
+ }
+
+ public List fetchPayments(String id, JSONObject request) throws RazorpayException {
+ return getCollection(String.format(Constants.VIRTUAL_ACCOUNT_PAYMENTS, id), request);
+ }
+}
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/jobs/dailyReconciliation/DailyReconciliationJob.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/jobs/dailyReconciliation/DailyReconciliationJob.java
index 45fb57ec066..c96d93570ec 100644
--- a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/jobs/dailyReconciliation/DailyReconciliationJob.java
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/jobs/dailyReconciliation/DailyReconciliationJob.java
@@ -31,6 +31,7 @@ public class DailyReconciliationJob implements Job {
@PostConstruct
public void init() {
User userInfo = User.builder()
+ //.uuid("DAILY_RECONC_JOB")
.uuid(appProperties.getEgovPgReconciliationSystemUserUuid())
.type("SYSTEM")
.roles(Collections.emptyList()).id(0L).build();
diff --git a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/jobs/earlyReconciliation/EarlyReconciliationJob.java b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/jobs/earlyReconciliation/EarlyReconciliationJob.java
index cb73bca506e..8b9e7db2e1c 100644
--- a/core-services/egov-pg-service/src/main/java/org/egov/pg/service/jobs/earlyReconciliation/EarlyReconciliationJob.java
+++ b/core-services/egov-pg-service/src/main/java/org/egov/pg/service/jobs/earlyReconciliation/EarlyReconciliationJob.java
@@ -32,6 +32,7 @@ public class EarlyReconciliationJob implements Job {
@PostConstruct
public void init() {
User userInfo = User.builder()
+ //.uuid("EARLY_RECONC_JOB")
.uuid(appProperties.getEgovPgReconciliationSystemUserUuid())
.type("SYSTEM")
.roles(Collections.emptyList()).id(0L).build();
diff --git a/core-services/egov-pg-service/src/main/resources/application.properties b/core-services/egov-pg-service/src/main/resources/application.properties
index 8f605a028f1..086caf4ab6a 100644
--- a/core-services/egov-pg-service/src/main/resources/application.properties
+++ b/core-services/egov-pg-service/src/main/resources/application.properties
@@ -6,9 +6,9 @@ pg.earlyReconcileJobRunInterval.mins=15
##----------------------------- SPRING DS CONFIGURATIONS ------------------------------#
spring.datasource.driver-class-name=org.postgresql.Driver
-spring.datasource.url=jdbc:postgresql://localhost:5432/pg_db
-spring.datasource.username=postgres
-spring.datasource.password=postgres
+spring.datasource.url=jdbc:postgresql://dbmsewa.ch88m0ouypx1.ap-south-1.rds.amazonaws.com:5432/egov_prod_db
+spring.datasource.username=msewapunjabnew
+spring.datasource.password=msewa123456
##----------------------------- FLYWAY CONFIGURATIONS ------------------------------#
spring.flyway.url=jdbc:postgresql://localhost:5432/pg_db
spring.flyway.user=postgres
@@ -17,7 +17,7 @@ spring.flyway.password=postgres
spring.flyway.baseline-on-migrate=true
spring.flyway.outOfOrder=true
spring.flyway.locations=classpath:/db/migration/main
-spring.flyway.enabled=true
+spring.flyway.enabled=false
##----------------------------- KAFKA CONFIGURATIONS ------------------------------#
kafka.config.bootstrap_server_config=localhost:9092
spring.kafka.consumer.value-deserializer=org.egov.tracer.kafka.deserializer.HashMapDeserializer
@@ -45,22 +45,25 @@ persister.update.pg.txns=update-pg-txns
persister.save.pg.txnsDump=save-pg-txns-dump
persister.update.pg.txnsDump=update-pg-txns-dump
##----------------------------- ID GEN CONFIGURATIONS ------------------------------#
-egov.idgen.host=https://dev.digit.org/
+egov.idgen.host=https://msewapunjab.niua.org/
egov.idgen.path=egov-idgen/id/_generate
egov.idgen.ack.name=pg.txnid
-egov.idgen.ack.format=PG_PG_[cy:yyyy_MM_dd]_[SEQ_EG_PG_TXN]_[d{2}]
+egov.idgen.ack.format=PB_PG_[cy:yyyy_MM_dd]_[SEQ_EG_PG_TXN]_[d{2}]
##----------------------------- BILLING SERVICE CONFIGURATIONS ------------------------------#
-egov.billingservice.host=https://dev.digit.org/
+egov.billingservice.host=https://msewapunjab.niua.org/
egov.billingservice.path=billing-service/bill/_search
##----------------------------- COLLECTIONS SERVICE CONFIGURATIONS ------------------------------#
-egov.collectionservice.host=http://localhost:8095/
+egov.collectionservice.host=https://msewapunjab.niua.org/
egov.collectionservice.create.path=collection-services/receipts/_create
egov.collectionservice.validate.path=collection-services/receipts/_validate
egov.collectionservice.payment.create.path=collection-services/payments/_create
egov.collectionservice.payment.validate.path=collection-services/payments/_validate
##----------------------------- EGF MASTER SERVICE CONFIGURATIONS ------------------------------#
-egov.bankaccountservice.host=https://dev.digit.org/
+egov.bankaccountservice.host=https://msewapunjab.niua.org/
egov.bankaccountservice.path=egf-master/bankaccounts/_search
+##----------------------------- EGOV COMMON MASTERS SERVICE CONFIGURATIONS ------------------------------#
+egov.businessdetailsservice.host=hhttps://msewapunjab.niua.org/
+egov.businessdetailsservice.path=/egov-common-masters/businessDetails/_search?tenantId={tenantId}&businessDetailsCodes={businessDetailsCodes}
##----------------------------- AXIS GATEWAY CONFIGURATIONS ------------------------------#
axis.active=true
axis.currency=INR
@@ -93,7 +96,7 @@ phonepe.merchant.host=mercury-uat.phonepe.com
phonepe.url.debit=/v3/debit
phonepe.url.status=/v3/transaction
##----------------------------- PAYGOV GATEWAY CONFIGURATIONS ------------------------------#
-paygov.active=true
+paygov.active=false
paygov.messagetype=0100
paygov.currency=INR
paygov.merchant.id=UATNIUACG0000001435
@@ -112,7 +115,7 @@ paygov.citizen.redirect.domain.name=https://upyog.niua.org
## Citizen url
egov.default.citizen.url=https://upyog.niua.org/citizen
##----------------------------- PG-Detail Configuration ------------------------------#
-egov.pgdetail.host=http://localhost:8098
+egov.pgdetail.host=https://msewapunjab.niua.org/
egov.pgdetail.path=/pg-detail/_get
##----------------------------- PHONEPE GATEWAY CONFIGURATIONS ------------------------------#
payu.active=true
@@ -124,9 +127,21 @@ payu.path.pay=_payment
payu.path.status=merchant/postservice.php
management.endpoints.web.base-path=/
+##----------------------------- RAZORPAY GATEWAY CONFIGURATIONS ------------------------------#
+razorpay.active=true
+razorpay.currency=INR
+razorpay.locale=en_IN
+razorpay.hash.algorithm=HmacSHA256
+razorpay.payment_capture=1
+razorpay.merchant.id=rzp_test_hs3Y3SvtPp4N1v
+razorpay.merchant.secret.key=3TmZATrd54EcKHVU0kMf983h
+##razorpay.merchant.id=rzp_live_H2n9kGeN5lFKnU
+##razorpay.merchant.secret.key=dCq9sPlSVvLpvz4D9QbfdShj
+razorpay.url.debit=https://api.razorpay.com/v1
+razorpay.url.status=https://api.razorpay.com/v1/orders
##----------------------------- NTT GATEWAY CONFIGURATIONS ------------------------------#
-nttdata.active=true
+nttdata.active=false
nttdata.merchant.id=317156
nttdata.redirect.url=https://upyog.niua.org/pg-service/transaction/v1/_redirect
nttdata.gateway.url.status=https://paynetzuat.atomtech.in/ots/payment/status?
@@ -137,36 +152,36 @@ nttdata.merchant.checkout.host=https://pgtest.atomtech.in/staticdata/ots/js/atom
##----------------------------- USER SERVICE CONFIGURATIONS ------------------------------#
-egov.userservice.host=http://localhost:8081/
+egov.user.host=http://egov-user:8080/
egov.userservice.create.path=user/users/_createnovalidate
egov.userservice.search.path=user/v1/_search
pg.is.user.create.enabled=true
#Notification
-notification.url = https://dev.digit.org/
+notification.url = https://msewapunjab.niua.org/
notification.sms.enabled=true
kafka.topics.notification.sms=egov.core.notification.sms
#Localization config
-egov.localization.host=http://egov-localization.egov:8080
+egov.localization.host=https://msewapunjab.niua.org/
egov.localization.context.path=/localization/messages/v1
egov.localization.search.endpoint=/_search
egov.localization.statelevel=true
#url shortner
-egov.url.shortner.host=http://egov-url-shortening.egov:8080
+egov.url.shortner.host=https://msewapunjab.niua.org/
egov.url.shortner.endpoint=/egov-url-shortening/shortener
egov.application.pay.link=citizen/withoutAuth/egov-common/pay?consumerCode=$consumerCode&tenantId=$tenantId&businessService=$businessService
#Billing service
-egov.billing.service.host=http://billing-service.egov:8080
+egov.billing.service.host=https://msewapunjab.niua.org/
egov.bill.searchendpoint=/billing-service/bill/v2/_search
egov.pg.reconciliation.system.user.uuid=b405e4d0-99ec-41b1-92e7-2ebda0321e0d
-state.level.tenant.id=pg
+state.level.tenant.id=pb
//systemuser
internal.microservice.role.name=Internal Microservice Role
diff --git a/core-services/egov-pg-service/src/main/resources/db/Dockerfile b/core-services/egov-pg-service/src/main/resources/db/Dockerfile
index 545849c838d..771179b458c 100644
--- a/core-services/egov-pg-service/src/main/resources/db/Dockerfile
+++ b/core-services/egov-pg-service/src/main/resources/db/Dockerfile
@@ -1,13 +1,13 @@
-FROM upyogio/flyway:4.1.2
+FROM egovio/flyway:10.7.1
COPY ./migration/main /flyway/sql
-COPY ./migration/dev /flyway/dev
+#COPY ./migration/dev /flyway/dev
-COPY ./migration/seed /flyway/seed
+#COPY ./migration/seed /flyway/seed
COPY migrate.sh /usr/bin/migrate.sh
RUN chmod +x /usr/bin/migrate.sh
-CMD ["/usr/bin/migrate.sh"]
+ENTRYPOINT ["/usr/bin/migrate.sh"]
diff --git a/core-services/egov-pg-service/src/main/resources/db/migrate.sh b/core-services/egov-pg-service/src/main/resources/db/migrate.sh
index 5593a173eba..3b0babd2007 100644
--- a/core-services/egov-pg-service/src/main/resources/db/migrate.sh
+++ b/core-services/egov-pg-service/src/main/resources/db/migrate.sh
@@ -1,3 +1,3 @@
#!/bin/sh
-flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true migrate
\ No newline at end of file
+flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -validateOnMigrate=false migrate
diff --git a/core-services/egov-pg-service/src/main/resources/db/migration/main/V20180607185601__eg_pg_ddl.sql b/core-services/egov-pg-service/src/main/resources/db/migration/main/V20180607185601__eg_pg_ddl.sql
index be5f40a0524..5bd8013f57b 100644
--- a/core-services/egov-pg-service/src/main/resources/db/migration/main/V20180607185601__eg_pg_ddl.sql
+++ b/core-services/egov-pg-service/src/main/resources/db/migration/main/V20180607185601__eg_pg_ddl.sql
@@ -1,7 +1,7 @@
-DROP TABLE IF EXISTS eg_pg_transactions;
-DROP TABLE IF EXISTS eg_pg_transactions_dump;
+-- DROP TABLE IF EXISTS eg_pg_transactions;
+-- DROP TABLE IF EXISTS eg_pg_transactions_dump;
-CREATE TABLE "eg_pg_transactions" (
+CREATE TABLE IF NOt EXISTS "eg_pg_transactions" (
"txn_id" VARCHAR(128) NOT NULL,
"txn_amount" NUMERIC(15,2) NOT NULL,
"txn_status" VARCHAR(64) NOT NULL,
@@ -30,7 +30,7 @@ CREATE TABLE "eg_pg_transactions" (
PRIMARY KEY ("txn_id")
);
-CREATE TABLE "eg_pg_transactions_dump" (
+CREATE TABLE IF NOT EXISTS "eg_pg_transactions_dump" (
"txn_id" VARCHAR(128) NOT NULL,
"txn_request" varchar NULL,
"txn_response" JSONB NULL,
diff --git a/core-services/egov-pg-service/src/main/resources/db/migration/main/V20180613110701__eg_pg_quartz_ddl.sql b/core-services/egov-pg-service/src/main/resources/db/migration/main/V20180613110701__eg_pg_quartz_ddl.sql
index ae55997679e..34831ccf2f8 100644
--- a/core-services/egov-pg-service/src/main/resources/db/migration/main/V20180613110701__eg_pg_quartz_ddl.sql
+++ b/core-services/egov-pg-service/src/main/resources/db/migration/main/V20180613110701__eg_pg_quartz_ddl.sql
@@ -1,17 +1,17 @@
-DROP TABLE IF EXISTS eg_pg_qrtz_fired_triggers;
-DROP TABLE IF EXISTS eg_pg_qrtz_PAUSED_TRIGGER_GRPS;
-DROP TABLE IF EXISTS eg_pg_qrtz_SCHEDULER_STATE;
-DROP TABLE IF EXISTS eg_pg_qrtz_LOCKS;
-DROP TABLE IF EXISTS eg_pg_qrtz_simple_triggers;
-DROP TABLE IF EXISTS eg_pg_qrtz_cron_triggers;
-DROP TABLE IF EXISTS eg_pg_qrtz_simprop_triggers;
-DROP TABLE IF EXISTS eg_pg_qrtz_BLOB_TRIGGERS;
-DROP TABLE IF EXISTS eg_pg_qrtz_triggers;
-DROP TABLE IF EXISTS eg_pg_qrtz_job_details;
-DROP TABLE IF EXISTS eg_pg_qrtz_calendars;
-
-CREATE TABLE eg_pg_qrtz_job_details
+-- DROP TABLE IF EXISTS eg_pg_qrtz_fired_triggers;
+-- DROP TABLE IF EXISTS eg_pg_qrtz_PAUSED_TRIGGER_GRPS;
+-- DROP TABLE IF EXISTS eg_pg_qrtz_SCHEDULER_STATE;
+-- DROP TABLE IF EXISTS eg_pg_qrtz_LOCKS;
+-- DROP TABLE F EXISTS eg_pg_qrtz_simple_triggers;
+-- DROP TABLE IF EXISTS eg_pg_qrtz_cron_triggers;
+-- DROP TABLE IF EXISTS eg_pg_qrtz_simprop_triggers;
+-- DROP TABLE IF EXISTS eg_pg_qrtz_BLOB_TRIGGERS;
+-- DROP TABLE IF EXISTS eg_pg_qrtz_triggers;
+-- DROP TABLE IF EXISTS eg_pg_qrtz_job_details;
+-- DROP TABLE IF EXISTS eg_pg_qrtz_calendars;
+
+CREATE TABLE IF NOT EXISTS eg_pg_qrtz_job_details
(
SCHED_NAME VARCHAR(120) NOT NULL,
JOB_NAME VARCHAR(200) NOT NULL,
@@ -26,7 +26,7 @@ CREATE TABLE eg_pg_qrtz_job_details
PRIMARY KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)
);
-CREATE TABLE eg_pg_qrtz_triggers
+CREATE TABLE IF NOT EXISTS eg_pg_qrtz_triggers
(
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
@@ -49,7 +49,7 @@ CREATE TABLE eg_pg_qrtz_triggers
REFERENCES eg_pg_qrtz_JOB_DETAILS(SCHED_NAME,JOB_NAME,JOB_GROUP)
);
-CREATE TABLE eg_pg_qrtz_simple_triggers
+CREATE TABLE IF NOT EXISTS eg_pg_qrtz_simple_triggers
(
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
@@ -62,7 +62,7 @@ CREATE TABLE eg_pg_qrtz_simple_triggers
REFERENCES eg_pg_qrtz_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
);
-CREATE TABLE eg_pg_qrtz_cron_triggers
+CREATE TABLE IF NOT EXISTS eg_pg_qrtz_cron_triggers
(
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
@@ -74,7 +74,7 @@ CREATE TABLE eg_pg_qrtz_cron_triggers
REFERENCES eg_pg_qrtz_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
);
-CREATE TABLE eg_pg_qrtz_simprop_triggers
+CREATE TABLE IF NOT EXISTS eg_pg_qrtz_simprop_triggers
(
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
@@ -95,7 +95,7 @@ CREATE TABLE eg_pg_qrtz_simprop_triggers
REFERENCES eg_pg_qrtz_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
);
-CREATE TABLE eg_pg_qrtz_blob_triggers
+CREATE TABLE IF NOT EXISTS eg_pg_qrtz_blob_triggers
(
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_NAME VARCHAR(200) NOT NULL,
@@ -106,7 +106,7 @@ CREATE TABLE eg_pg_qrtz_blob_triggers
REFERENCES eg_pg_qrtz_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
);
-CREATE TABLE eg_pg_qrtz_calendars
+CREATE TABLE IF NOT EXISTS eg_pg_qrtz_calendars
(
SCHED_NAME VARCHAR(120) NOT NULL,
CALENDAR_NAME VARCHAR(200) NOT NULL,
@@ -115,14 +115,14 @@ CREATE TABLE eg_pg_qrtz_calendars
);
-CREATE TABLE eg_pg_qrtz_paused_trigger_grps
+CREATE TABLE IF NOT EXISTS eg_pg_qrtz_paused_trigger_grps
(
SCHED_NAME VARCHAR(120) NOT NULL,
TRIGGER_GROUP VARCHAR(200) NOT NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_GROUP)
);
-CREATE TABLE eg_pg_qrtz_fired_triggers
+CREATE TABLE IF NOT EXISTS eg_pg_qrtz_fired_triggers
(
SCHED_NAME VARCHAR(120) NOT NULL,
ENTRY_ID VARCHAR(95) NOT NULL,
@@ -140,7 +140,7 @@ CREATE TABLE eg_pg_qrtz_fired_triggers
PRIMARY KEY (SCHED_NAME,ENTRY_ID)
);
-CREATE TABLE eg_pg_qrtz_scheduler_state
+CREATE TABLE IF NOT EXISTS eg_pg_qrtz_scheduler_state
(
SCHED_NAME VARCHAR(120) NOT NULL,
INSTANCE_NAME VARCHAR(200) NOT NULL,
@@ -149,35 +149,35 @@ CREATE TABLE eg_pg_qrtz_scheduler_state
PRIMARY KEY (SCHED_NAME,INSTANCE_NAME)
);
-CREATE TABLE eg_pg_qrtz_locks
+CREATE TABLE IF NOT EXISTS eg_pg_qrtz_locks
(
SCHED_NAME VARCHAR(120) NOT NULL,
LOCK_NAME VARCHAR(40) NOT NULL,
PRIMARY KEY (SCHED_NAME,LOCK_NAME)
);
-create index idx_eg_pg_qrtz_j_req_recovery on eg_pg_qrtz_job_details(SCHED_NAME,REQUESTS_RECOVERY);
-create index idx_eg_pg_qrtz_j_grp on eg_pg_qrtz_job_details(SCHED_NAME,JOB_GROUP);
-
-create index idx_eg_pg_qrtz_t_j on eg_pg_qrtz_triggers(SCHED_NAME,JOB_NAME,JOB_GROUP);
-create index idx_eg_pg_qrtz_t_jg on eg_pg_qrtz_triggers(SCHED_NAME,JOB_GROUP);
-create index idx_eg_pg_qrtz_t_c on eg_pg_qrtz_triggers(SCHED_NAME,CALENDAR_NAME);
-create index idx_eg_pg_qrtz_t_g on eg_pg_qrtz_triggers(SCHED_NAME,TRIGGER_GROUP);
-create index idx_eg_pg_qrtz_t_state on eg_pg_qrtz_triggers(SCHED_NAME,TRIGGER_STATE);
-create index idx_eg_pg_qrtz_t_n_state on eg_pg_qrtz_triggers(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_STATE);
-create index idx_eg_pg_qrtz_t_n_g_state on eg_pg_qrtz_triggers(SCHED_NAME,TRIGGER_GROUP,TRIGGER_STATE);
-create index idx_eg_pg_qrtz_t_next_fire_time on eg_pg_qrtz_triggers(SCHED_NAME,NEXT_FIRE_TIME);
-create index idx_eg_pg_qrtz_t_nft_st on eg_pg_qrtz_triggers(SCHED_NAME,TRIGGER_STATE,NEXT_FIRE_TIME);
-create index idx_eg_pg_qrtz_t_nft_misfire on eg_pg_qrtz_triggers(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME);
-create index idx_eg_pg_qrtz_t_nft_st_misfire on eg_pg_qrtz_triggers(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_STATE);
-create index idx_eg_pg_qrtz_t_nft_st_misfire_grp on eg_pg_qrtz_triggers(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_GROUP,TRIGGER_STATE);
-
-create index idx_eg_pg_qrtz_ft_trig_inst_name on eg_pg_qrtz_fired_triggers(SCHED_NAME,INSTANCE_NAME);
-create index idx_eg_pg_qrtz_ft_inst_job_req_rcvry on eg_pg_qrtz_fired_triggers(SCHED_NAME,INSTANCE_NAME,REQUESTS_RECOVERY);
-create index idx_eg_pg_qrtz_ft_j_g on eg_pg_qrtz_fired_triggers(SCHED_NAME,JOB_NAME,JOB_GROUP);
-create index idx_eg_pg_qrtz_ft_jg on eg_pg_qrtz_fired_triggers(SCHED_NAME,JOB_GROUP);
-create index idx_eg_pg_qrtz_ft_t_g on eg_pg_qrtz_fired_triggers(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP);
-create index idx_eg_pg_qrtz_ft_tg on eg_pg_qrtz_fired_triggers(SCHED_NAME,TRIGGER_GROUP);
+create index IF NOT EXISTS idx_eg_pg_qrtz_j_req_recovery on eg_pg_qrtz_job_details(SCHED_NAME,REQUESTS_RECOVERY);
+create index IF NOT EXISTS idx_eg_pg_qrtz_j_grp on eg_pg_qrtz_job_details(SCHED_NAME,JOB_GROUP);
+
+create index IF NOT EXISTS idx_eg_pg_qrtz_t_j on eg_pg_qrtz_triggers(SCHED_NAME,JOB_NAME,JOB_GROUP);
+create index IF NOT EXISTS idx_eg_pg_qrtz_t_jg on eg_pg_qrtz_triggers(SCHED_NAME,JOB_GROUP);
+create index IF NOT EXISTS idx_eg_pg_qrtz_t_c on eg_pg_qrtz_triggers(SCHED_NAME,CALENDAR_NAME);
+create index IF NOT EXISTS idx_eg_pg_qrtz_t_g on eg_pg_qrtz_triggers(SCHED_NAME,TRIGGER_GROUP);
+create index IF NOT EXISTS idx_eg_pg_qrtz_t_state on eg_pg_qrtz_triggers(SCHED_NAME,TRIGGER_STATE);
+create index IF NOT EXISTS idx_eg_pg_qrtz_t_n_state on eg_pg_qrtz_triggers(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_STATE);
+create index IF NOT EXISTS idx_eg_pg_qrtz_t_n_g_state on eg_pg_qrtz_triggers(SCHED_NAME,TRIGGER_GROUP,TRIGGER_STATE);
+create index IF NOT EXISTS idx_eg_pg_qrtz_t_next_fire_time on eg_pg_qrtz_triggers(SCHED_NAME,NEXT_FIRE_TIME);
+create index IF NOT EXISTS idx_eg_pg_qrtz_t_nft_st on eg_pg_qrtz_triggers(SCHED_NAME,TRIGGER_STATE,NEXT_FIRE_TIME);
+create index IF NOT EXISTS idx_eg_pg_qrtz_t_nft_misfire on eg_pg_qrtz_triggers(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME);
+create index IF NOT EXISTS idx_eg_pg_qrtz_t_nft_st_misfire on eg_pg_qrtz_triggers(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_STATE);
+create index IF NOT EXISTS idx_eg_pg_qrtz_t_nft_st_misfire_grp on eg_pg_qrtz_triggers(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_GROUP,TRIGGER_STATE);
+
+create index IF NOT EXISTS idx_eg_pg_qrtz_ft_trig_inst_name on eg_pg_qrtz_fired_triggers(SCHED_NAME,INSTANCE_NAME);
+create index IF NOT EXISTS idx_eg_pg_qrtz_ft_inst_job_req_rcvry on eg_pg_qrtz_fired_triggers(SCHED_NAME,INSTANCE_NAME,REQUESTS_RECOVERY);
+create index IF NOT EXISTS idx_eg_pg_qrtz_ft_j_g on eg_pg_qrtz_fired_triggers(SCHED_NAME,JOB_NAME,JOB_GROUP);
+create index IF NOT EXISTS idx_eg_pg_qrtz_ft_jg on eg_pg_qrtz_fired_triggers(SCHED_NAME,JOB_GROUP);
+create index IF NOT EXISTS idx_eg_pg_qrtz_ft_t_g on eg_pg_qrtz_fired_triggers(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP);
+create index IF NOT EXISTS idx_eg_pg_qrtz_ft_tg on eg_pg_qrtz_fired_triggers(SCHED_NAME,TRIGGER_GROUP);
commit;
diff --git a/core-services/egov-pg-service/src/main/resources/db/migration/main/V20190326220501__alter_eg_pg_transactions.sql b/core-services/egov-pg-service/src/main/resources/db/migration/main/V20190326220501__alter_eg_pg_transactions.sql
index 2309172e961..ab774f48334 100644
--- a/core-services/egov-pg-service/src/main/resources/db/migration/main/V20190326220501__alter_eg_pg_transactions.sql
+++ b/core-services/egov-pg-service/src/main/resources/db/migration/main/V20190326220501__alter_eg_pg_transactions.sql
@@ -1,6 +1,6 @@
ALTER TABLE eg_pg_transactions ALTER COLUMN "module" DROP NOT NULL;
ALTER TABLE eg_pg_transactions ALTER COLUMN "module_id" DROP NOT NULL;
ALTER TABLE eg_pg_transactions ALTER COLUMN "txn_status_msg" DROP NOT NULL;
-ALTER TABLE eg_pg_transactions ADD COLUMN "consumer_code" VARCHAR(128);
+ALTER TABLE eg_pg_transactions ADD COLUMN IF NOT EXISTS "consumer_code" VARCHAR(128);
UPDATE eg_pg_transactions SET consumer_code = module_id;
-ALTER TABLE eg_pg_transactions ADD COLUMN "additional_details" JSONB NULL;
\ No newline at end of file
+ALTER TABLE eg_pg_transactions ADD COLUMN IF NOT EXISTS "additional_details" JSONB NULL;
\ No newline at end of file
diff --git a/core-services/egov-user/pom.xml b/core-services/egov-user/pom.xml
index 5e3852e9f47..6499458fa93 100644
--- a/core-services/egov-user/pom.xml
+++ b/core-services/egov-user/pom.xml
@@ -21,8 +21,25 @@
2.9.6
UTF-8
1.16.12
+ 1.2.0.Final
+
+ org.cache2k
+ cache2k-api
+ ${cache2k-version}
+
+
+ org.cache2k
+ cache2k-core
+ ${cache2k-version}
+ runtime
+
+
+ org.cache2k
+ cache2k-spring
+ ${cache2k-version}
+
ch.qos.logback
logback-classic
@@ -31,7 +48,7 @@
org.egov.services
tracer
- 2.1.2-SNAPSHOT
+ 1.1.5-SNAPSHOT
org.springframework.kafka
@@ -46,7 +63,7 @@
org.egov.services
services-common
- 1.1.1-SNAPSHOT
+ 1.0.1-SNAPSHOT
@@ -103,7 +120,7 @@
org.postgresql
postgresql
- 9.4.1212
+ 42.2.18
runtime
@@ -129,7 +146,7 @@
org.egov
mdms-client
- 0.0.2-SNAPSHOT
+ 0.0.3-SNAPSHOT
spring-boot-devtools
diff --git a/core-services/egov-user/src/main/java/org/egov/user/EgovUserApplication.java b/core-services/egov-user/src/main/java/org/egov/user/EgovUserApplication.java
index 8573a97519c..6f884060e55 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/EgovUserApplication.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/EgovUserApplication.java
@@ -6,6 +6,7 @@
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
+import org.cache2k.extra.spring.SpringCache2kCacheManager;
import org.egov.encryption.EncryptionService;
import org.egov.encryption.config.EncryptionConfiguration;
import org.egov.tracer.config.TracerConfiguration;
@@ -25,8 +26,11 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cache.CacheManager;
+import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
+import org.springframework.context.annotation.Profile;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
@@ -42,6 +46,7 @@
import javax.annotation.PostConstruct;
import java.text.SimpleDateFormat;
import java.util.*;
+import java.util.concurrent.TimeUnit;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@@ -51,6 +56,7 @@
@SpringBootApplication
@Slf4j
+@EnableCaching
@Import({TracerConfiguration.class, EncryptionConfiguration.class})
public class EgovUserApplication {
@@ -66,6 +72,8 @@ public class EgovUserApplication {
@Autowired
private CustomAuthenticationKeyGenerator customAuthenticationKeyGenerator;
+ @Value("${cache.expiry.masterdata.minutes:5}")
+ private long masterDataExpiry;
@PostConstruct
public void initialize() {
@@ -116,6 +124,13 @@ public TokenStore tokenStore() {
}
@Bean
+ @Profile("!test")
+ public CacheManager cacheManager() {
+ return new SpringCache2kCacheManager("cache-" + hashCode())
+ .addCaches(b->b.name("cRolesByCode").expireAfterWrite(masterDataExpiry, TimeUnit.MINUTES).entryCapacity(50));
+ }
+
+ @Bean
public JedisConnectionFactory connectionFactory() {
return new JedisConnectionFactory(new JedisShardInfo(host));
}
diff --git a/core-services/egov-user/src/main/java/org/egov/user/config/UserServiceConstants.java b/core-services/egov-user/src/main/java/org/egov/user/config/UserServiceConstants.java
index 7175fea24aa..7a56d195d4e 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/config/UserServiceConstants.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/config/UserServiceConstants.java
@@ -55,7 +55,7 @@ public class UserServiceConstants {
public static final String IP_HEADER_NAME = "x-real-ip";
- public static final String PATTERN_NAME = "^[^\\\\$\\\"<>?\\\\\\\\~`!@#$%^()+={}\\\\[\\\\]*,:;“”‘’]*$";
+ public static final String PATTERN_NAME = "^[^\\$\"'<>?~`!@#$%^()+={}\\[\\]*:;“”‘’]*$";
public static final String PATTERN_GENDER = "^[a-zA-Z ]*$";
diff --git a/core-services/egov-user/src/main/java/org/egov/user/domain/model/Address.java b/core-services/egov-user/src/main/java/org/egov/user/domain/model/Address.java
index 57d6d9dfa0f..45bd6d29d1d 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/domain/model/Address.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/domain/model/Address.java
@@ -5,7 +5,7 @@
import org.egov.user.domain.model.enums.AddressType;
import java.util.Date;
-
+@NoArgsConstructor
@Getter
@Setter
@Builder
diff --git a/core-services/egov-user/src/main/java/org/egov/user/domain/model/Role.java b/core-services/egov-user/src/main/java/org/egov/user/domain/model/Role.java
index 844c59a3a97..1aa0b20e957 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/domain/model/Role.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/domain/model/Role.java
@@ -3,7 +3,7 @@
import lombok.*;
import java.util.Date;
-
+@NoArgsConstructor
@Getter
@Setter
@Builder
diff --git a/core-services/egov-user/src/main/java/org/egov/user/domain/model/UpdateRequest.java b/core-services/egov-user/src/main/java/org/egov/user/domain/model/UpdateRequest.java
index 3a3d570004d..ac1029e7b0a 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/domain/model/UpdateRequest.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/domain/model/UpdateRequest.java
@@ -71,7 +71,7 @@ public class UpdateRequest {
public UpdateRequest(User user) {
this.id = user.getId();
- this.userName = user.getUsername();
+ this.userName = user.getUserName();
this.salutation = user.getSalutation();
this.name = user.getName();
this.gender = user.getGender() != null ? user.getGender().toString() : null;
@@ -138,7 +138,7 @@ public User toDomain(Long loggedInUserId, boolean isCreate) {
.uuid(this.uuid)
.id(this.id)
.name(this.name)
- .username(this.userName)
+ .userName(this.userName)
.salutation(this.salutation)
.mobileNumber(this.mobileNumber)
.emailId(this.emailId)
diff --git a/core-services/egov-user/src/main/java/org/egov/user/domain/model/User.java b/core-services/egov-user/src/main/java/org/egov/user/domain/model/User.java
index 518e699acb6..f0c6dac2e2d 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/domain/model/User.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/domain/model/User.java
@@ -25,7 +25,7 @@
import javax.validation.constraints.Size;
import static org.springframework.util.ObjectUtils.isEmpty;
-
+@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@@ -39,7 +39,7 @@ public class User {
@Pattern(regexp = UserServiceConstants.PATTERN_TENANT)
@Size(max = 50)
private String tenantId;
- private String username;
+ private String userName;
private String title;
private String password;
private String salutation;
@@ -167,7 +167,7 @@ public boolean isNameAbsent() {
@JsonIgnore
public boolean isUsernameAbsent() {
- return isEmpty(username);
+ return isEmpty(userName);
}
@JsonIgnore
@@ -191,7 +191,7 @@ public boolean isIdAbsent() {
}
public void nullifySensitiveFields() {
- username = null;
+ userName = null;
type = null;
mobileNumber = null;
password = null;
diff --git a/core-services/egov-user/src/main/java/org/egov/user/domain/model/UserSearchCriteria.java b/core-services/egov-user/src/main/java/org/egov/user/domain/model/UserSearchCriteria.java
index f05a71c682a..cd94ec6def7 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/domain/model/UserSearchCriteria.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/domain/model/UserSearchCriteria.java
@@ -14,6 +14,7 @@
@Setter
@Builder
@ToString
+@NoArgsConstructor
public class UserSearchCriteria {
private List id;
diff --git a/core-services/egov-user/src/main/java/org/egov/user/domain/model/enums/GuardianRelation.java b/core-services/egov-user/src/main/java/org/egov/user/domain/model/enums/GuardianRelation.java
index de652b5f166..d6fd6fce0b8 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/domain/model/enums/GuardianRelation.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/domain/model/enums/GuardianRelation.java
@@ -41,5 +41,5 @@
package org.egov.user.domain.model.enums;
public enum GuardianRelation {
- FATHER, MOTHER, HUSBAND, OTHER;
+ Father, Mother, Husband, Other;
}
diff --git a/core-services/egov-user/src/main/java/org/egov/user/domain/service/UserService.java b/core-services/egov-user/src/main/java/org/egov/user/domain/service/UserService.java
index 79a89c9b4a0..54789dd61d2 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/domain/service/UserService.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/domain/service/UserService.java
@@ -1,659 +1,657 @@
-package org.egov.user.domain.service;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.databind.ObjectWriter;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.egov.common.contract.request.RequestInfo;
-import org.egov.tracer.model.CustomException;
-import org.egov.user.domain.exception.*;
-import org.egov.user.domain.model.LoggedInUserUpdatePasswordRequest;
-import org.egov.user.domain.model.NonLoggedInUserUpdatePasswordRequest;
-import org.egov.user.domain.model.User;
-import org.egov.user.domain.model.UserSearchCriteria;
-import org.egov.user.domain.model.enums.UserType;
-import org.egov.user.domain.service.utils.EncryptionDecryptionUtil;
-import org.egov.user.domain.service.utils.NotificationUtil;
-import org.egov.user.persistence.dto.FailedLoginAttempt;
-import org.egov.user.persistence.repository.FileStoreRepository;
-import org.egov.user.persistence.repository.OtpRepository;
-import org.egov.user.persistence.repository.UserRepository;
-import org.egov.user.web.contract.Otp;
-import org.egov.user.web.contract.OtpValidateRequest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.MediaType;
-import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.security.oauth2.common.OAuth2AccessToken;
-import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
-import org.springframework.security.oauth2.provider.token.TokenStore;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-import org.springframework.util.LinkedMultiValueMap;
-import org.springframework.util.MultiValueMap;
-import org.springframework.web.client.RestTemplate;
-
-import java.io.IOException;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
-import static java.util.Objects.isNull;
-import static org.apache.commons.lang3.StringUtils.isEmpty;
-import static org.egov.user.config.UserServiceConstants.USER_CLIENT_ID;
-import static org.springframework.util.CollectionUtils.isEmpty;
-
-@Service
-@Slf4j
-public class UserService {
-
- private UserRepository userRepository;
- private OtpRepository otpRepository;
- private PasswordEncoder passwordEncoder;
- private int defaultPasswordExpiryInDays;
- private boolean isCitizenLoginOtpBased;
- private boolean isEmployeeLoginOtpBased;
- private FileStoreRepository fileRepository;
- private EncryptionDecryptionUtil encryptionDecryptionUtil;
- private TokenStore tokenStore;
-
- @Value("${egov.user.host}")
- private String userHost;
-
- @Value("${account.unlock.cool.down.period.minutes}")
- private Long accountUnlockCoolDownPeriod;
-
- @Value("${max.invalid.login.attempts.period.minutes}")
- private Long maxInvalidLoginAttemptsPeriod;
-
- @Value("${create.user.validate.name}")
- private boolean createUserValidateName;
-
- @Value("${max.invalid.login.attempts}")
- private Long maxInvalidLoginAttempts;
-
-
- @Value("${egov.user.pwd.pattern}")
- private String pwdRegex;
-
- @Value("${egov.user.pwd.pattern.min.length}")
- private Integer pwdMinLength;
-
- @Value("${egov.user.pwd.pattern.max.length}")
- private Integer pwdMaxLength;
-
- @Autowired
- private RestTemplate restTemplate;
-
- @Autowired
- private NotificationUtil notificationUtil;
-
- public UserService(UserRepository userRepository, OtpRepository otpRepository, FileStoreRepository fileRepository,
- PasswordEncoder passwordEncoder, EncryptionDecryptionUtil encryptionDecryptionUtil, TokenStore tokenStore,
- @Value("${default.password.expiry.in.days}") int defaultPasswordExpiryInDays,
- @Value("${citizen.login.password.otp.enabled}") boolean isCitizenLoginOtpBased,
- @Value("${employee.login.password.otp.enabled}") boolean isEmployeeLoginOtpBased,
- @Value("${egov.user.pwd.pattern}") String pwdRegex,
- @Value("${egov.user.pwd.pattern.max.length}") Integer pwdMaxLength,
- @Value("${egov.user.pwd.pattern.min.length}") Integer pwdMinLength) {
- this.userRepository = userRepository;
- this.otpRepository = otpRepository;
- this.passwordEncoder = passwordEncoder;
- this.defaultPasswordExpiryInDays = defaultPasswordExpiryInDays;
- this.isCitizenLoginOtpBased = isCitizenLoginOtpBased;
- this.isEmployeeLoginOtpBased = isEmployeeLoginOtpBased;
- this.fileRepository = fileRepository;
- this.encryptionDecryptionUtil = encryptionDecryptionUtil;
- this.tokenStore = tokenStore;
- this.pwdRegex = pwdRegex;
- this.pwdMaxLength = pwdMaxLength;
- this.pwdMinLength = pwdMinLength;
-
- }
-
- /**
- * get user By UserName And TenantId
- *
- * @param userName
- * @param tenantId
- * @return
- */
- public User getUniqueUser(String userName, String tenantId, UserType userType) {
-
- UserSearchCriteria userSearchCriteria = UserSearchCriteria.builder()
- .userName(userName)
- .tenantId(getStateLevelTenantForCitizen(tenantId, userType))
- .type(userType)
- .build();
-
- if (isEmpty(userName) || isEmpty(tenantId) || isNull(userType)) {
- log.error("Invalid lookup, mandatory fields are absent");
- throw new UserNotFoundException(userSearchCriteria);
- }
-
- /* encrypt here */
-
- userSearchCriteria = encryptionDecryptionUtil.encryptObject(userSearchCriteria, "User", UserSearchCriteria.class);
- List users = userRepository.findAll(userSearchCriteria);
-
- if (users.isEmpty())
- throw new UserNotFoundException(userSearchCriteria);
- if (users.size() > 1)
- throw new DuplicateUserNameException(userSearchCriteria);
-
- return users.get(0);
- }
-
- public User getUserByUuid(String uuid) {
-
- UserSearchCriteria userSearchCriteria = UserSearchCriteria.builder()
- .uuid(Collections.singletonList(uuid))
- .build();
-
- if (isEmpty(uuid)) {
- log.error("UUID is mandatory");
- throw new UserNotFoundException(userSearchCriteria);
- }
-
- List users = userRepository.findAll(userSearchCriteria);
-
- if (users.isEmpty())
- throw new UserNotFoundException(userSearchCriteria);
- return users.get(0);
- }
-
-
- /**
- * get the users based on on userSearch criteria
- *
- * @param searchCriteria
- * @return
- */
-
- public List searchUsers(UserSearchCriteria searchCriteria,
- boolean isInterServiceCall, RequestInfo requestInfo) {
-
- searchCriteria.validate(isInterServiceCall);
-
- searchCriteria.setTenantId(getStateLevelTenantForCitizen(searchCriteria.getTenantId(), searchCriteria.getType()));
- /* encrypt here / encrypted searchcriteria will be used for search*/
-
- String altmobnumber=null;
-
- if(searchCriteria.getMobileNumber()!=null) {
- altmobnumber = searchCriteria.getMobileNumber();
- }
-
- searchCriteria = encryptionDecryptionUtil.encryptObject(searchCriteria, "User", UserSearchCriteria.class);
-
- if(altmobnumber!=null) {
- searchCriteria.setAlternatemobilenumber(altmobnumber);
- }
-
- List list = userRepository.findAll(searchCriteria);
-
- /* decrypt here / final reponse decrypted*/
-
- list = encryptionDecryptionUtil.decryptObject(list, null, User.class, requestInfo);
-
- setFileStoreUrlsByFileStoreIds(list);
- return list;
- }
-
- /**
- * api will create the user based on some validations
- *
- * @param user
- * @return
- */
- public User createUser(User user, RequestInfo requestInfo) {
- user.setUuid(UUID.randomUUID().toString());
- user.validateNewUser(createUserValidateName);
- conditionallyValidateOtp(user);
- /* encrypt here */
- user = encryptionDecryptionUtil.encryptObject(user, "User", User.class);
- validateUserUniqueness(user);
- if (isEmpty(user.getPassword())) {
- user.setPassword(UUID.randomUUID().toString());
- } else {
- validatePassword(user.getPassword());
- }
- user.setPassword(encryptPwd(user.getPassword()));
- user.setDefaultPasswordExpiry(defaultPasswordExpiryInDays);
- user.setTenantId(getStateLevelTenantForCitizen(user.getTenantId(), user.getType()));
- User persistedNewUser = persistNewUser(user);
- return encryptionDecryptionUtil.decryptObject(persistedNewUser, "UserSelf", User.class, requestInfo);
-
- /* decrypt here because encrypted data coming from DB*/
-
- }
-
- private void validateUserUniqueness(User user) {
- if (userRepository.isUserPresent(user.getUsername(), getStateLevelTenantForCitizen(user.getTenantId(), user
- .getType()), user.getType()))
- throw new DuplicateUserNameException(UserSearchCriteria.builder().userName(user.getUsername()).type(user
- .getType()).tenantId(user.getTenantId()).build());
- }
-
- private String getStateLevelTenantForCitizen(String tenantId, UserType userType) {
- if (!isNull(userType) && userType.equals(UserType.CITIZEN) && !isEmpty(tenantId) && tenantId.contains("."))
- return tenantId.split("\\.")[0];
- else
- return tenantId;
- }
-
- /**
- * api will create the citizen with otp
- *
- * @param user
- * @return
- */
- public User createCitizen(User user, RequestInfo requestInfo) {
- validateAndEnrichCitizen(user);
- return createUser(user, requestInfo);
- }
-
-
- private void validateAndEnrichCitizen(User user) {
- log.info("Validating User........");
- if (isCitizenLoginOtpBased && !StringUtils.isNumeric(user.getUsername()))
- throw new UserNameNotValidException();
- else if (isCitizenLoginOtpBased)
- user.setMobileNumber(user.getUsername());
- if (!isCitizenLoginOtpBased)
- validatePassword(user.getPassword());
- user.setRoleToCitizen();
- user.setTenantId(getStateLevelTenantForCitizen(user.getTenantId(), user.getType()));
- }
-
- /**
- * api will create the citizen with otp
- *
- * @param user
- * @return
- */
- public Object registerWithLogin(User user, RequestInfo requestInfo) {
- user.setActive(true);
- createCitizen(user, requestInfo);
- return getAccess(user, user.getOtpReference());
- }
-
- private Object getAccess(User user, String password) {
- log.info("Fetch access token for register with login flow");
- try {
- HttpHeaders headers = new HttpHeaders();
- headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
- headers.set("Authorization", "Basic ZWdvdi11c2VyLWNsaWVudDo=");
- MultiValueMap map = new LinkedMultiValueMap<>();
- map.add("username", user.getUsername());
- if (!isEmpty(password))
- map.add("password", password);
- else
- map.add("password", user.getPassword());
- map.add("grant_type", "password");
- map.add("scope", "read");
- map.add("tenantId", user.getTenantId());
- map.add("isInternal", "true");
- map.add("userType", UserType.CITIZEN.name());
-
- HttpEntity> request = new HttpEntity>(map,
- headers);
- return restTemplate.postForEntity(userHost + "/user/oauth/token", request, Map.class).getBody();
-
- } catch (Exception e) {
- log.error("Error occurred while logging-in via register flow", e);
- throw new CustomException("LOGIN_ERROR", "Error occurred while logging in via register flow: " + e.getMessage());
- }
- }
-
- /**
- * dependent on otpValidationMandatory filed,it will validate the otp.
- *
- * @param user
- */
- private void conditionallyValidateOtp(User user) {
- if (user.isOtpValidationMandatory()) {
- if (!validateOtp(user))
- throw new OtpValidationPendingException();
- }
- }
-
- /**
- * This api will validate the otp
- *
- * @param user
- * @return
- */
- public Boolean validateOtp(User user) {
- Otp otp = Otp.builder().otp(user.getOtpReference()).identity(user.getMobileNumber()).tenantId(user.getTenantId())
- .userType(user.getType()).build();
- RequestInfo requestInfo = RequestInfo.builder().action("validate").ts(System.currentTimeMillis()).build();
- OtpValidateRequest otpValidationRequest = OtpValidateRequest.builder().requestInfo(requestInfo).otp(otp)
- .build();
- return otpRepository.validateOtp(otpValidationRequest);
-
- }
-
-
- /**
- * api will update user details without otp
- *
- * @param user
- * @return
- */
- // TODO Fix date formats
- public User updateWithoutOtpValidation(User user, RequestInfo requestInfo) {
- final User existingUser = getUserByUuid(user.getUuid());
- user.setTenantId(getStateLevelTenantForCitizen(user.getTenantId(), user.getType()));
- validateUserRoles(user);
- user.validateUserModification();
- validatePassword(user.getPassword());
- user.setPassword(encryptPwd(user.getPassword()));
- /* encrypt */
- user = encryptionDecryptionUtil.encryptObject(user, "User", User.class);
- userRepository.update(user, existingUser,requestInfo.getUserInfo().getId(), requestInfo.getUserInfo().getUuid() );
-
- // If user is being unlocked via update, reset failed login attempts
- if (user.getAccountLocked() != null && !user.getAccountLocked() && existingUser.getAccountLocked())
- resetFailedLoginAttempts(user);
-
- User encryptedUpdatedUserfromDB = getUserByUuid(user.getUuid());
- User decryptedupdatedUserfromDB = encryptionDecryptionUtil.decryptObject(encryptedUpdatedUserfromDB, "UserSelf", User.class, requestInfo);
- return decryptedupdatedUserfromDB;
- }
-
- public void removeTokensByUser(User user) {
- Collection tokens = tokenStore.findTokensByClientIdAndUserName(USER_CLIENT_ID,
- user.getUsername());
-
- for (OAuth2AccessToken token : tokens) {
- if (token.getAdditionalInformation() != null && token.getAdditionalInformation().containsKey("UserRequest")) {
- if (token.getAdditionalInformation().get("UserRequest") instanceof org.egov.user.web.contract.auth.User) {
- org.egov.user.web.contract.auth.User userInfo =
- (org.egov.user.web.contract.auth.User) token.getAdditionalInformation().get(
- "UserRequest");
- if (user.getUsername().equalsIgnoreCase(userInfo.getUserName()) && user.getTenantId().equalsIgnoreCase(userInfo.getTenantId())
- && user.getType().equals(UserType.fromValue(userInfo.getType())))
- tokenStore.removeAccessToken(token);
- }
- }
- }
-
- }
-
- /**
- * this api will validate whether user roles exist in Database or not
- *
- * @param user
- */
- private void validateUserRoles(User user) {
- if (user.getRoles() == null || user.getRoles() != null && user.getRoles().isEmpty()) {
- throw new AtleastOneRoleCodeException();
- }
- }
-
- /**
- * this api will update user profile data except these fields userName ,
- * mobileNumber type , password ,pwsExpiryData, roles
- *
- * @param user
- * @return
- */
- public User partialUpdate(User user, RequestInfo requestInfo) {
- /* encrypt here */
- user = encryptionDecryptionUtil.encryptObject(user, "User", User.class);
-
- User existingUser = getUserByUuid(user.getUuid());
- validateProfileUpdateIsDoneByTheSameLoggedInUser(user);
- user.nullifySensitiveFields();
- validatePassword(user.getPassword());
- userRepository.update(user, existingUser,requestInfo.getUserInfo().getId(), requestInfo.getUserInfo().getUuid() );
- User updatedUser = getUserByUuid(user.getUuid());
-
- /* decrypt here */
- existingUser = encryptionDecryptionUtil.decryptObject(existingUser, "UserSelf", User.class, requestInfo);
- updatedUser = encryptionDecryptionUtil.decryptObject(updatedUser, "UserSelf", User.class, requestInfo);
-
- setFileStoreUrlsByFileStoreIds(Collections.singletonList(updatedUser));
- String oldEmail = existingUser.getEmailId();
- String newEmail = updatedUser.getEmailId();
- if((oldEmail != null && !oldEmail.isEmpty()) && newEmail != null && !(newEmail.equalsIgnoreCase(oldEmail))) {
- // Sending sms and email to old email to notify that email has been changed
- notificationUtil.sendEmail(requestInfo, existingUser, updatedUser);
- }
- return updatedUser;
- }
-
- /**
- * This api will update the password for logged-in user
- *
- * @param updatePasswordRequest
- */
- public void updatePasswordForLoggedInUser(LoggedInUserUpdatePasswordRequest updatePasswordRequest) {
- updatePasswordRequest.validate();
- final User user = getUniqueUser(updatePasswordRequest.getUserName(), updatePasswordRequest.getTenantId(),
- updatePasswordRequest.getType());
-
- if (user.getType().toString().equals(UserType.CITIZEN.toString()) && isCitizenLoginOtpBased)
- throw new InvalidUpdatePasswordRequestException();
- if (user.getType().toString().equals(UserType.EMPLOYEE.toString()) && isEmployeeLoginOtpBased)
- throw new InvalidUpdatePasswordRequestException();
-
- validateExistingPassword(user, updatePasswordRequest.getExistingPassword());
- validatePassword(updatePasswordRequest.getNewPassword());
- user.updatePassword(encryptPwd(updatePasswordRequest.getNewPassword()));
- userRepository.update(user, user, user.getId() , user.getUuid());
- }
-
- /**
- * This Api will update the password for non logged-in user
- *
- * @param request
- */
- public void updatePasswordForNonLoggedInUser(NonLoggedInUserUpdatePasswordRequest request, RequestInfo requestInfo) {
- request.validate();
- // validateOtp(request.getOtpValidationRequest());
- User user = getUniqueUser(request.getUserName(), request.getTenantId(), request.getType());
- if (user.getType().toString().equals(UserType.CITIZEN.toString()) && isCitizenLoginOtpBased) {
- log.info("CITIZEN forgot password flow is disabled");
- throw new InvalidUpdatePasswordRequestException();
- }
- if (user.getType().toString().equals(UserType.EMPLOYEE.toString()) && isEmployeeLoginOtpBased) {
- log.info("EMPLOYEE forgot password flow is disabled");
- throw new InvalidUpdatePasswordRequestException();
- }
- /* decrypt here */
- /* the reason for decryption here is the otp service requires decrypted username */
- user = encryptionDecryptionUtil.decryptObject(user, "User", User.class, requestInfo);
- user.setOtpReference(request.getOtpReference());
- validateOtp(user);
- validatePassword(request.getNewPassword());
- user.updatePassword(encryptPwd(request.getNewPassword()));
- /* encrypt here */
- /* encrypted value is stored in DB*/
- user = encryptionDecryptionUtil.encryptObject(user, "User", User.class);
- userRepository.update(user, user,user.getId()!=null?user.getId():0 , user.getUuid()!=null?user.getUuid():"NA");
- }
-
-
- /**
- * Deactivate failed login attempts for provided user
- *
- * @param user whose failed login attempts are to be reset
- */
- public void resetFailedLoginAttempts(User user) {
- if (user.getUuid() != null)
- userRepository.resetFailedLoginAttemptsForUser(user.getUuid());
- }
-
- /**
- * Checks if user is eligible for unlock
- * returns true,
- * - If configured cool down period has passed since last lock
- * else false
- *
- * @param user to be checked for eligibility for unlock
- * @return if unlock able
- */
- public boolean isAccountUnlockAble(User user) {
- if (user.getAccountLocked()) {
- boolean unlockAble =
- System.currentTimeMillis() - user.getAccountLockedDate() > TimeUnit.MINUTES.toMillis(accountUnlockCoolDownPeriod);
-
- log.info("Account eligible for unlock - " + unlockAble);
- log.info("Current time {}, last lock time {} , cool down period {} ", System.currentTimeMillis(),
- user.getAccountLockedDate(), TimeUnit.MINUTES.toMillis(accountUnlockCoolDownPeriod));
- return unlockAble;
- } else
- return true;
- }
-
- /**
- * Perform actions where a user login fails
- * - Fetch existing failed login attempts within configured time
- * period{@link UserService#maxInvalidLoginAttemptsPeriod}
- * - If failed login attempts exceeds configured {@link UserService#maxInvalidLoginAttempts}
- * - then lock account
- * - Add failed login attempt entry to repository
- *
- * @param user user whose failed login attempt to be handled
- * @param ipAddress IP address of remote
- */
- public void handleFailedLogin(User user, String ipAddress, RequestInfo requestInfo) {
- if (!Objects.isNull(user.getUuid())) {
- List failedLoginAttempts =
- userRepository.fetchFailedAttemptsByUserAndTime(user.getUuid(),
- System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(maxInvalidLoginAttemptsPeriod));
-
- if (failedLoginAttempts.size() + 1 >= maxInvalidLoginAttempts) {
- User userToBeUpdated = user.toBuilder()
- .accountLocked(true)
- .password(null)
- .accountLockedDate(System.currentTimeMillis())
- .build();
-
- user = updateWithoutOtpValidation(userToBeUpdated, requestInfo);
- removeTokensByUser(user);
- log.info("Locked account with uuid {} for {} minutes as exceeded max allowed attempts of {} within {} " +
- "minutes",
- user.getUuid(), accountUnlockCoolDownPeriod, maxInvalidLoginAttempts, maxInvalidLoginAttemptsPeriod);
- throw new OAuth2Exception("Account locked");
- }
-
- userRepository.insertFailedLoginAttempt(new FailedLoginAttempt(user.getUuid(), ipAddress,
- System.currentTimeMillis(), true));
- }
- }
-
-
- /**
- * This api will validate existing password and current password matching or
- * not
- *
- * @param user
- * @param existingRawPassword
- */
- private void validateExistingPassword(User user, String existingRawPassword) {
- if (!passwordEncoder.matches(existingRawPassword, user.getPassword())) {
- throw new PasswordMismatchException("Invalid username or password");
- }
- }
-
-// /**
-// * this api will check user is exist or not, If not exist it will throw
-// * exception.
-// *
-// * @param user
-// */
-// private void validateUserPresent(User user) {
-// if (user == null) {
-// throw new UserNotFoundException(null);
-// }
-// }
-
- /**
- * this api will validate, updating the profile for same logged-in user or
- * not
- *
- * @param user
- */
- private void validateProfileUpdateIsDoneByTheSameLoggedInUser(User user) {
- if (user.isLoggedInUserDifferentFromUpdatedUser()) {
- throw new UserProfileUpdateDeniedException();
- }
- }
-
-
- String encryptPwd(String pwd) {
- if (!isNull(pwd))
- return passwordEncoder.encode(pwd);
- else
- return null;
- }
-
- /**
- * This api will persist the user
- *
- * @param user
- * @return
- */
- private User persistNewUser(User user) {
-
- return userRepository.create(user);
- }
-
- /**
- * This api will fetch the fileStoreUrl By fileStoreId
- *
- * @param userList
- * @throws Exception
- */
- private void setFileStoreUrlsByFileStoreIds(List userList) {
- List fileStoreIds = userList.parallelStream().filter(p -> p.getPhoto() != null).map(User::getPhoto)
- .collect(Collectors.toList());
- if (!isEmpty(fileStoreIds)) {
- Map fileStoreUrlList = null;
- try {
- fileStoreUrlList = fileRepository.getUrlByFileStoreId(userList.get(0).getTenantId(), fileStoreIds);
- } catch (Exception e) {
- // TODO Auto-generated catch block
-
- log.error("Error while fetching fileStore url list: " + e.getMessage());
- }
-
- if (fileStoreUrlList != null && !fileStoreUrlList.isEmpty()) {
- for (User user : userList) {
- user.setPhoto(fileStoreUrlList.get(user.getPhoto()));
- }
- }
- }
- }
-
-
- public void validatePassword(String password) {
- Map errorMap = new HashMap<>();
- if (!StringUtils.isEmpty(password)) {
- if (password.length() < pwdMinLength || password.length() > pwdMaxLength)
- errorMap.put("INVALID_PWD_LENGTH", "Password must be of minimum: " + pwdMinLength + " and maximum: " + pwdMaxLength + " characters.");
- Pattern p = Pattern.compile(pwdRegex);
- Matcher m = p.matcher(password);
- if (!m.find()) {
- errorMap.put("INVALID_PWD_PATTERN", "Password MUST HAVE: Atleast one digit, one upper case, one lower case, one special character (@#$%) and MUST NOT contain any spaces");
- }
- }
- if (!CollectionUtils.isEmpty(errorMap.keySet())) {
- throw new CustomException(errorMap);
- }
- }
-
-
-}
+package org.egov.user.domain.service;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
+import com.fasterxml.jackson.databind.ObjectWriter;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.egov.common.contract.request.RequestInfo;
+import org.egov.tracer.model.CustomException;
+import org.egov.user.domain.exception.*;
+import org.egov.user.domain.model.LoggedInUserUpdatePasswordRequest;
+import org.egov.user.domain.model.NonLoggedInUserUpdatePasswordRequest;
+import org.egov.user.domain.model.User;
+import org.egov.user.domain.model.UserSearchCriteria;
+import org.egov.user.domain.model.enums.UserType;
+import org.egov.user.domain.service.utils.EncryptionDecryptionUtil;
+import org.egov.user.domain.service.utils.NotificationUtil;
+import org.egov.user.persistence.dto.FailedLoginAttempt;
+import org.egov.user.persistence.repository.FileStoreRepository;
+import org.egov.user.persistence.repository.OtpRepository;
+import org.egov.user.persistence.repository.UserRepository;
+import org.egov.user.web.contract.Otp;
+import org.egov.user.web.contract.OtpValidateRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.oauth2.common.OAuth2AccessToken;
+import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
+import org.springframework.security.oauth2.provider.token.TokenStore;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestTemplate;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import static java.util.Objects.isNull;
+import static org.apache.commons.lang3.StringUtils.isEmpty;
+import static org.egov.user.config.UserServiceConstants.USER_CLIENT_ID;
+import static org.springframework.util.CollectionUtils.isEmpty;
+
+@Service
+@Slf4j
+public class UserService {
+
+ private UserRepository userRepository;
+ private OtpRepository otpRepository;
+ private PasswordEncoder passwordEncoder;
+ private int defaultPasswordExpiryInDays;
+ private boolean isCitizenLoginOtpBased;
+ private boolean isEmployeeLoginOtpBased;
+ private FileStoreRepository fileRepository;
+ private EncryptionDecryptionUtil encryptionDecryptionUtil;
+ private TokenStore tokenStore;
+
+ @Value("${egov.user.host}")
+ private String userHost;
+
+ @Value("${account.unlock.cool.down.period.minutes}")
+ private Long accountUnlockCoolDownPeriod;
+
+ @Value("${max.invalid.login.attempts.period.minutes}")
+ private Long maxInvalidLoginAttemptsPeriod;
+
+ @Value("${create.user.validate.name}")
+ private boolean createUserValidateName;
+
+ @Value("${max.invalid.login.attempts}")
+ private Long maxInvalidLoginAttempts;
+
+
+ @Value("${egov.user.pwd.pattern}")
+ private String pwdRegex;
+
+ @Value("${egov.user.pwd.pattern.min.length}")
+ private Integer pwdMinLength;
+
+ @Value("${egov.user.pwd.pattern.max.length}")
+ private Integer pwdMaxLength;
+
+ @Autowired
+ private RestTemplate restTemplate;
+
+ @Autowired
+ private NotificationUtil notificationUtil;
+
+ public UserService(UserRepository userRepository, OtpRepository otpRepository, FileStoreRepository fileRepository,
+ PasswordEncoder passwordEncoder, EncryptionDecryptionUtil encryptionDecryptionUtil, TokenStore tokenStore,
+ @Value("${default.password.expiry.in.days}") int defaultPasswordExpiryInDays,
+ @Value("${citizen.login.password.otp.enabled}") boolean isCitizenLoginOtpBased,
+ @Value("${employee.login.password.otp.enabled}") boolean isEmployeeLoginOtpBased,
+ @Value("${egov.user.pwd.pattern}") String pwdRegex,
+ @Value("${egov.user.pwd.pattern.max.length}") Integer pwdMaxLength,
+ @Value("${egov.user.pwd.pattern.min.length}") Integer pwdMinLength) {
+ this.userRepository = userRepository;
+ this.otpRepository = otpRepository;
+ this.passwordEncoder = passwordEncoder;
+ this.defaultPasswordExpiryInDays = defaultPasswordExpiryInDays;
+ this.isCitizenLoginOtpBased = isCitizenLoginOtpBased;
+ this.isEmployeeLoginOtpBased = isEmployeeLoginOtpBased;
+ this.fileRepository = fileRepository;
+ this.encryptionDecryptionUtil = encryptionDecryptionUtil;
+ this.tokenStore = tokenStore;
+ this.pwdRegex = pwdRegex;
+ this.pwdMaxLength = pwdMaxLength;
+ this.pwdMinLength = pwdMinLength;
+
+ }
+
+ /**
+ * get user By UserName And TenantId
+ *
+ * @param userName
+ * @param tenantId
+ * @return
+ */
+ public User getUniqueUser(String userName, String tenantId, UserType userType) {
+
+ UserSearchCriteria userSearchCriteria = UserSearchCriteria.builder()
+ .userName(userName)
+ .tenantId(getStateLevelTenantForCitizen(tenantId, userType))
+ .type(userType)
+ .build();
+
+ if (isEmpty(userName) || isEmpty(tenantId) || isNull(userType)) {
+ log.error("Invalid lookup, mandatory fields are absent");
+ throw new UserNotFoundException(userSearchCriteria);
+ }
+
+ /* encrypt here */
+
+ userSearchCriteria = encryptionDecryptionUtil.encryptObject(userSearchCriteria, "UserSearchCriteria", UserSearchCriteria.class);
+ List users = userRepository.findAll(userSearchCriteria);
+
+ if (users.isEmpty())
+ throw new UserNotFoundException(userSearchCriteria);
+ if (users.size() > 1)
+ throw new DuplicateUserNameException(userSearchCriteria);
+
+ return users.get(0);
+ }
+
+ public User getUserByUuid(String uuid) {
+
+ UserSearchCriteria userSearchCriteria = UserSearchCriteria.builder()
+ .uuid(Collections.singletonList(uuid))
+ .build();
+
+ if (isEmpty(uuid)) {
+ log.error("UUID is mandatory");
+ throw new UserNotFoundException(userSearchCriteria);
+ }
+
+ List users = userRepository.findAll(userSearchCriteria);
+
+ if (users.isEmpty())
+ throw new UserNotFoundException(userSearchCriteria);
+ return users.get(0);
+ }
+
+
+ /**
+ * get the users based on on userSearch criteria
+ *
+ * @param searchCriteria
+ * @return
+ */
+
+ public List searchUsers(UserSearchCriteria searchCriteria,
+ boolean isInterServiceCall, RequestInfo requestInfo) {
+
+ searchCriteria.validate(isInterServiceCall);
+
+ searchCriteria.setTenantId(getStateLevelTenantForCitizen(searchCriteria.getTenantId(), searchCriteria.getType()));
+ /* encrypt here / encrypted searchcriteria will be used for search*/
+
+ String altmobnumber=null;
+
+ if(searchCriteria.getMobileNumber()!=null) {
+ altmobnumber = searchCriteria.getMobileNumber();
+ }
+ // org.egov.user.domain.model.User user= encryptionDecryptionUtil.encryptObject(searchCriteria, "User", User.class);
+ searchCriteria = encryptionDecryptionUtil.encryptObject(searchCriteria, "UserSearchCriteria", UserSearchCriteria.class);
+
+ if(altmobnumber!=null) {
+ searchCriteria.setAlternatemobilenumber(altmobnumber);
+ }
+
+ List list = userRepository.findAll(searchCriteria);
+
+ /* decrypt here / final reponse decrypted*/
+
+ list = encryptionDecryptionUtil.decryptObject(list, "UserListSelf", User.class, requestInfo);
+
+ setFileStoreUrlsByFileStoreIds(list);
+ return list;
+ }
+
+ /**
+ * api will create the user based on some validations
+ *
+ * @param user
+ * @return
+ */
+ public User createUser(User user, RequestInfo requestInfo) {
+ user.setUuid(UUID.randomUUID().toString());
+ user.validateNewUser(createUserValidateName);
+ conditionallyValidateOtp(user);
+ /* encrypt here */
+ user = encryptionDecryptionUtil.encryptObject(user, "UserSelf", User.class);
+ validateUserUniqueness(user);
+ if (isEmpty(user.getPassword())) {
+ user.setPassword(UUID.randomUUID().toString());
+ } else {
+ validatePassword(user.getPassword());
+ }
+ user.setPassword(encryptPwd(user.getPassword()));
+ user.setDefaultPasswordExpiry(defaultPasswordExpiryInDays);
+ user.setTenantId(getStateLevelTenantForCitizen(user.getTenantId(), user.getType()));
+ User persistedNewUser = persistNewUser(user);
+ return encryptionDecryptionUtil.decryptObject(persistedNewUser, null, User.class, requestInfo);
+
+ /* decrypt here because encrypted data coming from DB*/
+
+ }
+
+ private void validateUserUniqueness(User user) {
+ if (userRepository.isUserPresent(user.getUserName(), getStateLevelTenantForCitizen(user.getTenantId(), user
+ .getType()), user.getType()))
+ throw new DuplicateUserNameException(UserSearchCriteria.builder().userName(user.getUserName()).type(user
+ .getType()).tenantId(user.getTenantId()).build());
+ }
+
+ private String getStateLevelTenantForCitizen(String tenantId, UserType userType) {
+ if (!isNull(userType) && userType.equals(UserType.CITIZEN) && !isEmpty(tenantId) && tenantId.contains("."))
+ return tenantId.split("\\.")[0];
+ else
+ return tenantId;
+ }
+
+ /**
+ * api will create the citizen with otp
+ *
+ * @param user
+ * @return
+ */
+ public User createCitizen(User user, RequestInfo requestInfo) {
+ validateAndEnrichCitizen(user);
+ return createUser(user, requestInfo);
+ }
+
+
+ private void validateAndEnrichCitizen(User user) {
+ log.info("Validating User........");
+ if (isCitizenLoginOtpBased && !StringUtils.isNumeric(user.getUserName()))
+ throw new UserNameNotValidException();
+ else if (isCitizenLoginOtpBased)
+ user.setMobileNumber(user.getUserName());
+ if (!isCitizenLoginOtpBased)
+ validatePassword(user.getPassword());
+ user.setRoleToCitizen();
+ user.setTenantId(getStateLevelTenantForCitizen(user.getTenantId(), user.getType()));
+ }
+
+ /**
+ * api will create the citizen with otp
+ *
+ * @param user
+ * @return
+ */
+ public Object registerWithLogin(User user, RequestInfo requestInfo) {
+ user.setActive(true);
+ createCitizen(user, requestInfo);
+ return getAccess(user, user.getOtpReference());
+ }
+
+ private Object getAccess(User user, String password) {
+ log.info("Fetch access token for register with login flow");
+ try {
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+ headers.set("Authorization", "Basic ZWdvdi11c2VyLWNsaWVudDplZ292LXVzZXItc2VjcmV0");
+ MultiValueMap map = new LinkedMultiValueMap<>();
+ map.add("username", user.getUserName());
+ if (!isEmpty(password))
+ map.add("password", password);
+ else
+ map.add("password", user.getPassword());
+ map.add("grant_type", "password");
+ map.add("scope", "read");
+ map.add("tenantId", user.getTenantId());
+ map.add("isInternal", "true");
+ map.add("userType", UserType.CITIZEN.name());
+
+ HttpEntity> request = new HttpEntity>(map,
+ headers);
+ return restTemplate.postForEntity(userHost + "/user/oauth/token", request, Map.class).getBody();
+
+ } catch (Exception e) {
+ log.error("Error occurred while logging-in via register flow", e);
+ throw new CustomException("LOGIN_ERROR", "Error occurred while logging in via register flow: " + e.getMessage());
+ }
+ }
+
+ /**
+ * dependent on otpValidationMandatory filed,it will validate the otp.
+ *
+ * @param user
+ */
+ private void conditionallyValidateOtp(User user) {
+ if (user.isOtpValidationMandatory()) {
+ if (!validateOtp(user))
+ throw new OtpValidationPendingException();
+ }
+ }
+
+ /**
+ * This api will validate the otp
+ *
+ * @param user
+ * @return
+ */
+ public Boolean validateOtp(User user) {
+ Otp otp = Otp.builder().otp(user.getOtpReference()).identity(user.getMobileNumber()).tenantId(user.getTenantId())
+ .userType(user.getType()).build();
+ RequestInfo requestInfo = RequestInfo.builder().action("validate").ts(System.currentTimeMillis()).build();
+ OtpValidateRequest otpValidationRequest = OtpValidateRequest.builder().requestInfo(requestInfo).otp(otp)
+ .build();
+ return otpRepository.validateOtp(otpValidationRequest);
+
+ }
+
+
+ /**
+ * api will update user details without otp
+ *
+ * @param user
+ * @return
+ */
+ // TODO Fix date formats
+ public User updateWithoutOtpValidation(User user, RequestInfo requestInfo) {
+ final User existingUser = getUserByUuid(user.getUuid());
+ user.setTenantId(getStateLevelTenantForCitizen(user.getTenantId(), user.getType()));
+ validateUserRoles(user);
+ user.validateUserModification();
+ validatePassword(user.getPassword());
+ user.setPassword(encryptPwd(user.getPassword()));
+ /* encrypt */
+ user = encryptionDecryptionUtil.encryptObject(user, "User", User.class);
+ userRepository.update(user, existingUser,requestInfo.getUserInfo().getId(), requestInfo.getUserInfo().getUuid() );
+
+ // If user is being unlocked via update, reset failed login attempts
+ if (user.getAccountLocked() != null && !user.getAccountLocked() && existingUser.getAccountLocked())
+ resetFailedLoginAttempts(user);
+
+ User encryptedUpdatedUserfromDB = getUserByUuid(user.getUuid());
+ User decryptedupdatedUserfromDB = encryptionDecryptionUtil.decryptObject(encryptedUpdatedUserfromDB, "User", User.class, requestInfo);
+ return decryptedupdatedUserfromDB;
+ }
+
+ public void removeTokensByUser(User user) {
+ Collection tokens = tokenStore.findTokensByClientIdAndUserName(USER_CLIENT_ID,
+ user.getUserName());
+
+ for (OAuth2AccessToken token : tokens) {
+ if (token.getAdditionalInformation() != null && token.getAdditionalInformation().containsKey("UserRequest")) {
+ if (token.getAdditionalInformation().get("UserRequest") instanceof org.egov.user.web.contract.auth.User) {
+ org.egov.user.web.contract.auth.User userInfo =
+ (org.egov.user.web.contract.auth.User) token.getAdditionalInformation().get(
+ "UserRequest");
+ if (user.getUserName().equalsIgnoreCase(userInfo.getUserName()) && user.getTenantId().equalsIgnoreCase(userInfo.getTenantId())
+ && user.getType().equals(UserType.fromValue(userInfo.getType())))
+ tokenStore.removeAccessToken(token);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * this api will validate whether user roles exist in Database or not
+ *
+ * @param user
+ */
+ private void validateUserRoles(User user) {
+ if (user.getRoles() == null || user.getRoles() != null && user.getRoles().isEmpty()) {
+ throw new AtleastOneRoleCodeException();
+ }
+ }
+
+ /**
+ * this api will update user profile data except these fields userName ,
+ * mobileNumber type , password ,pwsExpiryData, roles
+ *
+ * @param user
+ * @return
+ */
+ public User partialUpdate(User user, RequestInfo requestInfo) {
+ /* encrypt here */
+ user = encryptionDecryptionUtil.encryptObject(user, "User", User.class);
+
+ User existingUser = getUserByUuid(user.getUuid());
+ validateProfileUpdateIsDoneByTheSameLoggedInUser(user);
+ user.nullifySensitiveFields();
+ validatePassword(user.getPassword());
+ userRepository.update(user, existingUser,requestInfo.getUserInfo().getId(), requestInfo.getUserInfo().getUuid() );
+ User updatedUser = getUserByUuid(user.getUuid());
+
+ updatedUser = encryptionDecryptionUtil.decryptObject(updatedUser, "User", User.class, requestInfo);
+
+ setFileStoreUrlsByFileStoreIds(Collections.singletonList(updatedUser));
+ String oldEmail = existingUser.getEmailId();
+ String newEmail = updatedUser.getEmailId();
+ if((oldEmail != null && !oldEmail.isEmpty()) && newEmail != null && !(newEmail.equalsIgnoreCase(oldEmail))) {
+ // Sending sms and email to old email to notify that email has been changed
+ notificationUtil.sendEmail(requestInfo, existingUser, updatedUser);
+ }
+ return updatedUser;
+ }
+
+ /**
+ * This api will update the password for logged-in user
+ *
+ * @param updatePasswordRequest
+ */
+ public void updatePasswordForLoggedInUser(LoggedInUserUpdatePasswordRequest updatePasswordRequest) {
+ updatePasswordRequest.validate();
+ final User user = getUniqueUser(updatePasswordRequest.getUserName(), updatePasswordRequest.getTenantId(),
+ updatePasswordRequest.getType());
+
+ if (user.getType().toString().equals(UserType.CITIZEN.toString()) && isCitizenLoginOtpBased)
+ throw new InvalidUpdatePasswordRequestException();
+ if (user.getType().toString().equals(UserType.EMPLOYEE.toString()) && isEmployeeLoginOtpBased)
+ throw new InvalidUpdatePasswordRequestException();
+
+ validateExistingPassword(user, updatePasswordRequest.getExistingPassword());
+ validatePassword(updatePasswordRequest.getNewPassword());
+ user.updatePassword(encryptPwd(updatePasswordRequest.getNewPassword()));
+ userRepository.update(user, user, user.getId() , user.getUuid());
+ }
+
+ /**
+ * This Api will update the password for non logged-in user
+ *
+ * @param request
+ */
+ public void updatePasswordForNonLoggedInUser(NonLoggedInUserUpdatePasswordRequest request, RequestInfo requestInfo) {
+ request.validate();
+ // validateOtp(request.getOtpValidationRequest());
+ User user = getUniqueUser(request.getUserName(), request.getTenantId(), request.getType());
+ if (user.getType().toString().equals(UserType.CITIZEN.toString()) && isCitizenLoginOtpBased) {
+ log.info("CITIZEN forgot password flow is disabled");
+ throw new InvalidUpdatePasswordRequestException();
+ }
+ if (user.getType().toString().equals(UserType.EMPLOYEE.toString()) && isEmployeeLoginOtpBased) {
+ log.info("EMPLOYEE forgot password flow is disabled");
+ throw new InvalidUpdatePasswordRequestException();
+ }
+ /* decrypt here */
+ /* the reason for decryption here is the otp service requires decrypted username */
+ user = encryptionDecryptionUtil.decryptObject(user, "UserListSelf", User.class, requestInfo);
+ user.setOtpReference(request.getOtpReference());
+ validateOtp(user);
+ validatePassword(request.getNewPassword());
+ user.updatePassword(encryptPwd(request.getNewPassword()));
+ /* encrypt here */
+ /* encrypted value is stored in DB*/
+ user = encryptionDecryptionUtil.encryptObject(user, "User", User.class);
+ userRepository.update(user, user,user.getId()!=null?user.getId():0 , user.getUuid()!=null?user.getUuid():"NA");
+ }
+
+
+ /**
+ * Deactivate failed login attempts for provided user
+ *
+ * @param user whose failed login attempts are to be reset
+ */
+ public void resetFailedLoginAttempts(User user) {
+ if (user.getUuid() != null)
+ userRepository.resetFailedLoginAttemptsForUser(user.getUuid());
+ }
+
+ /**
+ * Checks if user is eligible for unlock
+ * returns true,
+ * - If configured cool down period has passed since last lock
+ * else false
+ *
+ * @param user to be checked for eligibility for unlock
+ * @return if unlock able
+ */
+ public boolean isAccountUnlockAble(User user) {
+ if (user.getAccountLocked()) {
+ boolean unlockAble =
+ System.currentTimeMillis() - user.getAccountLockedDate() > TimeUnit.MINUTES.toMillis(accountUnlockCoolDownPeriod);
+
+ log.info("Account eligible for unlock - " + unlockAble);
+ log.info("Current time {}, last lock time {} , cool down period {} ", System.currentTimeMillis(),
+ user.getAccountLockedDate(), TimeUnit.MINUTES.toMillis(accountUnlockCoolDownPeriod));
+ return unlockAble;
+ } else
+ return true;
+ }
+
+ /**
+ * Perform actions where a user login fails
+ * - Fetch existing failed login attempts within configured time
+ * period{@link UserService#maxInvalidLoginAttemptsPeriod}
+ * - If failed login attempts exceeds configured {@link UserService#maxInvalidLoginAttempts}
+ * - then lock account
+ * - Add failed login attempt entry to repository
+ *
+ * @param user user whose failed login attempt to be handled
+ * @param ipAddress IP address of remote
+ */
+ public void handleFailedLogin(User user, String ipAddress, RequestInfo requestInfo) {
+ if (!Objects.isNull(user.getUuid())) {
+ List failedLoginAttempts =
+ userRepository.fetchFailedAttemptsByUserAndTime(user.getUuid(),
+ System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(maxInvalidLoginAttemptsPeriod));
+
+ if (failedLoginAttempts.size() + 1 >= maxInvalidLoginAttempts) {
+ User userToBeUpdated = user.toBuilder()
+ .accountLocked(true)
+ .password(null)
+ .accountLockedDate(System.currentTimeMillis())
+ .build();
+
+ user = updateWithoutOtpValidation(userToBeUpdated, requestInfo);
+ removeTokensByUser(user);
+ log.info("Locked account with uuid {} for {} minutes as exceeded max allowed attempts of {} within {} " +
+ "minutes",
+ user.getUuid(), accountUnlockCoolDownPeriod, maxInvalidLoginAttempts, maxInvalidLoginAttemptsPeriod);
+ throw new OAuth2Exception("Account locked");
+ }
+
+ userRepository.insertFailedLoginAttempt(new FailedLoginAttempt(user.getUuid(), ipAddress,
+ System.currentTimeMillis(), true));
+ }
+ }
+
+
+ /**
+ * This api will validate existing password and current password matching or
+ * not
+ *
+ * @param user
+ * @param existingRawPassword
+ */
+ private void validateExistingPassword(User user, String existingRawPassword) {
+ if (!passwordEncoder.matches(existingRawPassword, user.getPassword())) {
+ throw new PasswordMismatchException("Invalid username or password");
+ }
+ }
+
+// /**
+// * this api will check user is exist or not, If not exist it will throw
+// * exception.
+// *
+// * @param user
+// */
+// private void validateUserPresent(User user) {
+// if (user == null) {
+// throw new UserNotFoundException(null);
+// }
+// }
+
+ /**
+ * this api will validate, updating the profile for same logged-in user or
+ * not
+ *
+ * @param user
+ */
+ private void validateProfileUpdateIsDoneByTheSameLoggedInUser(User user) {
+ if (user.isLoggedInUserDifferentFromUpdatedUser()) {
+ throw new UserProfileUpdateDeniedException();
+ }
+ }
+
+
+ String encryptPwd(String pwd) {
+ if (!isNull(pwd))
+ return passwordEncoder.encode(pwd);
+ else
+ return null;
+ }
+
+ /**
+ * This api will persist the user
+ *
+ * @param user
+ * @return
+ */
+ private User persistNewUser(User user) {
+
+ return userRepository.create(user);
+ }
+
+ /**
+ * This api will fetch the fileStoreUrl By fileStoreId
+ *
+ * @param userList
+ * @throws Exception
+ */
+ private void setFileStoreUrlsByFileStoreIds(List userList) {
+ List fileStoreIds = userList.parallelStream().filter(p -> p.getPhoto() != null).map(User::getPhoto)
+ .collect(Collectors.toList());
+ if (!isEmpty(fileStoreIds)) {
+ Map fileStoreUrlList = null;
+ try {
+ fileStoreUrlList = fileRepository.getUrlByFileStoreId(userList.get(0).getTenantId(), fileStoreIds);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+
+ log.error("Error while fetching fileStore url list: " + e.getMessage());
+ }
+
+ if (fileStoreUrlList != null && !fileStoreUrlList.isEmpty()) {
+ for (User user : userList) {
+ user.setPhoto(fileStoreUrlList.get(user.getPhoto()));
+ }
+ }
+ }
+ }
+
+
+ public void validatePassword(String password) {
+ Map errorMap = new HashMap<>();
+ if (!StringUtils.isEmpty(password)) {
+ if (password.length() < pwdMinLength || password.length() > pwdMaxLength)
+ errorMap.put("INVALID_PWD_LENGTH", "Password must be of minimum: " + pwdMinLength + " and maximum: " + pwdMaxLength + " characters.");
+ Pattern p = Pattern.compile(pwdRegex);
+ Matcher m = p.matcher(password);
+ if (!m.find()) {
+ errorMap.put("INVALID_PWD_PATTERN", "Password MUST HAVE: Atleast one digit, one upper case, one lower case, one special character (@#$%) and MUST NOT contain any spaces");
+ }
+ }
+ if (!CollectionUtils.isEmpty(errorMap.keySet())) {
+ throw new CustomException(errorMap);
+ }
+ }
+
+
+}
diff --git a/core-services/egov-user/src/main/java/org/egov/user/domain/service/utils/EncryptionDecryptionUtil.java b/core-services/egov-user/src/main/java/org/egov/user/domain/service/utils/EncryptionDecryptionUtil.java
index f12c38f0209..5c2ea798fb6 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/domain/service/utils/EncryptionDecryptionUtil.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/domain/service/utils/EncryptionDecryptionUtil.java
@@ -25,6 +25,8 @@
@Slf4j
@Component
public class EncryptionDecryptionUtil {
+
+
private EncryptionService encryptionService;
@Autowired
private AuditService auditService;
@@ -63,7 +65,7 @@ public T encryptObject(Object objectToEncrypt, String key, Class classTyp
public P decryptObject(Object objectToDecrypt, String key, Class classType, RequestInfo requestInfo) {
- try {
+ try {
boolean objectToDecryptNotList = false;
if (objectToDecrypt == null) {
return null;
@@ -83,7 +85,7 @@ public P decryptObject(Object objectToDecrypt, String key, Class class
if(key == null)
key = keyPurposeMap.get("key");
-
+
P decryptedObject = (P) encryptionService.decryptJson(requestInfo,objectToDecrypt, key, purpose, classType);
if (decryptedObject == null) {
throw new CustomException("DECRYPTION_NULL_ERROR", "Null object found on performing decryption");
@@ -131,24 +133,24 @@ public Map getKeyToDecrypt(Object objectToDecrypt, User userInfo)
Map keyPurposeMap = new HashMap<>();
if (!abacEnabled){
- keyPurposeMap.put("key","UserSelf");
+ keyPurposeMap.put("key","UserListSelf");
keyPurposeMap.put("purpose","AbacDisabled");
}
else if (isUserDecryptingForSelf(objectToDecrypt, userInfo)){
- keyPurposeMap.put("key","UserSelf");
+ keyPurposeMap.put("key","UserListSelf");
keyPurposeMap.put("purpose","Self");
}
else if (isDecryptionForIndividualUser(objectToDecrypt)){
- keyPurposeMap.put("key","User");
+ keyPurposeMap.put("key","UserListSelf");
keyPurposeMap.put("purpose","SingleSearchResult");
}
else{
- keyPurposeMap.put("key","User");
+ keyPurposeMap.put("key","UserListSelf");
keyPurposeMap.put("purpose","BulkSearchResult");
}
diff --git a/core-services/egov-user/src/main/java/org/egov/user/domain/service/utils/LocalizationUtil.java b/core-services/egov-user/src/main/java/org/egov/user/domain/service/utils/LocalizationUtil.java
index c58d48ebbee..71cecfde458 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/domain/service/utils/LocalizationUtil.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/domain/service/utils/LocalizationUtil.java
@@ -12,7 +12,7 @@
import java.util.List;
import java.util.Map;
-import static org.reflections.Reflections.log;
+
@Component
@Slf4j
diff --git a/core-services/egov-user/src/main/java/org/egov/user/persistence/dto/Otp.java b/core-services/egov-user/src/main/java/org/egov/user/persistence/dto/Otp.java
index c2d373f573d..972c216eb8c 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/persistence/dto/Otp.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/persistence/dto/Otp.java
@@ -4,10 +4,12 @@
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
+import lombok.NoArgsConstructor;
@Getter
@Builder
@AllArgsConstructor
+@NoArgsConstructor
public class Otp {
@JsonProperty("isValidationSuccessful")
diff --git a/core-services/egov-user/src/main/java/org/egov/user/persistence/dto/OtpResponse.java b/core-services/egov-user/src/main/java/org/egov/user/persistence/dto/OtpResponse.java
index 1dce001335e..932ce248b99 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/persistence/dto/OtpResponse.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/persistence/dto/OtpResponse.java
@@ -2,10 +2,13 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
+import lombok.NoArgsConstructor;
+
import org.egov.common.contract.response.ResponseInfo;
@Getter
@AllArgsConstructor
+@NoArgsConstructor
public class OtpResponse {
private Otp otp;
private ResponseInfo responseInfo;
diff --git a/core-services/egov-user/src/main/java/org/egov/user/persistence/repository/AuditRepository.java b/core-services/egov-user/src/main/java/org/egov/user/persistence/repository/AuditRepository.java
index 9971c8fd199..318d7b19655 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/persistence/repository/AuditRepository.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/persistence/repository/AuditRepository.java
@@ -46,7 +46,7 @@ public void auditUser(User oldUser, long userId, String uuid) {
auditInputs.put("id", oldUser.getId());
auditInputs.put("uuid", oldUser.getUuid());
- auditInputs.put("username", oldUser.getUsername());
+ auditInputs.put("username", oldUser.getUserName());
auditInputs.put("type", oldUser.getType().toString());
auditInputs.put("tenantid", oldUser.getTenantId());
auditInputs.put("aadhaarnumber", oldUser.getAadhaarNumber());
diff --git a/core-services/egov-user/src/main/java/org/egov/user/persistence/repository/UserRepository.java b/core-services/egov-user/src/main/java/org/egov/user/persistence/repository/UserRepository.java
index bbacf63d212..eda165bbdea 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/persistence/repository/UserRepository.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/persistence/repository/UserRepository.java
@@ -17,6 +17,7 @@
import org.egov.user.repository.builder.UserTypeQueryBuilder;
import org.egov.user.repository.rowmapper.UserResultSetExtractor;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
@@ -179,7 +180,7 @@ public void update(final User user, User oldUser, long userId, String uuid) {
Map updateuserInputs = new HashMap<>();
- updateuserInputs.put("username", oldUser.getUsername());
+ updateuserInputs.put("username", oldUser.getUserName());
updateuserInputs.put("type", oldUser.getType().toString());
updateuserInputs.put("tenantid", oldUser.getTenantId());
updateuserInputs.put("AadhaarNumber", user.getAadhaarNumber());
@@ -199,18 +200,46 @@ public void update(final User user, User oldUser, long userId, String uuid) {
List bloodGroupEnumValues = Arrays.asList(BloodGroup.values());
if (user.getBloodGroup() != null) {
- if (bloodGroupEnumValues.contains(user.getBloodGroup()))
+ if (BloodGroup.A_NEGATIVE.toString().equals(user.getBloodGroup().toString())) {
updateuserInputs.put("BloodGroup", user.getBloodGroup().toString());
- else
+ } else if (BloodGroup.A_POSITIVE.toString().equals(user.getBloodGroup().toString())) {
+ updateuserInputs.put("BloodGroup", user.getBloodGroup().toString());
+ } else if (BloodGroup.AB_NEGATIVE.toString().equals(user.getBloodGroup().toString())) {
+ updateuserInputs.put("BloodGroup", user.getBloodGroup().toString());
+ } else if (BloodGroup.AB_POSITIVE.toString().equals(user.getBloodGroup().toString())) {
+ updateuserInputs.put("BloodGroup", user.getBloodGroup().toString());
+ } else if (BloodGroup.O_NEGATIVE.toString().equals(user.getBloodGroup().toString())) {
+ updateuserInputs.put("BloodGroup", user.getBloodGroup().toString());
+ } else if (BloodGroup.O_POSITIVE.toString().equals(user.getBloodGroup().toString())) {
+ updateuserInputs.put("BloodGroup", user.getBloodGroup().toString());
+ } else if (BloodGroup.B_POSITIVE.toString().equals(user.getBloodGroup().toString())) {
+ updateuserInputs.put("BloodGroup", user.getBloodGroup().toString());
+ } else if (BloodGroup.B_NEGATIVE.toString().equals(user.getBloodGroup().toString())) {
+ updateuserInputs.put("BloodGroup", user.getBloodGroup().toString());
+ } else {
updateuserInputs.put("BloodGroup", "");
}
- else if (oldUser != null && oldUser.getBloodGroup() != null) {
- if (bloodGroupEnumValues.contains(oldUser.getBloodGroup()))
+ } else if (oldUser != null && oldUser.getBloodGroup() != null) {
+ if (BloodGroup.A_NEGATIVE.toString().equals(oldUser.getBloodGroup().toString())) {
+ updateuserInputs.put("BloodGroup", oldUser.getBloodGroup().toString());
+ } else if (BloodGroup.A_POSITIVE.toString().equals(oldUser.getBloodGroup().toString())) {
+ updateuserInputs.put("BloodGroup", oldUser.getBloodGroup().toString());
+ } else if (BloodGroup.AB_NEGATIVE.toString().equals(oldUser.getBloodGroup().toString())) {
+ updateuserInputs.put("BloodGroup", oldUser.getBloodGroup().toString());
+ } else if (BloodGroup.AB_POSITIVE.toString().equals(oldUser.getBloodGroup().toString())) {
+ updateuserInputs.put("BloodGroup", oldUser.getBloodGroup().toString());
+ } else if (BloodGroup.O_NEGATIVE.toString().equals(oldUser.getBloodGroup().toString())) {
+ updateuserInputs.put("BloodGroup", oldUser.getBloodGroup().toString());
+ } else if (BloodGroup.O_POSITIVE.toString().equals(oldUser.getBloodGroup().toString())) {
+ updateuserInputs.put("BloodGroup", oldUser.getBloodGroup().toString());
+ } else if (BloodGroup.B_POSITIVE.toString().equals(oldUser.getBloodGroup().toString())) {
+ updateuserInputs.put("BloodGroup", oldUser.getBloodGroup().toString());
+ } else if (BloodGroup.B_NEGATIVE.toString().equals(oldUser.getBloodGroup().toString())) {
updateuserInputs.put("BloodGroup", oldUser.getBloodGroup().toString());
- else
+ } else {
updateuserInputs.put("BloodGroup", "");
}
- else {
+ } else {
updateuserInputs.put("BloodGroup", "");
}
@@ -240,9 +269,15 @@ else if (oldUser != null && oldUser.getBloodGroup() != null) {
List enumValues = Arrays.asList(GuardianRelation.values());
if (user.getGuardianRelation() != null) {
- if(enumValues.contains(user.getGuardianRelation()))
+ if (GuardianRelation.Father.toString().equals(user.getGuardianRelation().toString())) {
updateuserInputs.put("GuardianRelation", user.getGuardianRelation().toString());
- else {
+ } else if (GuardianRelation.Mother.toString().equals(user.getGuardianRelation().toString())) {
+ updateuserInputs.put("GuardianRelation", user.getGuardianRelation().toString());
+ } else if (GuardianRelation.Husband.toString().equals(user.getGuardianRelation().toString())) {
+ updateuserInputs.put("GuardianRelation", user.getGuardianRelation().toString());
+ } else if (GuardianRelation.Other.toString().equals(user.getGuardianRelation().toString())) {
+ updateuserInputs.put("GuardianRelation", user.getGuardianRelation().toString());
+ } else {
updateuserInputs.put("GuardianRelation", "");
}
@@ -279,9 +314,15 @@ else if (oldUser != null && oldUser.getBloodGroup() != null) {
List userTypeEnumValues = Arrays.asList(UserType.values());
if (user.getType() != null) {
- if (userTypeEnumValues.contains(user.getType()))
+ if (UserType.BUSINESS.toString().equals(user.getType().toString())) {
updateuserInputs.put("Type", user.getType().toString());
- else {
+ } else if (UserType.CITIZEN.toString().equals(user.getType().toString())) {
+ updateuserInputs.put("Type", user.getType().toString());
+ } else if (UserType.EMPLOYEE.toString().equals(user.getType().toString())) {
+ updateuserInputs.put("Type", user.getType().toString());
+ } else if (UserType.SYSTEM.toString().equals(user.getType().toString())) {
+ updateuserInputs.put("Type", user.getType().toString());
+ } else {
updateuserInputs.put("Type", "");
}
}
@@ -354,6 +395,7 @@ public void resetFailedLoginAttemptsForUser(String uuid) {
* @param tenantId tenant id of the roles
* @return enriched roles
*/
+ @Cacheable(value = "cRolesByCode", key = "roleCodes", sync = true)
private Set fetchRolesByCode(Set roleCodes, String tenantId) {
@@ -467,7 +509,7 @@ private User save(User entityUser) {
userInputs.put("salutation", entityUser.getSalutation());
userInputs.put("dob", entityUser.getDob());
userInputs.put("locale", entityUser.getLocale());
- userInputs.put("username", entityUser.getUsername());
+ userInputs.put("username", entityUser.getUserName());
userInputs.put("password", entityUser.getPassword());
userInputs.put("pwdexpirydate", entityUser.getPasswordExpiryDate());
userInputs.put("mobilenumber", entityUser.getMobileNumber());
@@ -576,8 +618,13 @@ private Address saveAddress(Address address, Long userId, String tenantId) {
*/
private void updateRoles(User user) {
Map roleInputs = new HashMap();
+ List roleCodes = user.getRoles().stream().map(Role::getCode).collect(Collectors.toList());
roleInputs.put("user_id", user.getId());
roleInputs.put("user_tenantid", user.getTenantId());
+
+ // Add roles filter as well, other wise during concurrent update call there is a
+ // null pointer exception due to delete of roles
+ roleInputs.put("roles", roleCodes);
namedParameterJdbcTemplate.update(RoleQueryBuilder.DELETE_USER_ROLES, roleInputs);
saveUserRoles(user);
}
diff --git a/core-services/egov-user/src/main/java/org/egov/user/repository/builder/RoleQueryBuilder.java b/core-services/egov-user/src/main/java/org/egov/user/repository/builder/RoleQueryBuilder.java
index aea67756734..15512e15d6e 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/repository/builder/RoleQueryBuilder.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/repository/builder/RoleQueryBuilder.java
@@ -9,9 +9,11 @@ public class RoleQueryBuilder {
public static final String GET_ROLES_BY_ROLEIDS = "select * from eg_role where id in (:id) and tenantid=:tenantId";
public static final String GET_ROLE_BYTENANT_ANDCODE = "select * from eg_role where code =:code and tenantid=:tenantId";
public static final String INSERT_USER_ROLES = "insert into eg_userrole_v1(role_code, role_tenantid, user_id, " +
- "user_tenantid, lastmodifieddate) values(:role_code,:role_tenantid,:user_id,:user_tenantid,:lastmodifieddate)";
+ "user_tenantid, lastmodifieddate) values(:role_code,:role_tenantid,:user_id,:user_tenantid,:lastmodifieddate) " +
+ "ON CONFLICT (role_code, role_tenantid, user_id, user_tenantid) DO NOTHING";
public static final String DELETE_USER_ROLES = "delete from eg_userrole_v1 where user_id=:user_id and " +
- "user_tenantid=:user_tenantid";
+ "user_tenantid=:user_tenantid and " +
+ "role_code not in (:roles)";
}
diff --git a/core-services/egov-user/src/main/java/org/egov/user/repository/rowmapper/UserResultSetExtractor.java b/core-services/egov-user/src/main/java/org/egov/user/repository/rowmapper/UserResultSetExtractor.java
index 8e888af0977..d52cf8b7e64 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/repository/rowmapper/UserResultSetExtractor.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/repository/rowmapper/UserResultSetExtractor.java
@@ -42,7 +42,7 @@ public List extractData(ResultSet rs) throws SQLException, DataAccessExcep
user = User.builder().id(rs.getLong("id")).tenantId(rs.getString("tenantid")).title(rs.getString("title"))
.salutation(rs.getString("salutation"))
- .dob(rs.getDate("dob")).locale(rs.getString("locale")).username(rs.getString("username"))
+ .dob(rs.getDate("dob")).locale(rs.getString("locale")).userName(rs.getString("username"))
.password(rs.getString("password")).passwordExpiryDate(rs.getTimestamp("pwdexpirydate"))
.mobileNumber(rs.getString("mobilenumber")).altContactNumber(rs.getString("altcontactnumber"))
.emailId(rs.getString("emailid")).active(rs.getBoolean("active")).name(rs.getString("name")).
diff --git a/core-services/egov-user/src/main/java/org/egov/user/repository/rowmapper/UserRowMapper.java b/core-services/egov-user/src/main/java/org/egov/user/repository/rowmapper/UserRowMapper.java
index f8c510500fd..47d78ea8891 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/repository/rowmapper/UserRowMapper.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/repository/rowmapper/UserRowMapper.java
@@ -15,7 +15,7 @@ public class UserRowMapper implements RowMapper {
@Override
public User mapRow(final ResultSet rs, final int rowNum) throws SQLException {
final User user = User.builder().id(rs.getLong("id")).tenantId(rs.getString("tenantid")).title(rs.getString("title")).salutation(rs.getString("salutation"))
- .dob(rs.getDate("dob")).locale(rs.getString("locale")).username(rs.getString("username"))
+ .dob(rs.getDate("dob")).locale(rs.getString("locale")).userName(rs.getString("username"))
.password(rs.getString("password")).passwordExpiryDate(rs.getTimestamp("pwdexpirydate"))
.mobileNumber(rs.getString("mobilenumber")).altContactNumber(rs.getString("altcontactnumber"))
.emailId(rs.getString("emailid")).active(rs.getBoolean("active")).name(rs.getString("name")).lastModifiedBy(rs.getLong("lastmodifiedby")).lastModifiedDate(rs.getTimestamp("lastmodifieddate"))
diff --git a/core-services/egov-user/src/main/java/org/egov/user/security/AuthorizationServerConfiguration.java b/core-services/egov-user/src/main/java/org/egov/user/security/AuthorizationServerConfiguration.java
index 5f7560f3b4e..d67b9f74e11 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/security/AuthorizationServerConfiguration.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/security/AuthorizationServerConfiguration.java
@@ -47,7 +47,7 @@ public class AuthorizationServerConfiguration extends AuthorizationServerConfigu
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
final int accessTokenValidityInSeconds = accessTokenValidityInMinutes * 60;
final int refreshTokenValidityInSeconds = refreshTokenValidityInMinutes * 60;
- clients.inMemory().withClient(USER_CLIENT_ID)
+ clients.inMemory().withClient(USER_CLIENT_ID).secret("egov-user-secret")
.authorizedGrantTypes("authorization_code", "refresh_token", "password")
.authorities("ROLE_APP", "ROLE_CITIZEN", "ROLE_ADMIN", "ROLE_EMPLOYEE").scopes("read", "write")
.refreshTokenValiditySeconds(refreshTokenValidityInSeconds)
diff --git a/core-services/egov-user/src/main/java/org/egov/user/security/CustomAuthenticationKeyGenerator.java b/core-services/egov-user/src/main/java/org/egov/user/security/CustomAuthenticationKeyGenerator.java
index 0e1d08f132c..306fa86a5e9 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/security/CustomAuthenticationKeyGenerator.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/security/CustomAuthenticationKeyGenerator.java
@@ -44,9 +44,9 @@ public String extractKey(OAuth2Authentication authentication) {
MessageDigest digest;
try {
- digest = MessageDigest.getInstance(hashAlgorithm);
+ digest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
- throw new IllegalStateException(hashAlgorithm+" algorithm not available. Fatal (should be in the JDK).");
+ throw new IllegalStateException("MD5 algorithm not available. Fatal (should be in the JDK).");
}
try {
diff --git a/core-services/egov-user/src/main/java/org/egov/user/security/oauth2/custom/authproviders/CustomAuthenticationProvider.java b/core-services/egov-user/src/main/java/org/egov/user/security/oauth2/custom/authproviders/CustomAuthenticationProvider.java
index 088f51b8772..e2e90a8e8ff 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/security/oauth2/custom/authproviders/CustomAuthenticationProvider.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/security/oauth2/custom/authproviders/CustomAuthenticationProvider.java
@@ -99,7 +99,7 @@ public Authentication authenticate(Authentication authentication) {
org.egov.common.contract.request.User userInfo = org.egov.common.contract.request.User.builder().uuid(user.getUuid())
.type(user.getType() != null ? user.getType().name() : null).roles(contract_roles).build();
requestInfo = RequestInfo.builder().userInfo(userInfo).build();
- user = encryptionDecryptionUtil.decryptObject(user, "UserSelf", User.class, requestInfo);
+ user = encryptionDecryptionUtil.decryptObject(user, "UserListSelf", User.class, requestInfo);
} catch (UserNotFoundException e) {
log.error("User not found", e);
@@ -204,7 +204,7 @@ private String getTenantId(Authentication authentication) {
}
private org.egov.user.web.contract.auth.User getUser(User user) {
- org.egov.user.web.contract.auth.User authUser = org.egov.user.web.contract.auth.User.builder().id(user.getId()).userName(user.getUsername()).uuid(user.getUuid())
+ org.egov.user.web.contract.auth.User authUser = org.egov.user.web.contract.auth.User.builder().id(user.getId()).userName(user.getUserName()).uuid(user.getUuid())
.name(user.getName()).mobileNumber(user.getMobileNumber()).emailId(user.getEmailId())
.locale(user.getLocale()).active(user.getActive()).type(user.getType().name())
.roles(toAuthRole(user.getRoles())).tenantId(user.getTenantId())
diff --git a/core-services/egov-user/src/main/java/org/egov/user/security/oauth2/custom/authproviders/CustomPreAuthenticatedProvider.java b/core-services/egov-user/src/main/java/org/egov/user/security/oauth2/custom/authproviders/CustomPreAuthenticatedProvider.java
index 8d6712d7ddb..19bc5d67f00 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/security/oauth2/custom/authproviders/CustomPreAuthenticatedProvider.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/security/oauth2/custom/authproviders/CustomPreAuthenticatedProvider.java
@@ -74,7 +74,7 @@ public Authentication authenticate(Authentication authentication) throws Authent
org.egov.common.contract.request.User userInfo = org.egov.common.contract.request.User.builder().uuid(user.getUuid())
.type(user.getType() != null ? user.getType().name() : null).roles(contract_roles).build();
RequestInfo requestInfo = RequestInfo.builder().userInfo(userInfo).build();
- user = encryptionDecryptionUtil.decryptObject(user, "UserSelf", User.class, requestInfo);
+ user = encryptionDecryptionUtil.decryptObject(user, "UserListSelf", User.class, requestInfo);
} catch (UserNotFoundException e) {
log.error("User not found", e);
throw new OAuth2Exception("Invalid login credentials");
@@ -102,7 +102,7 @@ public boolean supports(Class> authentication) {
private org.egov.user.web.contract.auth.User getUser(User user) {
- org.egov.user.web.contract.auth.User authUser = org.egov.user.web.contract.auth.User.builder().id(user.getId()).userName(user.getUsername()).uuid(user.getUuid())
+ org.egov.user.web.contract.auth.User authUser = org.egov.user.web.contract.auth.User.builder().id(user.getId()).userName(user.getUserName()).uuid(user.getUuid())
.name(user.getName()).mobileNumber(user.getMobileNumber()).emailId(user.getEmailId())
.locale(user.getLocale()).active(user.getActive()).type(user.getType().name())
.roles(toAuthRole(user.getRoles())).tenantId(user.getTenantId())
diff --git a/core-services/egov-user/src/main/java/org/egov/user/web/contract/RoleRequest.java b/core-services/egov-user/src/main/java/org/egov/user/web/contract/RoleRequest.java
index d39fa2eaf24..3ebfd3626d5 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/web/contract/RoleRequest.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/web/contract/RoleRequest.java
@@ -4,8 +4,10 @@
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
-import org.egov.user.domain.model.Role;
+import lombok.NoArgsConstructor;
+import org.egov.user.domain.model.Role;
+@NoArgsConstructor
@Getter
@Builder
@AllArgsConstructor
diff --git a/core-services/egov-user/src/main/java/org/egov/user/web/contract/UserRequest.java b/core-services/egov-user/src/main/java/org/egov/user/web/contract/UserRequest.java
index ebcdf121a58..eb5ce3c62be 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/web/contract/UserRequest.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/web/contract/UserRequest.java
@@ -7,7 +7,11 @@
import org.egov.user.domain.model.Address;
import org.egov.user.domain.model.Role;
import org.egov.user.domain.model.User;
-import org.egov.user.domain.model.enums.*;
+import org.egov.user.domain.model.enums.AddressType;
+import org.egov.user.domain.model.enums.BloodGroup;
+import org.egov.user.domain.model.enums.Gender;
+import org.egov.user.domain.model.enums.GuardianRelation;
+import org.egov.user.domain.model.enums.UserType;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.SafeHtml;
@@ -37,7 +41,7 @@ public class UserRequest {
private String salutation;
@Pattern(regexp = UserServiceConstants.PATTERN_NAME)
- @Size(max = 50)
+ @Size(max = 100)
private String name;
@Pattern(regexp = UserServiceConstants.PATTERN_GENDER)
@@ -102,7 +106,7 @@ public class UserRequest {
private Long accountLockedDate;
@Pattern(regexp = UserServiceConstants.PATTERN_NAME)
- @Size(max = 50)
+ @Size(max = 100)
private String fatherOrHusbandName;
private GuardianRelation relationship;
@@ -153,7 +157,7 @@ public class UserRequest {
public UserRequest(User user) {
this.id = user.getId();
- this.userName = user.getUsername();
+ this.userName = user.getUserName();
this.salutation = user.getSalutation();
this.name = user.getName();
this.gender = user.getGender() != null ? user.getGender().toString() : null;
@@ -221,7 +225,7 @@ public User toDomain(Long loggedInUserId, String loggedInUserUuid, boolean isCre
.uuid(this.uuid)
.id(this.id)
.name(this.name)
- .username(this.userName)
+ .userName(this.userName)
.salutation(this.salutation)
.mobileNumber(this.mobileNumber)
.emailId(this.emailId)
diff --git a/core-services/egov-user/src/main/java/org/egov/user/web/contract/UserSearchResponseContent.java b/core-services/egov-user/src/main/java/org/egov/user/web/contract/UserSearchResponseContent.java
index 4243716baab..fc81f175d2f 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/web/contract/UserSearchResponseContent.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/web/contract/UserSearchResponseContent.java
@@ -71,7 +71,7 @@ public class UserSearchResponseContent {
public UserSearchResponseContent(User user) {
this.id = user.getId();
- this.userName = user.getUsername();
+ this.userName = user.getUserName();
this.salutation = user.getSalutation();
this.name = user.getName();
this.gender = user.getGender() != null ? user.getGender().toString() : null;
diff --git a/core-services/egov-user/src/main/java/org/egov/user/web/controller/UserController.java b/core-services/egov-user/src/main/java/org/egov/user/web/controller/UserController.java
index 9f809f0900f..4c84da4a9cf 100644
--- a/core-services/egov-user/src/main/java/org/egov/user/web/controller/UserController.java
+++ b/core-services/egov-user/src/main/java/org/egov/user/web/controller/UserController.java
@@ -1,44 +1,41 @@
package org.egov.user.web.controller;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang.time.DateFormatUtils;
-import org.egov.common.contract.response.ResponseInfo;
-import org.egov.user.domain.model.*;
+import static org.egov.tracer.http.HttpUtils.isInterServiceCall;
+import static org.springframework.util.CollectionUtils.isEmpty;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.validation.Valid;
-import org.apache.commons.lang3.StringUtils;
import org.egov.common.contract.response.ResponseInfo;
-import org.egov.tracer.model.CustomException;
+import org.egov.user.domain.model.UpdateRequest;
+import org.egov.user.domain.model.UpdateResponse;
import org.egov.user.domain.model.User;
import org.egov.user.domain.model.UserDetail;
import org.egov.user.domain.model.UserSearchCriteria;
import org.egov.user.domain.service.TokenService;
import org.egov.user.domain.service.UserService;
-import org.egov.user.web.contract.*;
+import org.egov.user.web.contract.CreateUserRequest;
+import org.egov.user.web.contract.UserDetailResponse;
+import org.egov.user.web.contract.UserRequest;
+import org.egov.user.web.contract.UserSearchRequest;
+import org.egov.user.web.contract.UserSearchResponse;
+import org.egov.user.web.contract.UserSearchResponseContent;
import org.egov.user.web.contract.auth.CustomUserDetails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.util.CollectionUtils;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
-import javax.validation.Valid;
-
-import static org.egov.tracer.http.HttpUtils.isInterServiceCall;
-import static org.springframework.util.CollectionUtils.isEmpty;
+import lombok.extern.slf4j.Slf4j;
@RestController
@Slf4j
diff --git a/core-services/egov-user/src/main/resources/application.properties b/core-services/egov-user/src/main/resources/application.properties
index 768947449dd..0dceb782fb0 100644
--- a/core-services/egov-user/src/main/resources/application.properties
+++ b/core-services/egov-user/src/main/resources/application.properties
@@ -1,5 +1,6 @@
#Set context root
server.contextPath=/user
+cache.expiry.masterdata.minutes=5
server.port=8081
app.timezone=UTC
security.sessions:NEVER
@@ -67,7 +68,7 @@ egov.enc.decrypt.endpoint=/egov-enc-service/crypto/v1/_decrypt
#----------------MDMS config---------------------#
egov.mdms.host=https://upyog-sandbox.niua.org
egov.mdms.search.endpoint=/egov-mdms-service/v1/_search
-state.level.tenant.id=pg
+state.level.tenant.id=pb
#-----------Kafka Audit Topic Name------------#
kafka.topic.audit=audit_data
diff --git a/core-services/egov-user/src/main/resources/db/Dockerfile b/core-services/egov-user/src/main/resources/db/Dockerfile
index 37f9738105d..2f5df5c9d89 100644
--- a/core-services/egov-user/src/main/resources/db/Dockerfile
+++ b/core-services/egov-user/src/main/resources/db/Dockerfile
@@ -1,17 +1,9 @@
-FROM upyogio/flyway:4.1.2
+FROM egovio/flyway:10.7.1
COPY ./migration/ddl /flyway/sql
-COPY ./migration/seed /flyway/seed
-
-COPY ./migration/dev /flyway/dev
-
-COPY ./migration/qa /flyway/qa
-
-COPY ./migration/test /flyway/test
-
COPY migrate.sh /usr/bin/migrate.sh
RUN chmod +x /usr/bin/migrate.sh
-CMD ["/usr/bin/migrate.sh"]
+ENTRYPOINT ["/usr/bin/migrate.sh"]
diff --git a/core-services/egov-user/src/main/resources/db/migrate.sh b/core-services/egov-user/src/main/resources/db/migrate.sh
index 43960b25cdb..8865fad1ae1 100644
--- a/core-services/egov-user/src/main/resources/db/migrate.sh
+++ b/core-services/egov-user/src/main/resources/db/migrate.sh
@@ -1,3 +1,3 @@
#!/bin/sh
-flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate
\ No newline at end of file
+flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -validateOnMigrate=false migrate
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223150524__create_eg_user_table.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223150524__create_eg_user_table.sql
index 37f1248c87a..5f1cc44205a 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223150524__create_eg_user_table.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223150524__create_eg_user_table.sql
@@ -1,4 +1,4 @@
-CREATE TABLE eg_user (
+CREATE TABLE IF NOT EXISTS eg_user (
id bigint NOT NULL,
title character varying(8),
salutation character varying(5),
@@ -31,11 +31,11 @@ CREATE TABLE eg_user (
tenantid character varying(256) not null
);
-CREATE SEQUENCE seq_eg_user
+CREATE SEQUENCE IF NOT EXISTS seq_eg_user
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
-ALTER TABLE eg_user ADD CONSTRAINT eg_user_pkey PRIMARY KEY (id);
-ALTER TABLE eg_user ADD CONSTRAINT eg_user_user_name_key UNIQUE (username);
\ No newline at end of file
+--alter table eg_user ADD CONSTRAINT IF NOT EXISTS eg_user_pkey PRIMARY KEY (id);
+--alter table eg_user ADD CONSTRAINT IF NOT EXISTS eg_user_user_name_key UNIQUE (username);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151046__create_eg_address_table.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151046__create_eg_address_table.sql
index 4bbda016a0d..c88f73cbffe 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151046__create_eg_address_table.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151046__create_eg_address_table.sql
@@ -1,4 +1,4 @@
-CREATE TABLE eg_address (
+CREATE TABLE IF NOT EXISTS eg_address (
housenobldgapt character varying(32),
subdistrict character varying(100),
postoffice character varying(100),
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151145__create_eg_role_table.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151145__create_eg_role_table.sql
index eeb7e991677..5a01d6e9aca 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151145__create_eg_role_table.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151145__create_eg_role_table.sql
@@ -1,4 +1,4 @@
-CREATE TABLE eg_role (
+CREATE TABLE IF NOT EXISTS eg_role (
id serial NOT NULL primary key,
name character varying(32) NOT NULL,
code character varying(50) NOT NULL,
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151229__create_eg_user_role_table.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151229__create_eg_user_role_table.sql
index 382aada38b2..feb2c3a892d 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151229__create_eg_user_role_table.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151229__create_eg_user_role_table.sql
@@ -1,4 +1,4 @@
-CREATE TABLE eg_userrole (
+CREATE TABLE IF NOT EXISTS eg_userrole (
roleid bigint NOT NULL references eg_role(id),
userid bigint NOT NULL references eg_user(id)
);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151230__eg_user_drop_FK_PK_recreate.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151230__eg_user_drop_FK_PK_recreate.sql
index 0352232cd22..de35de69428 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151230__eg_user_drop_FK_PK_recreate.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170223151230__eg_user_drop_FK_PK_recreate.sql
@@ -1,24 +1,26 @@
-alter table eg_address add column userid_bak bigint;
-update eg_address set userid_bak=userid;
-alter table eg_address drop column userid;
-alter table eg_address add column userid bigint;
-update eg_address set userid=userid_bak;
-alter table eg_address drop column userid_bak;
+--alter table eg_user DROP constraint IF EXISTS eg_user_pkey ;
+--alter table eg_user add constraint eg_user_pkey primary key (id,tenantid);
+alter table eg_address add column IF NOT EXISTS userid_bak bigint;
+update eg_address set userid_bak=userid;
+-- alter table eg_address drop column userid;
+alter table eg_address add column IF NOT EXISTS userid bigint;
+update eg_address set userid=userid_bak;
+-- alter table eg_address drop column userid_bak;
-alter table eg_userrole add column userid_bak bigint;
-update eg_userrole set userid_bak=userid;
-alter table eg_userrole drop column userid;
-alter table eg_userrole add column userid bigint;
+
+alter table eg_userrole add column IF NOT EXISTS userid_bak bigint;
+update eg_userrole set userid_bak=userid;
+-- alter table eg_userrole drop column userid;
+alter table eg_userrole add column IF NOT EXISTS userid bigint;
update eg_userrole set userid=userid_bak;
-alter table eg_userrole drop column userid_bak;
+-- alter table eg_userrole drop column userid_bak;
-alter table eg_user add column id_bak bigint;
-update eg_user set id_bak=id;
-alter table eg_user drop column id;
-alter table eg_user add column id bigint;
+alter table eg_user add column IF NOT EXISTS id_bak bigint;
+update eg_user set id_bak=id;
+-- alter table eg_user drop column id;
+alter table eg_user add column IF NOT EXISTS id bigint;
update eg_user set id=id_bak;
-alter table eg_user drop column id_bak;
-alter table eg_user alter column id set not null;
-alter table eg_user add constraint eg_user_pkey primary key (id,tenantid);
+-- alter table eg_user drop column id_bak;
+alter table eg_user alter column id set not null;
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170404154844__create_role_sequence.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170404154844__create_role_sequence.sql
index 6ebcacc749c..8e0b3bf6df1 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170404154844__create_role_sequence.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170404154844__create_role_sequence.sql
@@ -1,4 +1,4 @@
-CREATE SEQUENCE SEQ_EG_ROLE
+CREATE SEQUENCE IF NOT EXISTS SEQ_EG_ROLE
START WITH 1
INCREMENT BY 1
NO MINVALUE
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170417165545__create_unique_username_tenant_constraint.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170417165545__create_unique_username_tenant_constraint.sql
index ed900c80c65..dae01f6f86e 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170417165545__create_unique_username_tenant_constraint.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170417165545__create_unique_username_tenant_constraint.sql
@@ -1,3 +1,3 @@
-ALTER TABLE eg_user DROP CONSTRAINT eg_user_user_name_key;
-
-ALTER TABLE eg_user ADD CONSTRAINT eg_user_user_name_tenant UNIQUE (username, tenantid);
\ No newline at end of file
+-- alter table eg_user DROP CONSTRAINT eg_user_user_name_key;
+alter table eg_user DROP CONSTRAINT IF EXISTS eg_user_user_name_tenant;
+alter table eg_user ADD CONSTRAINT eg_user_user_name_tenant UNIQUE (username, tenantid);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170417165956__create_unique_role_code_tenant_constraint.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170417165956__create_unique_role_code_tenant_constraint.sql
index f27335daebb..7a66c2a0fb7 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170417165956__create_unique_role_code_tenant_constraint.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170417165956__create_unique_role_code_tenant_constraint.sql
@@ -1,3 +1,3 @@
-ALTER TABLE eg_role DROP CONSTRAINT eg_roles_role_name_key;
-
-ALTER TABLE eg_role ADD CONSTRAINT eg_roles_code_tenant UNIQUE (code, tenantid);
\ No newline at end of file
+-- alter table eg_role DROP CONSTRAINT eg_roles_role_name_key;
+alter table eg_role DROP CONSTRAINT IF EXISTS eg_roles_code_tenant ;
+alter table eg_role ADD CONSTRAINT eg_roles_code_tenant UNIQUE (code, tenantid);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170423025220__alter_table_eg_user_to_increase_signature_length.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170423025220__alter_table_eg_user_to_increase_signature_length.sql
index 8200454e8e6..7d688072cb3 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170423025220__alter_table_eg_user_to_increase_signature_length.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170423025220__alter_table_eg_user_to_increase_signature_length.sql
@@ -1,2 +1,2 @@
-ALTER TABLE eg_user ALTER COLUMN signature TYPE CHARACTER VARYING(1000);
-ALTER TABLE eg_user ALTER COLUMN photo TYPE CHARACTER VARYING(1000);
+alter table eg_user ALTER COLUMN signature TYPE CHARACTER VARYING(1000);
+alter table eg_user ALTER COLUMN photo TYPE CHARACTER VARYING(1000);
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170423025221__alter_table_eg_user_to_reset_signature_length.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170423025221__alter_table_eg_user_to_reset_signature_length.sql
index f17ca301ad1..8e512bd8383 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170423025221__alter_table_eg_user_to_reset_signature_length.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170423025221__alter_table_eg_user_to_reset_signature_length.sql
@@ -1,2 +1,2 @@
-ALTER TABLE eg_user ALTER COLUMN signature TYPE CHARACTER VARYING(36);
-ALTER TABLE eg_user ALTER COLUMN photo TYPE CHARACTER VARYING(36);
+alter table eg_user ALTER COLUMN signature TYPE CHARACTER VARYING(36);
+alter table eg_user ALTER COLUMN photo TYPE CHARACTER VARYING(36);
diff --git a/frontend/mono-ui/web/rainmaker/dev-packages/egov-bnd-dev/src/ui-views/App/index.scss b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170425163119__user_insert_users.sql
similarity index 100%
rename from frontend/mono-ui/web/rainmaker/dev-packages/egov-bnd-dev/src/ui-views/App/index.scss
rename to core-services/egov-user/src/main/resources/db/migration/ddl/V20170425163119__user_insert_users.sql
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170428175632__recreate_user_address_table.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170428175632__recreate_user_address_table.sql
index 21b706ce0de..d3b7cc20f78 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170428175632__recreate_user_address_table.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170428175632__recreate_user_address_table.sql
@@ -1,4 +1,4 @@
-CREATE TABLE eg_user_address (
+CREATE TABLE IF NOT EXISTS eg_user_address (
id bigint NOT NULL,
version numeric DEFAULT 0,
createddate timestamp NOT NULL,
@@ -13,11 +13,11 @@ CREATE TABLE eg_user_address (
tenantid VARCHAR(256) NOT NULL
);
-ALTER TABLE eg_user_address ADD CONSTRAINT eg_user_address_pkey PRIMARY KEY (id);
+--alter table eg_user_address ADD CONSTRAINT IF NOT EXISTS eg_user_address_pkey PRIMARY KEY (id);
-ALTER TABLE eg_user_address ADD CONSTRAINT eg_user_address_user_fkey FOREIGN KEY (userid, tenantid)
-REFERENCES eg_user ON DELETE CASCADE;
+--alter table eg_user_address ADD CONSTRAINT IF NOT EXISTS eg_user_address_user_fkey FOREIGN KEY (userid, tenantid)
+-- REFERENCES eg_user ON DELETE CASCADE;
-ALTER TABLE eg_user_address ADD CONSTRAINT eg_user_address_type_unique UNIQUE (userid, tenantid, type);
+--alter table eg_user_address ADD CONSTRAINT IF NOT EXISTS eg_user_address_type_unique UNIQUE (userid, tenantid, type);
-CREATE SEQUENCE seq_eg_user_address START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
\ No newline at end of file
+CREATE SEQUENCE IF NOT EXISTS seq_eg_user_address START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170509172805__recreate_role_and_user_role_table_with_tenantid.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170509172805__recreate_role_and_user_role_table_with_tenantid.sql
index 97bc5845c4c..0f9187660b8 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170509172805__recreate_role_and_user_role_table_with_tenantid.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170509172805__recreate_role_and_user_role_table_with_tenantid.sql
@@ -1,12 +1,13 @@
-DROP TABLE eg_userrole;
-ALTER TABLE eg_role ADD roleid bigint NOT NULL DEFAULT 0;
-UPDATE eg_role SET roleid = id;
-ALTER TABLE eg_role ALTER COLUMN roleid DROP DEFAULT;
-ALTER TABLE eg_role DROP COLUMN id;
-ALTER TABLE eg_role RENAME COLUMN roleid TO id;
-ALTER TABLE eg_role ADD CONSTRAINT eg_role_pk PRIMARY KEY (id, tenantid);
+-- DROP TABLE eg_userrole;
+ALTER TABLE eg_role ADD IF NOT EXISTS roleid bigint NOT NULL DEFAULT 0;
+UPDATE eg_role SET roleid = id;
+alter table eg_role ALTER COLUMN roleid DROP DEFAULT;
+alter table eg_role DROP COLUMN id CASCADE;
+alter table eg_role RENAME COLUMN roleid TO id;
+alter table eg_role DROP CONSTRAINT IF EXISTS eg_role_pk;
+alter table eg_role ADD CONSTRAINT eg_role_pk PRIMARY KEY (id, tenantid);
-CREATE TABLE eg_userrole (
+CREATE TABLE IF NOT EXISTS eg_userrole (
roleid bigint NOT NULL,
roleidtenantid character varying(256) NOT NULL,
userid bigint NOT NULL,
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170516145558__alter_userrole_add_lastmodifieddate.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170516145558__alter_userrole_add_lastmodifieddate.sql
index 8a08f55a38e..37c6e1ccc6b 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170516145558__alter_userrole_add_lastmodifieddate.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170516145558__alter_userrole_add_lastmodifieddate.sql
@@ -1 +1 @@
-alter table eg_userrole add column lastmodifieddate TIMESTAMP default now();
\ No newline at end of file
+alter table eg_userrole add column IF NOT EXISTS lastmodifieddate TIMESTAMP default now();
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170823203553__dropping_not_null_for_mobilenumber_in_eg_user.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170823203553__dropping_not_null_for_mobilenumber_in_eg_user.sql
index f8d594af4ad..94ff6ff21f2 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20170823203553__dropping_not_null_for_mobilenumber_in_eg_user.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20170823203553__dropping_not_null_for_mobilenumber_in_eg_user.sql
@@ -1 +1 @@
-ALTER TABLE eg_user ALTER COLUMN mobilenumber DROP NOT NULL;
\ No newline at end of file
+-- alter table eg_user ALTER COLUMN mobilenumber DROP NOT NULL;
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20180313150524__added_uuid_user_table.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20180313150524__added_uuid_user_table.sql
index e4c672852ef..2123edbd52e 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20180313150524__added_uuid_user_table.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20180313150524__added_uuid_user_table.sql
@@ -1 +1 @@
-alter table eg_user add column uuid character(36);
\ No newline at end of file
+alter table eg_user add column IF NOT EXISTS uuid character(36);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20180725165212__alter_eg_role_name.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20180725165212__alter_eg_role_name.sql
index b53499e3df4..a5db5d8c654 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20180725165212__alter_eg_role_name.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20180725165212__alter_eg_role_name.sql
@@ -1 +1 @@
-ALTER TABLE eg_role ALTER COLUMN name TYPE VARCHAR(128);
+alter table eg_role ALTER COLUMN name TYPE VARCHAR(128);
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20180731215512__alter_eg_role_address_fk.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20180731215512__alter_eg_role_address_fk.sql
index 079fda2603c..158d0d71b96 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20180731215512__alter_eg_role_address_fk.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20180731215512__alter_eg_role_address_fk.sql
@@ -1,8 +1,8 @@
-ALTER TABLE eg_user DROP CONSTRAINT eg_user_user_name_tenant;
-ALTER TABLE eg_user ADD CONSTRAINT eg_user_user_name_tenant UNIQUE (username, type, tenantid);
+alter table eg_user DROP CONSTRAINT IF EXISTS eg_user_user_name_tenant;
+alter table eg_user ADD CONSTRAINT eg_user_user_name_tenant UNIQUE (username, type, tenantid);
-ALTER TABLE eg_userrole DROP CONSTRAINT eg_userrole_userid_fkey;
-ALTER TABLE eg_user_address DROP CONSTRAINT eg_user_address_user_fkey;
+ALTER TABLE eg_userrole DROP CONSTRAINT IF EXISTS eg_userrole_userid_fkey;
+alter table eg_user_address DROP CONSTRAINT IF EXISTS eg_user_address_user_fkey;
-ALTER TABLE eg_userrole ADD CONSTRAINT eg_userrole_userid_fkey FOREIGN KEY (userid, tenantid) REFERENCES eg_user (id, tenantid) ON UPDATE CASCADE ON DELETE CASCADE;
-ALTER TABLE eg_user_address ADD CONSTRAINT eg_user_address_user_fkey FOREIGN KEY (userid, tenantid) REFERENCES eg_user (id, tenantid) ON UPDATE CASCADE ON DELETE CASCADE;
\ No newline at end of file
+alter table eg_userrole ADD CONSTRAINT eg_userrole_userid_fkey FOREIGN KEY (userid, tenantid) REFERENCES eg_user (id, tenantid) ON UPDATE CASCADE ON DELETE CASCADE;
+alter table eg_user_address ADD CONSTRAINT eg_user_address_user_fkey FOREIGN KEY (userid, tenantid) REFERENCES eg_user (id, tenantid) ON UPDATE CASCADE ON DELETE CASCADE;
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20181108160312__create_indices_eg_user_role.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20181108160312__create_indices_eg_user_role.sql
index 670a1634693..02a10af2e24 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20181108160312__create_indices_eg_user_role.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20181108160312__create_indices_eg_user_role.sql
@@ -1,7 +1,7 @@
-CREATE INDEX IDX_EG_USER_USERNAME ON EG_USER (username);
-CREATE INDEX IDX_EG_USER_NAME ON EG_USER (name);
-CREATE INDEX IDX_EG_USER_ACTIVE ON EG_USER (active);
-CREATE INDEX IDX_EG_USER_MOBILE ON EG_USER (mobilenumber);
-CREATE INDEX IDX_EG_USER_TYPE ON EG_USER (type);
-CREATE INDEX IDX_EG_USER_UUID ON EG_USER (uuid);
-CREATE INDEX IDX_EG_ROLE_CODE ON EG_ROLE (code);
+CREATE INDEX IF NOT EXISTS IDX_EG_USER_USERNAME ON EG_USER (username);
+CREATE INDEX IF NOT EXISTS IDX_EG_USER_NAME ON EG_USER (name);
+CREATE INDEX IF NOT EXISTS IDX_EG_USER_ACTIVE ON EG_USER (active);
+CREATE INDEX IF NOT EXISTS IDX_EG_USER_MOBILE ON EG_USER (mobilenumber);
+CREATE INDEX IF NOT EXISTS IDX_EG_USER_TYPE ON EG_USER (type);
+CREATE INDEX IF NOT EXISTS IDX_EG_USER_UUID ON EG_USER (uuid);
+CREATE INDEX IF NOT EXISTS IDX_EG_ROLE_CODE ON EG_ROLE (code);
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20190204144112__create_eg_userrole_v1.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20190204144112__create_eg_userrole_v1.sql
index 5969e3dfc88..27cd7221ce2 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20190204144112__create_eg_userrole_v1.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20190204144112__create_eg_userrole_v1.sql
@@ -1,5 +1,5 @@
-CREATE TABLE eg_userrole_v1 AS
+CREATE TABLE IF NOT EXISTS eg_userrole_v1 AS
select r.code as role_code, ur.roleidtenantid role_tenantid, ur.userid as user_id, ur.tenantid as user_tenantid, ur
.lastmodifieddate as lastmodifieddate
from eg_userrole ur join eg_role r ON ur.roleid = r.id AND ur.roleidtenantid = r.tenantid ;
-ALTER TABLE eg_userrole_v1 ADD CONSTRAINT fk_user_role_v1 FOREIGN KEY (user_id, user_tenantid) REFERENCES eg_user(id, tenantid);
\ No newline at end of file
+-- alter table eg_userrole_v1 ADD CONSTRAINT IF NOT EXISTS fk_user_role_v1 FOREIGN KEY (user_id, user_tenantid) REFERENCES eg_user(id, tenantid);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20190222121612__create_eg_user_failed_login_attempts.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20190222121612__create_eg_user_failed_login_attempts.sql
index 449d0c73ce7..1559cf5cdab 100644
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20190222121612__create_eg_user_failed_login_attempts.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20190222121612__create_eg_user_failed_login_attempts.sql
@@ -1,4 +1,4 @@
-ALTER TABLE eg_user ADD COLUMN accountlockeddate bigint;
+alter table eg_user ADD COLUMN IF NOT EXISTS accountlockeddate bigint;
CREATE TABLE IF NOT EXISTS eg_user_login_failed_attempts (
user_uuid character varying(64) NOT NULL,
ip character varying(46),
diff --git a/core-services/egov-user/src/main/resources/db/migration/ddl/V20190313165702__alter_eg_user_address_extend.sql b/core-services/egov-user/src/main/resources/db/migration/ddl/V20190313165702__alter_eg_user_address_extend.sql
old mode 100755
new mode 100644
index 409272c5a13..66ed8bbf26c
--- a/core-services/egov-user/src/main/resources/db/migration/ddl/V20190313165702__alter_eg_user_address_extend.sql
+++ b/core-services/egov-user/src/main/resources/db/migration/ddl/V20190313165702__alter_eg_user_address_extend.sql
@@ -1,12 +1,12 @@
-ALTER TABLE eg_user
- ALTER COLUMN name TYPE varchar (250),
- ALTER COLUMN mobilenumber TYPE varchar (150),
- ALTER COLUMN emailid TYPE varchar (300),
- ALTER COLUMN username TYPE varchar (180),
- ALTER COLUMN altcontactnumber TYPE varchar (150),
- ALTER COLUMN pan TYPE varchar (65),
- ALTER COLUMN aadhaarnumber TYPE varchar (85),
- ALTER COLUMN guardian TYPE varchar (250);
-
-ALTER TABLE eg_user_address
- ALTER COLUMN address TYPE varchar (440);
\ No newline at end of file
+alter table eg_user
+ ALTER COLUMN name TYPE varchar (250),
+ ALTER COLUMN mobilenumber TYPE varchar (150),
+ ALTER COLUMN emailid TYPE varchar (300),
+ ALTER COLUMN username TYPE varchar (180),
+ ALTER COLUMN altcontactnumber TYPE varchar (150),
+ ALTER COLUMN pan TYPE varchar (65),
+ ALTER COLUMN aadhaarnumber TYPE varchar (85),
+ ALTER COLUMN guardian TYPE varchar (250);
+
+alter table eg_user_address
+ ALTER COLUMN address TYPE varchar (440);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/Dockerfile b/core-services/egov-user/src/main/resources/db2/Dockerfile
new file mode 100644
index 00000000000..2f5df5c9d89
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/Dockerfile
@@ -0,0 +1,9 @@
+FROM egovio/flyway:10.7.1
+
+COPY ./migration/ddl /flyway/sql
+
+COPY migrate.sh /usr/bin/migrate.sh
+
+RUN chmod +x /usr/bin/migrate.sh
+
+ENTRYPOINT ["/usr/bin/migrate.sh"]
diff --git a/core-services/egov-user/src/main/resources/db2/migrate.sh b/core-services/egov-user/src/main/resources/db2/migrate.sh
new file mode 100644
index 00000000000..8865fad1ae1
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migrate.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -validateOnMigrate=false migrate
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20170223150524__create_eg_user_table.sql b/core-services/egov-user/src/main/resources/db2/migration/V20170223150524__create_eg_user_table.sql
new file mode 100644
index 00000000000..5e30a689299
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20170223150524__create_eg_user_table.sql
@@ -0,0 +1,41 @@
+CREATE TABLE IF NOT EXISTS eg_user (
+ id bigint NOT NULL,
+ title character varying(8),
+ salutation character varying(5),
+ dob timestamp,
+ locale character varying(16),
+ username character varying(64) NOT NULL,
+ password character varying(64) NOT NULL,
+ pwdexpirydate timestamp DEFAULT CURRENT_TIMESTAMP,
+ mobilenumber character varying(50),
+ altcontactnumber character varying(50),
+ emailid character varying(128),
+ createddate timestamp,
+ lastmodifieddate timestamp,
+ createdby bigint,
+ lastmodifiedby bigint,
+ active boolean,
+ name character varying(100),
+ gender smallint,
+ pan character varying(10),
+ aadhaarnumber character varying(20),
+ type character varying(50),
+ version numeric DEFAULT 0,
+ guardian character varying(100),
+ guardianrelation character varying(32),
+ signature character varying(36),
+ accountlocked boolean DEFAULT false,
+ bloodgroup character varying(32),
+ photo character varying(36),
+ identificationmark character varying(300),
+ tenantid character varying(256) not null
+);
+
+CREATE SEQUENCE IF NOT EXISTS seq_eg_user
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+ALTER TABLE eg_user ADD CONSTRAINT IF NOT EXISTS eg_user_pkey PRIMARY KEY (id);
+ALTER TABLE eg_user ADD CONSTRAINT IF NOT EXISTS eg_user_user_name_key UNIQUE (username);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20170223151046__create_eg_address_table.sql b/core-services/egov-user/src/main/resources/db2/migration/V20170223151046__create_eg_address_table.sql
new file mode 100644
index 00000000000..4bbda016a0d
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20170223151046__create_eg_address_table.sql
@@ -0,0 +1,17 @@
+CREATE TABLE eg_address (
+ housenobldgapt character varying(32),
+ subdistrict character varying(100),
+ postoffice character varying(100),
+ landmark character varying(256),
+ country character varying(50),
+ userid bigint not null references eg_user(id),
+ type character varying(50),
+ streetroadline character varying(256),
+ citytownvillage character varying(256),
+ arealocalitysector character varying(256),
+ district character varying(100),
+ state character varying(100),
+ pincode character varying(10),
+ id serial NOT NULL primary key,
+ version bigint DEFAULT 0,
+ tenantid character varying(256) not null);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20170223151145__create_eg_role_table.sql b/core-services/egov-user/src/main/resources/db2/migration/V20170223151145__create_eg_role_table.sql
new file mode 100644
index 00000000000..eeb7e991677
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20170223151145__create_eg_role_table.sql
@@ -0,0 +1,13 @@
+CREATE TABLE eg_role (
+ id serial NOT NULL primary key,
+ name character varying(32) NOT NULL,
+ code character varying(50) NOT NULL,
+ description character varying(128),
+ createddate timestamp DEFAULT CURRENT_TIMESTAMP,
+ createdby bigint,
+ lastmodifiedby bigint,
+ lastmodifieddate timestamp,
+ version bigint,
+ tenantid character varying(256) not null,
+ CONSTRAINT eg_roles_role_name_key UNIQUE (name)
+);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20170223151229__create_eg_user_role_table.sql b/core-services/egov-user/src/main/resources/db2/migration/V20170223151229__create_eg_user_role_table.sql
new file mode 100644
index 00000000000..382aada38b2
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20170223151229__create_eg_user_role_table.sql
@@ -0,0 +1,4 @@
+CREATE TABLE eg_userrole (
+ roleid bigint NOT NULL references eg_role(id),
+ userid bigint NOT NULL references eg_user(id)
+);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20170223151230__eg_user_drop_FK_PK_recreate.sql b/core-services/egov-user/src/main/resources/db2/migration/V20170223151230__eg_user_drop_FK_PK_recreate.sql
new file mode 100644
index 00000000000..0352232cd22
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20170223151230__eg_user_drop_FK_PK_recreate.sql
@@ -0,0 +1,24 @@
+alter table eg_address add column userid_bak bigint;
+update eg_address set userid_bak=userid;
+alter table eg_address drop column userid;
+alter table eg_address add column userid bigint;
+update eg_address set userid=userid_bak;
+alter table eg_address drop column userid_bak;
+
+
+alter table eg_userrole add column userid_bak bigint;
+update eg_userrole set userid_bak=userid;
+alter table eg_userrole drop column userid;
+alter table eg_userrole add column userid bigint;
+update eg_userrole set userid=userid_bak;
+alter table eg_userrole drop column userid_bak;
+
+alter table eg_user add column id_bak bigint;
+update eg_user set id_bak=id;
+alter table eg_user drop column id;
+alter table eg_user add column id bigint;
+update eg_user set id=id_bak;
+alter table eg_user drop column id_bak;
+alter table eg_user alter column id set not null;
+alter table eg_user add constraint eg_user_pkey primary key (id,tenantid);
+
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20170404154844__create_role_sequence.sql b/core-services/egov-user/src/main/resources/db2/migration/V20170404154844__create_role_sequence.sql
new file mode 100644
index 00000000000..6ebcacc749c
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20170404154844__create_role_sequence.sql
@@ -0,0 +1,6 @@
+CREATE SEQUENCE SEQ_EG_ROLE
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20170417165545__create_unique_username_tenant_constraint.sql b/core-services/egov-user/src/main/resources/db2/migration/V20170417165545__create_unique_username_tenant_constraint.sql
new file mode 100644
index 00000000000..ed900c80c65
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20170417165545__create_unique_username_tenant_constraint.sql
@@ -0,0 +1,3 @@
+ALTER TABLE eg_user DROP CONSTRAINT eg_user_user_name_key;
+
+ALTER TABLE eg_user ADD CONSTRAINT eg_user_user_name_tenant UNIQUE (username, tenantid);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20170417165956__create_unique_role_code_tenant_constraint.sql b/core-services/egov-user/src/main/resources/db2/migration/V20170417165956__create_unique_role_code_tenant_constraint.sql
new file mode 100644
index 00000000000..f27335daebb
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20170417165956__create_unique_role_code_tenant_constraint.sql
@@ -0,0 +1,3 @@
+ALTER TABLE eg_role DROP CONSTRAINT eg_roles_role_name_key;
+
+ALTER TABLE eg_role ADD CONSTRAINT eg_roles_code_tenant UNIQUE (code, tenantid);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20170423025220__alter_table_eg_user_to_increase_signature_length.sql b/core-services/egov-user/src/main/resources/db2/migration/V20170423025220__alter_table_eg_user_to_increase_signature_length.sql
new file mode 100644
index 00000000000..8200454e8e6
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20170423025220__alter_table_eg_user_to_increase_signature_length.sql
@@ -0,0 +1,2 @@
+ALTER TABLE eg_user ALTER COLUMN signature TYPE CHARACTER VARYING(1000);
+ALTER TABLE eg_user ALTER COLUMN photo TYPE CHARACTER VARYING(1000);
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20170423025221__alter_table_eg_user_to_reset_signature_length.sql b/core-services/egov-user/src/main/resources/db2/migration/V20170423025221__alter_table_eg_user_to_reset_signature_length.sql
new file mode 100644
index 00000000000..f17ca301ad1
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20170423025221__alter_table_eg_user_to_reset_signature_length.sql
@@ -0,0 +1,2 @@
+ALTER TABLE eg_user ALTER COLUMN signature TYPE CHARACTER VARYING(36);
+ALTER TABLE eg_user ALTER COLUMN photo TYPE CHARACTER VARYING(36);
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20170428175632__recreate_user_address_table.sql b/core-services/egov-user/src/main/resources/db2/migration/V20170428175632__recreate_user_address_table.sql
new file mode 100644
index 00000000000..21b706ce0de
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20170428175632__recreate_user_address_table.sql
@@ -0,0 +1,23 @@
+CREATE TABLE eg_user_address (
+ id bigint NOT NULL,
+ version numeric DEFAULT 0,
+ createddate timestamp NOT NULL,
+ lastmodifieddate timestamp,
+ createdby bigint NOT NULL,
+ lastmodifiedby bigint,
+ type VARCHAR (50) NOT NULL,
+ address VARCHAR(300),
+ city VARCHAR(300),
+ pincode VARCHAR(10),
+ userid bigint NOT NULL,
+ tenantid VARCHAR(256) NOT NULL
+ );
+
+ALTER TABLE eg_user_address ADD CONSTRAINT eg_user_address_pkey PRIMARY KEY (id);
+
+ALTER TABLE eg_user_address ADD CONSTRAINT eg_user_address_user_fkey FOREIGN KEY (userid, tenantid)
+REFERENCES eg_user ON DELETE CASCADE;
+
+ALTER TABLE eg_user_address ADD CONSTRAINT eg_user_address_type_unique UNIQUE (userid, tenantid, type);
+
+CREATE SEQUENCE seq_eg_user_address START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20170509172805__recreate_role_and_user_role_table_with_tenantid.sql b/core-services/egov-user/src/main/resources/db2/migration/V20170509172805__recreate_role_and_user_role_table_with_tenantid.sql
new file mode 100644
index 00000000000..97bc5845c4c
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20170509172805__recreate_role_and_user_role_table_with_tenantid.sql
@@ -0,0 +1,16 @@
+DROP TABLE eg_userrole;
+ALTER TABLE eg_role ADD roleid bigint NOT NULL DEFAULT 0;
+UPDATE eg_role SET roleid = id;
+ALTER TABLE eg_role ALTER COLUMN roleid DROP DEFAULT;
+ALTER TABLE eg_role DROP COLUMN id;
+ALTER TABLE eg_role RENAME COLUMN roleid TO id;
+ALTER TABLE eg_role ADD CONSTRAINT eg_role_pk PRIMARY KEY (id, tenantid);
+
+CREATE TABLE eg_userrole (
+ roleid bigint NOT NULL,
+ roleidtenantid character varying(256) NOT NULL,
+ userid bigint NOT NULL,
+ tenantid character varying(256) NOT NULL,
+ FOREIGN KEY (roleid, roleidtenantid) REFERENCES eg_role (id, tenantid),
+ FOREIGN KEY (userid, tenantid) REFERENCES eg_user (id, tenantid)
+);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20170516145558__alter_userrole_add_lastmodifieddate.sql b/core-services/egov-user/src/main/resources/db2/migration/V20170516145558__alter_userrole_add_lastmodifieddate.sql
new file mode 100644
index 00000000000..8a08f55a38e
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20170516145558__alter_userrole_add_lastmodifieddate.sql
@@ -0,0 +1 @@
+alter table eg_userrole add column lastmodifieddate TIMESTAMP default now();
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20170823203553__dropping_not_null_for_mobilenumber_in_eg_user.sql b/core-services/egov-user/src/main/resources/db2/migration/V20170823203553__dropping_not_null_for_mobilenumber_in_eg_user.sql
new file mode 100644
index 00000000000..f8d594af4ad
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20170823203553__dropping_not_null_for_mobilenumber_in_eg_user.sql
@@ -0,0 +1 @@
+ALTER TABLE eg_user ALTER COLUMN mobilenumber DROP NOT NULL;
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20180313150524__added_uuid_user_table.sql b/core-services/egov-user/src/main/resources/db2/migration/V20180313150524__added_uuid_user_table.sql
new file mode 100644
index 00000000000..e4c672852ef
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20180313150524__added_uuid_user_table.sql
@@ -0,0 +1 @@
+alter table eg_user add column uuid character(36);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20180725165212__alter_eg_role_name.sql b/core-services/egov-user/src/main/resources/db2/migration/V20180725165212__alter_eg_role_name.sql
new file mode 100644
index 00000000000..b53499e3df4
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20180725165212__alter_eg_role_name.sql
@@ -0,0 +1 @@
+ALTER TABLE eg_role ALTER COLUMN name TYPE VARCHAR(128);
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20180731215512__alter_eg_role_address_fk.sql b/core-services/egov-user/src/main/resources/db2/migration/V20180731215512__alter_eg_role_address_fk.sql
new file mode 100644
index 00000000000..21c671b98ab
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20180731215512__alter_eg_role_address_fk.sql
@@ -0,0 +1,8 @@
+ALTER TABLE eg_user DROP CONSTRAINT eg_user_user_name_tenant;
+ALTER TABLE eg_user ADD CONSTRAINT eg_user_user_name_tenant UNIQUE (username, type, tenantid);
+
+--ALTER TABLE eg_userrole DROP CONSTRAINT eg_userrole_userid_fkey;
+ALTER TABLE eg_user_address DROP CONSTRAINT eg_user_address_user_fkey;
+
+ALTER TABLE eg_userrole ADD CONSTRAINT eg_userrole_userid_fkey FOREIGN KEY (userid, tenantid) REFERENCES eg_user (id, tenantid) ON UPDATE CASCADE ON DELETE CASCADE;
+ALTER TABLE eg_user_address ADD CONSTRAINT eg_user_address_user_fkey FOREIGN KEY (userid, tenantid) REFERENCES eg_user (id, tenantid) ON UPDATE CASCADE ON DELETE CASCADE;
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20181108160312__create_indices_eg_user_role.sql b/core-services/egov-user/src/main/resources/db2/migration/V20181108160312__create_indices_eg_user_role.sql
new file mode 100644
index 00000000000..670a1634693
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20181108160312__create_indices_eg_user_role.sql
@@ -0,0 +1,7 @@
+CREATE INDEX IDX_EG_USER_USERNAME ON EG_USER (username);
+CREATE INDEX IDX_EG_USER_NAME ON EG_USER (name);
+CREATE INDEX IDX_EG_USER_ACTIVE ON EG_USER (active);
+CREATE INDEX IDX_EG_USER_MOBILE ON EG_USER (mobilenumber);
+CREATE INDEX IDX_EG_USER_TYPE ON EG_USER (type);
+CREATE INDEX IDX_EG_USER_UUID ON EG_USER (uuid);
+CREATE INDEX IDX_EG_ROLE_CODE ON EG_ROLE (code);
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20190204144112__create_eg_userrole_v1.sql b/core-services/egov-user/src/main/resources/db2/migration/V20190204144112__create_eg_userrole_v1.sql
new file mode 100644
index 00000000000..5969e3dfc88
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20190204144112__create_eg_userrole_v1.sql
@@ -0,0 +1,5 @@
+CREATE TABLE eg_userrole_v1 AS
+select r.code as role_code, ur.roleidtenantid role_tenantid, ur.userid as user_id, ur.tenantid as user_tenantid, ur
+.lastmodifieddate as lastmodifieddate
+ from eg_userrole ur join eg_role r ON ur.roleid = r.id AND ur.roleidtenantid = r.tenantid ;
+ALTER TABLE eg_userrole_v1 ADD CONSTRAINT fk_user_role_v1 FOREIGN KEY (user_id, user_tenantid) REFERENCES eg_user(id, tenantid);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20190222121612__create_eg_user_failed_login_attempts.sql b/core-services/egov-user/src/main/resources/db2/migration/V20190222121612__create_eg_user_failed_login_attempts.sql
new file mode 100644
index 00000000000..449d0c73ce7
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20190222121612__create_eg_user_failed_login_attempts.sql
@@ -0,0 +1,9 @@
+ALTER TABLE eg_user ADD COLUMN accountlockeddate bigint;
+CREATE TABLE IF NOT EXISTS eg_user_login_failed_attempts (
+ user_uuid character varying(64) NOT NULL,
+ ip character varying(46),
+ attempt_date bigint NOT NULL,
+ active boolean
+);
+CREATE INDEX IF NOT EXISTS idx_eg_user_failed_attempts_user_uuid ON eg_user_login_failed_attempts (user_uuid);
+CREATE INDEX IF NOT EXISTS idx_eg_user_failed_attempts_user_attemptdate ON eg_user_login_failed_attempts (attempt_date);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20190313165702__alter_eg_user_address_extend.sql b/core-services/egov-user/src/main/resources/db2/migration/V20190313165702__alter_eg_user_address_extend.sql
new file mode 100644
index 00000000000..958da941aec
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20190313165702__alter_eg_user_address_extend.sql
@@ -0,0 +1,12 @@
+ALTER TABLE eg_user
+ ALTER COLUMN name TYPE varchar (250),
+ ALTER COLUMN mobilenumber TYPE varchar (150),
+ ALTER COLUMN emailid TYPE varchar (300),
+ ALTER COLUMN username TYPE varchar (180),
+ ALTER COLUMN altcontactnumber TYPE varchar (150),
+ ALTER COLUMN pan TYPE varchar (65),
+ ALTER COLUMN aadhaarnumber TYPE varchar (85),
+ ALTER COLUMN guardian TYPE varchar (250);
+
+ALTER TABLE eg_user_address
+ ALTER COLUMN address TYPE varchar (440);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/V20190402123143__create_indices_eg_user_eg_userrole_v1 .sql b/core-services/egov-user/src/main/resources/db2/migration/V20190402123143__create_indices_eg_user_eg_userrole_v1 .sql
new file mode 100644
index 00000000000..b535ff2c49b
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/V20190402123143__create_indices_eg_user_eg_userrole_v1 .sql
@@ -0,0 +1,6 @@
+CREATE INDEX IF NOT EXISTS idx_eg_user_tenantid ON eg_user(tenantid);
+CREATE INDEX IF NOT EXISTS idx_eg_user_address_tenantid ON eg_user_address(tenantid);
+CREATE INDEX IF NOT EXISTS idx_eg_userrole_v1_rolecode ON eg_userrole_v1(role_code);
+CREATE INDEX IF NOT EXISTS idx_eg_userrole_v1_roletenantid ON eg_userrole_v1(role_tenantid);
+CREATE INDEX IF NOT EXISTS idx_eg_userrole_v1_userid ON eg_userrole_v1(user_id);
+CREATE INDEX IF NOT EXISTS idx_eg_userrole_v1_usertenantid ON eg_userrole_v1(user_tenantid);
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/ddl/V20210908231720__alter_table_eg_user_alternate_number.sql b/core-services/egov-user/src/main/resources/db2/migration/ddl/V20210908231720__alter_table_eg_user_alternate_number.sql
new file mode 100644
index 00000000000..db062a36766
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/ddl/V20210908231720__alter_table_eg_user_alternate_number.sql
@@ -0,0 +1 @@
+ALTER TABLE eg_user ADD IF NOT EXISTS alternatemobilenumber character varying (50) DEFAULT NULL;
diff --git a/core-services/egov-user/src/main/resources/db2/migration/ddl/V20211029155746__create_table_user_audit.sql b/core-services/egov-user/src/main/resources/db2/migration/ddl/V20211029155746__create_table_user_audit.sql
new file mode 100644
index 00000000000..6f8e1c496ad
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/ddl/V20211029155746__create_table_user_audit.sql
@@ -0,0 +1,31 @@
+CREATE TABLE eg_user_audit_table(
+ id bigint NOT NULL,
+ title character varying(8),
+ salutation character varying(5),
+ dob timestamp,
+ locale character varying(16),
+ username character varying(64) NOT NULL,
+ password character varying(64) NOT NULL,
+ pwdexpirydate timestamp DEFAULT CURRENT_TIMESTAMP,
+ mobilenumber character varying(50),
+ altcontactnumber character varying(50),
+ emailid character varying(128),
+ active boolean,
+ name character varying(100),
+ gender smallint,
+ pan character varying(50),
+ aadhaarnumber character varying(50),
+ type character varying(50),
+ version numeric DEFAULT 0,
+ guardian character varying(100),
+ guardianrelation character varying(32),
+ signature character varying(36),
+ accountlocked boolean DEFAULT false,
+ bloodgroup character varying(32),
+ photo character varying(36),
+ identificationmark character varying(300),
+ tenantid character varying(256) not null,
+ uuid character(36),
+ auditcreatedby bigint,
+ auditcreatedtime bigint
+);
diff --git a/core-services/egov-user/src/main/resources/db2/migration/ddl/V20211029171730__modified_auditby.sql b/core-services/egov-user/src/main/resources/db2/migration/ddl/V20211029171730__modified_auditby.sql
new file mode 100644
index 00000000000..49fe7c5adf7
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/ddl/V20211029171730__modified_auditby.sql
@@ -0,0 +1 @@
+ALTER TABLE eg_user_audit_table ALTER COLUMN auditcreatedby TYPE character varying(100);
diff --git a/core-services/egov-user/src/main/resources/db2/migration/ddl/V20211029175430__modified_username_audit.sql b/core-services/egov-user/src/main/resources/db2/migration/ddl/V20211029175430__modified_username_audit.sql
new file mode 100644
index 00000000000..057d382f7a8
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/ddl/V20211029175430__modified_username_audit.sql
@@ -0,0 +1,3 @@
+ALTER TABLE eg_user_audit_table ALTER COLUMN username TYPE character varying(300);
+ALTER TABLE eg_user_audit_table ALTER COLUMN password TYPE character varying(300);
+ALTER TABLE eg_user_audit_table ALTER COLUMN uuid TYPE character varying(300);
diff --git a/frontend/mono-ui/web/rainmaker/dev-packages/egov-inbox-dev/src/App.scss b/core-services/egov-user/src/main/resources/db2/migration/dev/V20170425163119__user_insert_users.sql
similarity index 100%
rename from frontend/mono-ui/web/rainmaker/dev-packages/egov-inbox-dev/src/App.scss
rename to core-services/egov-user/src/main/resources/db2/migration/dev/V20170425163119__user_insert_users.sql
diff --git a/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170425163119__user_insert_users.sql b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170425163119__user_insert_users.sql
new file mode 100644
index 00000000000..3d032e29f43
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170425163119__user_insert_users.sql
@@ -0,0 +1,10 @@
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'narasappa', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', '1234567890', NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'narasappa', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','default');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'manas', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', '1234567890', NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'manas', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','default');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation, signature, bloodgroup,accountlocked,photo,identificationmark, tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'ramana', '$2a$10$/pAdOFmv9h7jrnm2zkEQjOKnWO9/xt8T0t.gkT7rb7t4ugz7QUEPi', '2017-03-10 10:32:17.627', '0123456789', NULL, NULL, '2016-12-10 08:32:45.545', '2016-12-10 10:32:17.629', 1, 73, true, 'Ramana', 1, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,NULL,'identification mark','default');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation, signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', '9999999999', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2020-12-31 00:00:00', '1234567890', NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, '999999999', NULL, NULL, NULL, 'CITIZEN', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','default');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'ravi', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', '1234567890', NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'ravi', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','default');
diff --git a/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170425163441__user_insert_user_role_data.sql b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170425163441__user_insert_user_role_data.sql
new file mode 100644
index 00000000000..5682cdabe98
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170425163441__user_insert_user_role_data.sql
@@ -0,0 +1,6 @@
+insert into eg_userrole values((select id from eg_role where name='Employee'),(select id from eg_user where username='narasappa'));
+insert into eg_userrole values((select id from eg_role where name='Employee'),(select id from eg_user where username='manas'));
+insert into eg_userrole values((select id from eg_role where name='Employee'),(select id from eg_user where username='ramana'));
+insert into eg_userrole values((select id from eg_role where name='Citizen'),(select id from eg_user where username='9999999999'));
+insert into eg_userrole values((select id from eg_role where name='Employee'),(select id from eg_user where username='ravi'));
+insert into eg_userrole values((select id from eg_role where name='Grievance Routing Officer'),(select id from eg_user where username='ravi'));
diff --git a/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170509173136__insert_user_role_data_with_tenant_id.sql b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170509173136__insert_user_role_data_with_tenant_id.sql
new file mode 100644
index 00000000000..dafb323a5e5
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170509173136__insert_user_role_data_with_tenant_id.sql
@@ -0,0 +1,30 @@
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Employee' and tenantid='default'),
+(select id from eg_user where username='narasappa' and tenantid='default'),
+'default',
+'default');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Employee' and tenantid='default'),
+(select id from eg_user where username='manas' and tenantid='default'),
+'default',
+'default');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values((select id from eg_role where name='Employee' and tenantid='default'),
+(select id from eg_user where username='ramana' and tenantid='default'),
+'default',
+'default');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values((select id from eg_role where name='Citizen' and tenantid='default'),
+(select id from eg_user where username='9999999999' and tenantid='default'),
+'default',
+'default');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid) values
+((select id from eg_role where name='Employee' and tenantid='default'),
+(select id from eg_user where username='ravi' and tenantid='default'),
+'default',
+'default');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid) values(
+(select id from eg_role where name='Grievance Routing Officer' and tenantid='default'),
+(select id from eg_user where username='ravi' and tenantid='default'),
+'default',
+'default');
diff --git a/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170510143711__insert_user_role_redressal_officer.sql b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170510143711__insert_user_role_redressal_officer.sql
new file mode 100644
index 00000000000..c5fdd2794d5
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170510143711__insert_user_role_redressal_officer.sql
@@ -0,0 +1,5 @@
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Redressal Officer' and tenantid='default'),
+(select id from eg_user where username='narasappa' and tenantid='default'),
+'default',
+'default');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170511114218__insert_redressal_officer_role.sql b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170511114218__insert_redressal_officer_role.sql
new file mode 100644
index 00000000000..f4ba0d701ab
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170511114218__insert_redressal_officer_role.sql
@@ -0,0 +1,5 @@
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Redressal Officer' and tenantid='default'),
+(select id from eg_user where username='ravi' and tenantid='default'),
+'default',
+'default');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170517175914__insert_user_data.sql b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170517175914__insert_user_data.sql
new file mode 100644
index 00000000000..0e7d19fc1b9
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170517175914__insert_user_data.sql
@@ -0,0 +1,2 @@
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'mahaadmin', '$2a$10$ZpX0jsy.ZyZGtfSkV0wz9e5P1OubgKMZino396w.2kw2FCU3t1tYy', '2099-01-01 00:00:00', '1234567890', NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'admin', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','default');
diff --git a/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170517212937__insert_user_role_for_citizenservices.sql b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170517212937__insert_user_role_for_citizenservices.sql
new file mode 100644
index 00000000000..a7df5de8420
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170517212937__insert_user_role_for_citizenservices.sql
@@ -0,0 +1,4 @@
+insert into eg_userrole (roleid,roleidtenantid,userid,tenantid) values((select id from eg_role where name='Service request Creator'),'default',(select id from eg_user where username='mahaadmin'),'default');
+insert into eg_userrole (roleid,roleidtenantid,userid,tenantid) values((select id from eg_role where name='Service request administrator'),'default',(select id from eg_user where username='mahaadmin'),'default');
+insert into eg_userrole (roleid,roleidtenantid,userid,tenantid) values((select id from eg_role where name='Service request status update'),'default',(select id from eg_user where username='mahaadmin'),'default');
+insert into eg_userrole (roleid,roleidtenantid,userid,tenantid) values((select id from eg_role where name='Service request Report viewer'),'default',(select id from eg_user where username='mahaadmin'),'default');
diff --git a/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170525144823__insert_servicerequest_creator.sql b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170525144823__insert_servicerequest_creator.sql
new file mode 100644
index 00000000000..2975fa02349
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170525144823__insert_servicerequest_creator.sql
@@ -0,0 +1,5 @@
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Service request Creator' and tenantid='default'),
+(select id from eg_user where username='narasappa' and tenantid='default'),
+'default',
+'default');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170529191439__user_initial_data_panavel.sql b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170529191439__user_initial_data_panavel.sql
new file mode 100644
index 00000000000..aef9f26d9b0
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170529191439__user_initial_data_panavel.sql
@@ -0,0 +1,50 @@
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'admin', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', '1234567890', NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'admin', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','panavel');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'sanjeev', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', '1234567890', NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'sanjeev', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','panavel');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation, signature, bloodgroup,accountlocked,photo,identificationmark, tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'ajay', '$2a$10$/pAdOFmv9h7jrnm2zkEQjOKnWO9/xt8T0t.gkT7rb7t4ugz7QUEPi', '2017-03-10 10:32:17.627', '0123456789', NULL, NULL, '2016-12-10 08:32:45.545', '2016-12-10 10:32:17.629', 1, 73, true, 'ajay', 1, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,NULL,'identification mark','panavel');
+
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen','CITIZEN','Citizen who can raise complaint',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Super User','SUPERUSER','System Administrator. Can change all master data and has access to all the system screens.',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Officer','GO','Heads the grivance cell. Also all complaints that cannot be routed based on the rules are routed to Grievance Officer.',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Redressal Officer','RO','Employees that address citizens grievances.',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grivance Administrator','GA','System Administator for PGR. Can change PGR Master data only.',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Routing Officer','GRO','Grievance Routing Officer',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Service request Creator','SRC','Service request Creator',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Service request administrator','SRA','Service request administrator',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Service request status update','SRSU','Service request status update',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Service request Report viewer','SRV','Service request Report viewer',now(),1,1,now(),0,'panavel');
+
+
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Employee' and tenantid='panavel'),
+(select id from eg_user where username='admin' and tenantid='panavel'),'panavel','panavel');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Employee' and tenantid='panavel'),
+(select id from eg_user where username='ajay' and tenantid='panavel'),'panavel','panavel');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values((select id from eg_role where name='Citizen' and tenantid='panavel'),
+(select id from eg_user where username='sanjeev' and tenantid='panavel'),'panavel','panavel');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values((select id from eg_role where name='Grievance Routing Officer' and tenantid='panavel'),
+(select id from eg_user where username='ajay' and tenantid='panavel'),'panavel','panavel');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Redressal Officer' and tenantid='panavel'),
+(select id from eg_user where username='admin' and tenantid='panavel'),'panavel','panavel');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Service request Creator' and tenantid='panavel'),
+(select id from eg_user where username='ajay' and tenantid='panavel'),'panavel','panavel');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170530134617__users_data_panavel.sql b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170530134617__users_data_panavel.sql
new file mode 100644
index 00000000000..fe35ac88cce
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170530134617__users_data_panavel.sql
@@ -0,0 +1,22 @@
+update eg_user set type = 'CITIZEN' where username = 'sanjeev' and tenantid = 'panavel';
+
+
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', 'Mrs', '1990-07-23 00:00:00', 'en_IN', 'anonymous', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK',
+'2020-12-31 00:00:00', '1234567890', '9876543210', 'anonymous@gmail.com', '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true,
+'Anonymous', 2, 'ABCDE1234F', '12346789011', 'SYSTEM', 0, 'Guardian name', 'Mother',
+'0fef5a6f-fb86-493d-9ecf-8f4b37fa498c', 'AB_POSITIVE', '54fc046d-12be-4733-b88c-cf7c06402980', 'identificationmark','panavel');
+
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', 'Mrs', '1990-07-23 00:00:00', 'en_IN', 'system', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK',
+'2020-12-31 00:00:00', '0000000000', '0000000000', 'system@gmail.com', '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true,
+'System', 2, 'ABCDE1234F', '12346789011', 'SYSTEM', 0, 'Guardian name', 'Mother',
+'0fef5a6f-fb86-493d-9ecf-8f4b37fa498c', 'AB_POSITIVE', '54fc046d-12be-4733-b88c-cf7c06402980', 'identificationmark','panavel');
diff --git a/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170530150635__update_password_panavel.sql b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170530150635__update_password_panavel.sql
new file mode 100644
index 00000000000..afa5be1b0a4
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170530150635__update_password_panavel.sql
@@ -0,0 +1 @@
+update eg_user set password = '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK' where username = 'ajay' and tenantid = 'panavel';
diff --git a/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170530192632__user_role_panavel.sql b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170530192632__user_role_panavel.sql
new file mode 100644
index 00000000000..ab1349b5633
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170530192632__user_role_panavel.sql
@@ -0,0 +1,3 @@
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Service request Creator' and tenantid='panavel'),
+(select id from eg_user where username='admin' and tenantid='panavel'),'panavel','panavel');
diff --git a/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170717145752__user_role_data.sql b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170717145752__user_role_data.sql
new file mode 100644
index 00000000000..1bc361480a3
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170717145752__user_role_data.sql
@@ -0,0 +1,40 @@
+delete from eg_userrole where userid = (select id from eg_user where username = 'narasappa') and
+tenantid = 'default' and roleidtenantid = 'default';
+
+delete from eg_userrole where userid = (select id from eg_user where username = 'ramana') and
+tenantid = 'default' and roleidtenantid = 'default';
+
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Employee' and tenantid='default'),
+(select id from eg_user where username='narasappa' and tenantid='default'),
+'default','default');
+
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Redressal Officer' and tenantid='default'),
+(select id from eg_user where username='narasappa' and tenantid='default'),
+'default','default');
+
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Service request Creator' and tenantid='default'),
+(select id from eg_user where username='narasappa' and tenantid='default'),
+'default','default');
+
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Grievance Officer' and tenantid='default'),
+(select id from eg_user where username='narasappa' and tenantid='default'),
+'default','default');
+
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Grivance Administrator' and tenantid='default'),
+(select id from eg_user where username='narasappa' and tenantid='default'),
+'default','default');
+
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Employee' and tenantid='default'),
+(select id from eg_user where username='ramana' and tenantid='default'),
+'default','default');
+
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Redressal Officer' and tenantid='default'),
+(select id from eg_user where username='ramana' and tenantid='default'),
+'default','default');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170804150924__user_role_data_for_panavel_user.sql b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170804150924__user_role_data_for_panavel_user.sql
new file mode 100644
index 00000000000..d11c4d4948b
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/dev2/V20170804150924__user_role_data_for_panavel_user.sql
@@ -0,0 +1 @@
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid, lastmodifieddate) values( (select id from eg_role where code='SUPERUSER' and tenantid='panavel'), (select id from eg_user where username='ajay' and tenantid='panavel'), 'panavel','panavel', now());
\ No newline at end of file
diff --git a/frontend/mono-ui/web/rainmaker/dev-packages/egov-inbox-dev/src/index.scss b/core-services/egov-user/src/main/resources/db2/migration/qa/V20170425163119__user_insert_users.sql
similarity index 100%
rename from frontend/mono-ui/web/rainmaker/dev-packages/egov-inbox-dev/src/index.scss
rename to core-services/egov-user/src/main/resources/db2/migration/qa/V20170425163119__user_insert_users.sql
diff --git a/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170425163119__user_insert_users.sql b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170425163119__user_insert_users.sql
new file mode 100644
index 00000000000..ca4c084e30b
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170425163119__user_insert_users.sql
@@ -0,0 +1,10 @@
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'narasappa', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', '1234567890', NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'narasappa', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','default');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'manas', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', '1234567890', NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'manas', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','default');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation, signature, bloodgroup,accountlocked,photo,identificationmark, tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'ramana', '$2a$10$/pAdOFmv9h7jrnm2zkEQjOKnWO9/xt8T0t.gkT7rb7t4ugz7QUEPi', '2017-03-10 10:32:17.627', '0123456789', NULL, NULL, '2016-12-10 08:32:45.545', '2016-12-10 10:32:17.629', 1, 73, true, 'Ramana', 1, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,NULL,'identification mark','default');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation, signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', '9999999999', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2020-12-31 00:00:00', '1234567890', NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, '999999999', NULL, NULL, NULL, 'CITIZEN', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','default');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'ravi', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', '1234567890', NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'ravi', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','default');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170425163441__user_insert_user_role_data.sql b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170425163441__user_insert_user_role_data.sql
new file mode 100644
index 00000000000..5682cdabe98
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170425163441__user_insert_user_role_data.sql
@@ -0,0 +1,6 @@
+insert into eg_userrole values((select id from eg_role where name='Employee'),(select id from eg_user where username='narasappa'));
+insert into eg_userrole values((select id from eg_role where name='Employee'),(select id from eg_user where username='manas'));
+insert into eg_userrole values((select id from eg_role where name='Employee'),(select id from eg_user where username='ramana'));
+insert into eg_userrole values((select id from eg_role where name='Citizen'),(select id from eg_user where username='9999999999'));
+insert into eg_userrole values((select id from eg_role where name='Employee'),(select id from eg_user where username='ravi'));
+insert into eg_userrole values((select id from eg_role where name='Grievance Routing Officer'),(select id from eg_user where username='ravi'));
diff --git a/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170509173136__insert_user_role_data_with_tenant_id.sql b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170509173136__insert_user_role_data_with_tenant_id.sql
new file mode 100644
index 00000000000..dafb323a5e5
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170509173136__insert_user_role_data_with_tenant_id.sql
@@ -0,0 +1,30 @@
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Employee' and tenantid='default'),
+(select id from eg_user where username='narasappa' and tenantid='default'),
+'default',
+'default');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Employee' and tenantid='default'),
+(select id from eg_user where username='manas' and tenantid='default'),
+'default',
+'default');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values((select id from eg_role where name='Employee' and tenantid='default'),
+(select id from eg_user where username='ramana' and tenantid='default'),
+'default',
+'default');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values((select id from eg_role where name='Citizen' and tenantid='default'),
+(select id from eg_user where username='9999999999' and tenantid='default'),
+'default',
+'default');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid) values
+((select id from eg_role where name='Employee' and tenantid='default'),
+(select id from eg_user where username='ravi' and tenantid='default'),
+'default',
+'default');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid) values(
+(select id from eg_role where name='Grievance Routing Officer' and tenantid='default'),
+(select id from eg_user where username='ravi' and tenantid='default'),
+'default',
+'default');
diff --git a/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170510143711__insert_user_role_redressal_officer.sql b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170510143711__insert_user_role_redressal_officer.sql
new file mode 100644
index 00000000000..c5fdd2794d5
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170510143711__insert_user_role_redressal_officer.sql
@@ -0,0 +1,5 @@
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Redressal Officer' and tenantid='default'),
+(select id from eg_user where username='narasappa' and tenantid='default'),
+'default',
+'default');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170511114218__insert_redressal_officer_role.sql b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170511114218__insert_redressal_officer_role.sql
new file mode 100644
index 00000000000..f4ba0d701ab
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170511114218__insert_redressal_officer_role.sql
@@ -0,0 +1,5 @@
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Redressal Officer' and tenantid='default'),
+(select id from eg_user where username='ravi' and tenantid='default'),
+'default',
+'default');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170525144823__insert_servicerequest_creator.sql b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170525144823__insert_servicerequest_creator.sql
new file mode 100644
index 00000000000..2975fa02349
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170525144823__insert_servicerequest_creator.sql
@@ -0,0 +1,5 @@
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Service request Creator' and tenantid='default'),
+(select id from eg_user where username='narasappa' and tenantid='default'),
+'default',
+'default');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170529191439__user_initial_data_panavel.sql b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170529191439__user_initial_data_panavel.sql
new file mode 100644
index 00000000000..aef9f26d9b0
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170529191439__user_initial_data_panavel.sql
@@ -0,0 +1,50 @@
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'admin', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', '1234567890', NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'admin', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','panavel');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'sanjeev', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', '1234567890', NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'sanjeev', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','panavel');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation, signature, bloodgroup,accountlocked,photo,identificationmark, tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'ajay', '$2a$10$/pAdOFmv9h7jrnm2zkEQjOKnWO9/xt8T0t.gkT7rb7t4ugz7QUEPi', '2017-03-10 10:32:17.627', '0123456789', NULL, NULL, '2016-12-10 08:32:45.545', '2016-12-10 10:32:17.629', 1, 73, true, 'ajay', 1, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,NULL,'identification mark','panavel');
+
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen','CITIZEN','Citizen who can raise complaint',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Super User','SUPERUSER','System Administrator. Can change all master data and has access to all the system screens.',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Officer','GO','Heads the grivance cell. Also all complaints that cannot be routed based on the rules are routed to Grievance Officer.',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Redressal Officer','RO','Employees that address citizens grievances.',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grivance Administrator','GA','System Administator for PGR. Can change PGR Master data only.',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Routing Officer','GRO','Grievance Routing Officer',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Service request Creator','SRC','Service request Creator',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Service request administrator','SRA','Service request administrator',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Service request status update','SRSU','Service request status update',now(),1,1,now(),0,'panavel');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Service request Report viewer','SRV','Service request Report viewer',now(),1,1,now(),0,'panavel');
+
+
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Employee' and tenantid='panavel'),
+(select id from eg_user where username='admin' and tenantid='panavel'),'panavel','panavel');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Employee' and tenantid='panavel'),
+(select id from eg_user where username='ajay' and tenantid='panavel'),'panavel','panavel');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values((select id from eg_role where name='Citizen' and tenantid='panavel'),
+(select id from eg_user where username='sanjeev' and tenantid='panavel'),'panavel','panavel');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values((select id from eg_role where name='Grievance Routing Officer' and tenantid='panavel'),
+(select id from eg_user where username='ajay' and tenantid='panavel'),'panavel','panavel');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Redressal Officer' and tenantid='panavel'),
+(select id from eg_user where username='admin' and tenantid='panavel'),'panavel','panavel');
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Service request Creator' and tenantid='panavel'),
+(select id from eg_user where username='ajay' and tenantid='panavel'),'panavel','panavel');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170530134617__users_data_panavel.sql b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170530134617__users_data_panavel.sql
new file mode 100644
index 00000000000..fe35ac88cce
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170530134617__users_data_panavel.sql
@@ -0,0 +1,22 @@
+update eg_user set type = 'CITIZEN' where username = 'sanjeev' and tenantid = 'panavel';
+
+
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', 'Mrs', '1990-07-23 00:00:00', 'en_IN', 'anonymous', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK',
+'2020-12-31 00:00:00', '1234567890', '9876543210', 'anonymous@gmail.com', '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true,
+'Anonymous', 2, 'ABCDE1234F', '12346789011', 'SYSTEM', 0, 'Guardian name', 'Mother',
+'0fef5a6f-fb86-493d-9ecf-8f4b37fa498c', 'AB_POSITIVE', '54fc046d-12be-4733-b88c-cf7c06402980', 'identificationmark','panavel');
+
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', 'Mrs', '1990-07-23 00:00:00', 'en_IN', 'system', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK',
+'2020-12-31 00:00:00', '0000000000', '0000000000', 'system@gmail.com', '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true,
+'System', 2, 'ABCDE1234F', '12346789011', 'SYSTEM', 0, 'Guardian name', 'Mother',
+'0fef5a6f-fb86-493d-9ecf-8f4b37fa498c', 'AB_POSITIVE', '54fc046d-12be-4733-b88c-cf7c06402980', 'identificationmark','panavel');
diff --git a/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170530150635__update_password_panavel.sql b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170530150635__update_password_panavel.sql
new file mode 100644
index 00000000000..afa5be1b0a4
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170530150635__update_password_panavel.sql
@@ -0,0 +1 @@
+update eg_user set password = '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK' where username = 'ajay' and tenantid = 'panavel';
diff --git a/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170530192632__user_role_panavel.sql b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170530192632__user_role_panavel.sql
new file mode 100644
index 00000000000..ab1349b5633
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170530192632__user_role_panavel.sql
@@ -0,0 +1,3 @@
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Service request Creator' and tenantid='panavel'),
+(select id from eg_user where username='admin' and tenantid='panavel'),'panavel','panavel');
diff --git a/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170712115918__update_script_for_eguser_table.sql b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170712115918__update_script_for_eguser_table.sql
new file mode 100644
index 00000000000..b9510b2b162
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170712115918__update_script_for_eguser_table.sql
@@ -0,0 +1,2 @@
+update eg_user set mobilenumber= '9036544535' , emailid='akhilagd@gmail.com' where username='narasappa' and tenantid='default';
+
diff --git a/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170713171524__user_role_data.sql b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170713171524__user_role_data.sql
new file mode 100644
index 00000000000..fa5483627b1
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170713171524__user_role_data.sql
@@ -0,0 +1,14 @@
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Grievance Officer' and tenantid='default'),
+(select id from eg_user where username='narasappa' and tenantid='default'),
+'default','default');
+
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Grivance Administrator' and tenantid='default'),
+(select id from eg_user where username='narasappa' and tenantid='default'),
+'default','default');
+
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid)
+values( (select id from eg_role where name='Redressal Officer' and tenantid='default'),
+(select id from eg_user where username='ramana' and tenantid='default'),
+'default','default');
diff --git a/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170804150924__user_role_data_for_panavel_user.sql b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170804150924__user_role_data_for_panavel_user.sql
new file mode 100644
index 00000000000..d11c4d4948b
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170804150924__user_role_data_for_panavel_user.sql
@@ -0,0 +1 @@
+insert into eg_userrole (roleid, userid, roleidtenantid, tenantid, lastmodifieddate) values( (select id from eg_role where code='SUPERUSER' and tenantid='panavel'), (select id from eg_user where username='ajay' and tenantid='panavel'), 'panavel','panavel', now());
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170826161819__update_narasappa_user.sql b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170826161819__update_narasappa_user.sql
new file mode 100644
index 00000000000..37c926e1a7b
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20170826161819__update_narasappa_user.sql
@@ -0,0 +1 @@
+update eg_user set mobilenumber= '0123456789' , emailid=null where username='narasappa' and tenantid='default';
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/qa2/V20171229121210__role_insert_testtenantulb1.sql b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20171229121210__role_insert_testtenantulb1.sql
new file mode 100644
index 00000000000..466264f68c9
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/qa2/V20171229121210__role_insert_testtenantulb1.sql
@@ -0,0 +1,4 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'testtenant.ulb1');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Super User','SUPERUSER','System Administrator. Can change all master data and has access to all the system screens.',now(),1,1,now(),0,'testtenant.ulb1');
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed/V20170223151327__user_setup_data.sql b/core-services/egov-user/src/main/resources/db2/migration/seed/V20170223151327__user_setup_data.sql
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170223151327__user_setup_data.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170223151327__user_setup_data.sql
new file mode 100644
index 00000000000..bcb7ae85b0a
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170223151327__user_setup_data.sql
@@ -0,0 +1,70 @@
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', 'Mrs', '1990-07-23 00:00:00', 'en_IN', 'anonymous', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK',
+'2020-12-31 00:00:00', '1234567890', '9876543210', 'anonymous@gmail.com', '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true,
+'Anonymous', 2, 'ABCDE1234F', '12346789011', 'SYSTEM', 0, 'Guardian name', 'Mother',
+'0fef5a6f-fb86-493d-9ecf-8f4b37fa498c', 'AB_POSITIVE', '54fc046d-12be-4733-b88c-cf7c06402980', 'identificationmark','default');
+
+
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', 'Mrs', '1990-07-23 00:00:00', 'en_IN', 'system', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK',
+'2020-12-31 00:00:00', '0000000000', '0000000000', 'system@gmail.com', '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true,
+'System', 2, 'ABCDE1234F', '12346789011', 'SYSTEM', 0, 'Guardian name', 'Mother',
+'0fef5a6f-fb86-493d-9ecf-8f4b37fa498c', 'AB_POSITIVE', '54fc046d-12be-4733-b88c-cf7c06402980', 'identificationmark','default');
+
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', 'Mrs', '1990-07-23 00:00:00', 'en_IN', 'bigcat399', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK',
+'2020-12-31 00:00:00', '9731123456', '080292575', 'kay.alexander@example.com', '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true,
+'Kay Alexander', 0, 'ABCDE1234F', '12346789011', 'EMPLOYEE', 0, 'Guardian name', 'Father',
+'7a9d7f12-bdcb-4487-9d43-709838a0ad39', 'A_POSITIVE', '3b26fb49-e43d-401b-899a-f8f0a1572de0', 'identificationmark','ap.public');
+
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', 'Mrs', '1990-07-23 00:00:00', 'en_IN', 'greenfish424', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK',
+'2020-12-31 00:00:00', '9731123456', '080292575', 'ferdinand.douwes@example.com', '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true,
+'Ferdinand Douwes', 2, 'ABCDE1234F', '12346789011', 'CITIZEN', 0, 'Guardian name', 'Mother',
+'0fef5a6f-fb86-493d-9ecf-8f4b37fa498c', 'AB_POSITIVE', '54fc046d-12be-4733-b88c-cf7c06402980', 'identificationmark','ap.public');
+
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', 'Mrs', '1990-07-23 00:00:00', 'en_IN', 'tinymouse812', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK',
+'2020-12-31 00:00:00', '9731123456', '080292575', 'email3@gmail.com', '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true,
+'Raman', 1, 'ABCDE1234F', '12346789011', 'CITIZEN', 0, 'Guardian name', 'Mother',
+'0fef5a6f-fb86-493d-9ecf-8f4b37fa498c', 'AB_POSITIVE', '54fc046d-12be-4733-b88c-cf7c06402980', 'identificationmark','ap.public');
+
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', 'Mrs', '1990-07-23 00:00:00', 'en_IN', 'organicelephant552', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK',
+'2020-12-31 00:00:00', '9731123456', '080292575', 'email4@gmail.com', '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true,
+'Seetharam', 1, 'ABCDE1234F', '12346789011', 'CITIZEN', 0, 'Guardian name', 'Mother',
+'0fef5a6f-fb86-493d-9ecf-8f4b37fa498c', 'AB_POSITIVE', '54fc046d-12be-4733-b88c-cf7c06402980', 'identificationmark','ap.public');
+
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', 'Mrs', '1990-07-23 00:00:00', 'en_IN', 'ege.koyluoglu@example.com', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK',
+'2020-12-31 00:00:00', '9731123456', '080292575', 'email5@gmail.com', '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true,
+'Sreerama Krishnan', 1, 'ABCDE1234F', '12346789011', 'EMPLOYEE', 0, 'Guardian name', 'Mother',
+'0fef5a6f-fb86-493d-9ecf-8f4b37fa498c', 'AB_POSITIVE', '54fc046d-12be-4733-b88c-cf7c06402980', 'identificationmark','ap.public');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170223151350__address_setup_data.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170223151350__address_setup_data.sql
new file mode 100644
index 00000000000..2591598a0c4
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170223151350__address_setup_data.sql
@@ -0,0 +1,7 @@
+INSERT INTO eg_address(
+ housenobldgapt, subdistrict, postoffice, landmark, country, userid,
+ type, streetroadline, citytownvillage, arealocalitysector, district,
+ state, pincode, id, version,tenantid)
+ VALUES ('house no', 'sub district', 'post office', 'landmark', 'country', 1,
+ 'PERMANENT', 'street line', 'city town village', 'area locality sector', 'district',
+ 'state', '506034', 1, 0,'ap.public');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170404155010__insert_role_data.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170404155010__insert_role_data.sql
new file mode 100644
index 00000000000..07d7a133b49
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170404155010__insert_role_data.sql
@@ -0,0 +1,14 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen','CITIZEN','Citizen who can raise complaint',now(),1,1,now(),0,'ap.public');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'ap.public');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Super User','SUPERUSER','System Administrator. Can change all master data and has access to all the system screens.',now(),1,1,now(),0,'ap.public');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Officer','GO','Heads the grivance cell. Also all complaints that cannot be routed based on the rules are routed to Grievance Officer.',now(),1,1,now(),0,'ap.public');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Redressal Officer','RO','Employees that address citizens grievances.',now(),1,1,now(),0,'ap.public');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grivance Administrator','GA','System Administator for PGR. Can change PGR Master data only.',now(),1,1,now(),0,'ap.public');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Routing Officer','GRO','Grievance Routing Officer',now(),1,1,now(),0,'ap.public');
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170405171456__user_initial_data.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170405171456__user_initial_data.sql
new file mode 100644
index 00000000000..fd1d5172418
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170405171456__user_initial_data.sql
@@ -0,0 +1,195 @@
+-----------------START-------------------
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'gayathri', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'gayathri', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'manas', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'manas', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'narasappa', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'narasappa', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'krishna', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'krishna', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'elzan', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'elzan', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'girish', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'girish', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'iffath', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'iffath', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'nirbhay', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'nirbhay', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'prk', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'prk', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'pradeep', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'pradeep', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'rajashree', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'rajashree', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'ramakrishna', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'ramakrishna', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'manikanta', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'manikanta', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'rishi', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'rishi', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'sathish', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'sathish', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'mohanraj', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'mohanraj', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'sankar', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'sankar', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'vaibhav', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'vaibhav', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'rajkumar', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'rajkumar', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'jayashree', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'jayashree', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'subhash', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'subhash', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'nayeemalla', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'nayeemalla', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'deepa', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'deepa', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'suresh', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'suresh', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'malathi', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'malathi', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'surya', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'surya ', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'satish', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'satish', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'satyam', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'satyam', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'shahid', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'shahid', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'sathyandra', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'sathyandra', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'syed', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'syed', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'seema', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'seema', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'roopa', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'roopa', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'parvati', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'parvati', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'manasa', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'manasa', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'makaraju', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'makaraju', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'arun', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'arun', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'venkataramana', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'venkataramana', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'mahesh', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'mahesh', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'chandrashekar', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'chandrashekar', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'gireesh', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'gireesh', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'jitha', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'jitha', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'vijay', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'vijay', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'evlyn', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'evlyn', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'pramod', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'pramod', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'vasanth', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'vasanth', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'julian', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'julian', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'gauthami', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'gauthami', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'chetan', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'chetan', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'vikas', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'vikas', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'akash', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'akash', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'shamili', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'shamili', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'mussavir', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'mussavir', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'phanindra', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'phanindra', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'neetu', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'neetu', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'tilak', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'tilak', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'prabhu', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'prabhu', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'suhail', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'suhail', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'venkatesh', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'venkatesh', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'ramandeep ', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'ramandeep ', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'sumit', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'sumit', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'ravi', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'ravi', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', 'dharmendra', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2099-01-01 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, 'dharmendra', NULL, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation, signature, bloodgroup, photo, identificationmark ,tenantid)
+VALUES (nextval('seq_eg_user'), NULL, NULL, NULL, 'en_IN', '9999999999', '$2a$10$uheIOutTnD33x7CDqac1zOL8DMiuz7mWplToPgcf7oxAI9OzRKxmK', '2020-12-31 00:00:00', NULL, NULL, NULL, '2010-01-01 00:00:00', '2015-01-01 00:00:00', 1, 1, true, '999999999', NULL, NULL, NULL, 'CITIZEN', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,'identification mark','ap.public');
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation, signature, bloodgroup,accountlocked,photo,identificationmark, tenantid)
+VALUES (156, NULL, 'MR.', NULL, 'en_IN', 'ramana', '$2a$10$/pAdOFmv9h7jrnm2zkEQjOKnWO9/xt8T0t.gkT7rb7t4ugz7QUEPi', '2017-03-10 10:32:17.627', '0123456789', NULL, NULL, '2016-12-10 08:32:45.545', '2016-12-10 10:32:17.629', 1, 73, true, 'Ramana', 1, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,NULL,'identification mark','ap.public');
+------------------END---------------------
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170406125044__insert_user_role_data.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170406125044__insert_user_role_data.sql
new file mode 100644
index 00000000000..5682cdabe98
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170406125044__insert_user_role_data.sql
@@ -0,0 +1,6 @@
+insert into eg_userrole values((select id from eg_role where name='Employee'),(select id from eg_user where username='narasappa'));
+insert into eg_userrole values((select id from eg_role where name='Employee'),(select id from eg_user where username='manas'));
+insert into eg_userrole values((select id from eg_role where name='Employee'),(select id from eg_user where username='ramana'));
+insert into eg_userrole values((select id from eg_role where name='Citizen'),(select id from eg_user where username='9999999999'));
+insert into eg_userrole values((select id from eg_role where name='Employee'),(select id from eg_user where username='ravi'));
+insert into eg_userrole values((select id from eg_role where name='Grievance Routing Officer'),(select id from eg_user where username='ravi'));
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170414120251__hr_employee_insert_employeeadmin_role.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170414120251__hr_employee_insert_employeeadmin_role.sql
new file mode 100644
index 00000000000..522993369dd
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170414120251__hr_employee_insert_employeeadmin_role.sql
@@ -0,0 +1,2 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee Admin','EMPLOYEE ADMIN','Employee Administrator',now(),1,1,now(),0,'ap.public');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170419162007__alter_user_mobile_number.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170419162007__alter_user_mobile_number.sql
new file mode 100644
index 00000000000..d1e3b83bf02
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170419162007__alter_user_mobile_number.sql
@@ -0,0 +1 @@
+UPDATE eg_user set mobilenumber='1234567890' where mobilenumber is null;
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170419163013__user_delete_add_user.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170419163013__user_delete_add_user.sql
new file mode 100644
index 00000000000..53ce8e39bbc
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170419163013__user_delete_add_user.sql
@@ -0,0 +1,8 @@
+DELETE from eg_userrole where userid in(select id from eg_user where username='ramana');
+
+DELETE from eg_user where username='ramana';
+
+INSERT INTO eg_user (id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate, lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation, signature, bloodgroup,accountlocked,photo,identificationmark, tenantid)
+VALUES (nextval('seq_eg_user'), NULL, 'MR.', NULL, 'en_IN', 'ramana', '$2a$10$/pAdOFmv9h7jrnm2zkEQjOKnWO9/xt8T0t.gkT7rb7t4ugz7QUEPi', '2017-03-10 10:32:17.627', '0123456789', NULL, NULL, '2016-12-10 08:32:45.545', '2016-12-10 10:32:17.629', 1, 73, true, 'Ramana', 1, NULL, NULL, 'EMPLOYEE', 0, NULL, NULL, NULL, 'AB_POSITIVE', NULL,NULL,'identification mark','ap.public');
+
+insert into eg_userrole values((select id from eg_role where name='Employee'),(select id from eg_user where username='ramana'));
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170420160504__lams_roles.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170420160504__lams_roles.sql
new file mode 100644
index 00000000000..8453ae92006
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170420160504__lams_roles.sql
@@ -0,0 +1,8 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'ULB Operator','ULB Operator','City Official',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Property Verifier','Property Verifier','One who do field survey and verified the data entered by ULB Operator',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Property Approver','Property Approver','One who approves the record finally',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Asset Administrator','Asset Administrator','One who manages the Asset Master data',now(),1,1,now(),0,'default');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170425134613__user_delete_initial_data.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170425134613__user_delete_initial_data.sql
new file mode 100644
index 00000000000..f7fc7a4115e
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170425134613__user_delete_initial_data.sql
@@ -0,0 +1,77 @@
+delete from eg_userrole where userid = (select id from eg_user where username='narasappa');
+delete from eg_userrole where userid = (select id from eg_user where username='manas');
+delete from eg_userrole where userid = (select id from eg_user where username='ramana');
+delete from eg_userrole where userid = (select id from eg_user where username='9999999999');
+delete from eg_userrole where userid = (select id from eg_user where username='ravi');
+
+delete from eg_user where username = 'greenfish424';
+delete from eg_user where username = 'tinymouse812';
+delete from eg_user where username = 'gayathri';
+delete from eg_user where username = 'organicelephant552';
+delete from eg_user where username = 'ege.koyluoglu@example.com';
+delete from eg_user where username = 'manas';
+delete from eg_user where username = 'narasappa';
+delete from eg_user where username = 'krishna';
+delete from eg_user where username = 'elzan';
+delete from eg_user where username = 'girish';
+delete from eg_user where username = 'iffath';
+delete from eg_user where username = 'nirbhay';
+delete from eg_user where username = 'prk';
+delete from eg_user where username = 'pradeep';
+delete from eg_user where username = 'rajashree';
+delete from eg_user where username = 'ramakrishna';
+delete from eg_user where username = 'manikanta';
+delete from eg_user where username = 'rishi';
+delete from eg_user where username = 'sathish';
+delete from eg_user where username = 'mohanraj';
+delete from eg_user where username = 'sankar';
+delete from eg_user where username = 'vaibhav';
+delete from eg_user where username = 'rajkumar';
+delete from eg_user where username = 'jayashree';
+delete from eg_user where username = 'subhash';
+delete from eg_user where username = 'nayeemalla';
+delete from eg_user where username = 'deepa';
+delete from eg_user where username = 'suresh';
+delete from eg_user where username = 'malathi';
+delete from eg_user where username = 'surya';
+delete from eg_user where username = 'satish';
+delete from eg_user where username = 'satyam';
+delete from eg_user where username = 'shahid';
+delete from eg_user where username = 'sathyandra';
+delete from eg_user where username = 'syed';
+delete from eg_user where username = 'seema';
+delete from eg_user where username = 'roopa';
+delete from eg_user where username = 'parvati';
+delete from eg_user where username = 'manasa';
+delete from eg_user where username = 'makaraju';
+delete from eg_user where username = 'arun';
+delete from eg_user where username = 'venkataramana';
+delete from eg_user where username = 'mahesh';
+delete from eg_user where username = 'chandrashekar';
+delete from eg_user where username = 'gireesh';
+delete from eg_user where username = 'jitha';
+delete from eg_user where username = 'vijay';
+delete from eg_user where username = 'evlyn';
+delete from eg_user where username = 'pramod';
+delete from eg_user where username = 'vasanth';
+delete from eg_user where username = 'julian';
+delete from eg_user where username = 'gauthami';
+delete from eg_user where username = 'chetan';
+delete from eg_user where username = 'vikas';
+delete from eg_user where username = 'akash';
+delete from eg_user where username = 'shamili';
+delete from eg_user where username = 'mussavir';
+delete from eg_user where username = 'phanindra';
+delete from eg_user where username = 'neetu';
+delete from eg_user where username = 'tilak';
+delete from eg_user where username = 'prabhu';
+delete from eg_user where username = 'suhail';
+delete from eg_user where username = 'venkatesh';
+delete from eg_user where username = 'ramandeep';
+delete from eg_user where username = 'sumit';
+delete from eg_user where username = 'ravi';
+delete from eg_user where username = 'dharmendra';
+delete from eg_user where username = '9999999999';
+delete from eg_user where username = 'ramana';
+delete from eg_user where username = 'ramandeep ';
+delete from eg_user where username = 'bigcat399';
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170427110043__user_set_default_tenant_and_mobilenumber.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170427110043__user_set_default_tenant_and_mobilenumber.sql
new file mode 100644
index 00000000000..d928c84613e
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170427110043__user_set_default_tenant_and_mobilenumber.sql
@@ -0,0 +1,7 @@
+update eg_role set tenantid = 'default' where tenantid = 'ap.public' and code not in('CITIZEN','EMPLOYEE','SUPERUSER','EMPLOYEE ADMIN');
+
+delete from eg_address where id = 1;
+UPDATE eg_user set mobilenumber='1234567890' where mobilenumber is null;
+
+ALTER TABLE eg_user ALTER COLUMN mobilenumber SET NOT NULL;
+
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170503192010__update_role_data.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170503192010__update_role_data.sql
new file mode 100644
index 00000000000..c58f198cfb6
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170503192010__update_role_data.sql
@@ -0,0 +1,2 @@
+
+update eg_role set tenantid='default' where tenantid='ap.public';
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170508144639__asset_creator_role.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170508144639__asset_creator_role.sql
new file mode 100644
index 00000000000..43f8e286b9b
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170508144639__asset_creator_role.sql
@@ -0,0 +1,3 @@
+INSERT INTO EG_ROLE (ID,NAME,DESCRIPTION,CREATEDDATE,CREATEDBY,LASTMODIFIEDBY,LASTMODIFIEDDATE,VERSION,CODE,TENANTID) values(nextval('seq_eg_role'),'Asset Creator','Creator of Assets',now(),1,1,now(),0,'AssetCreator','default');
+
+--rollback delete from eg_role where name like 'Asset Creator' and tenantid = 'default';
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170517102938__insert_role_for_citizen_services.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170517102938__insert_role_for_citizen_services.sql
new file mode 100644
index 00000000000..efd5e2da7e4
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170517102938__insert_role_for_citizen_services.sql
@@ -0,0 +1,9 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Service request Creator','SRC','Service request Creator',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Service request administrator','SRA','Service request administrator',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Service request status update','SRSU','Service request status update',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Service request Report viewer','SRV','Service request Report viewer',now(),1,1,now(),0,'default');
+
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170609115303__asset_assetreport_viewer_role.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170609115303__asset_assetreport_viewer_role.sql
new file mode 100644
index 00000000000..c7851802b67
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170609115303__asset_assetreport_viewer_role.sql
@@ -0,0 +1,5 @@
+INSERT INTO EG_ROLE (ID,NAME,DESCRIPTION,CREATEDDATE,CREATEDBY,LASTMODIFIEDBY,LASTMODIFIEDDATE,
+ VERSION,CODE,TENANTID) values(nextval('seq_eg_role'),'Asset Report Viewer',
+ 'Viewer of Assets Reports',now(),1,1,now(),0,'AssetReportViewer','default');
+
+--rollback delete from eg_role where name = 'Asset Report Viewer' and tenantid = 'default';
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170804185200__tl_tladmin_role.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170804185200__tl_tladmin_role.sql
new file mode 100644
index 00000000000..f5359fc9868
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170804185200__tl_tladmin_role.sql
@@ -0,0 +1,5 @@
+INSERT INTO EG_ROLE (ID,NAME,DESCRIPTION,CREATEDDATE,CREATEDBY,LASTMODIFIEDBY,LASTMODIFIEDDATE, VERSION,CODE,TENANTID)
+values(nextval('seq_eg_role'),'TL Admin','Who has a access to Trade License Masters',now(),1,1,now(),0,'TL_ADMIN','default');
+
+
+--rollback delete from eg_role where name = 'TL Admin' and tenantid = 'default';
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170829142108__collection_role_collectionoperator.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170829142108__collection_role_collectionoperator.sql
new file mode 100644
index 00000000000..74e6437a95a
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170829142108__collection_role_collectionoperator.sql
@@ -0,0 +1,10 @@
+INSERT INTO EG_ROLE (ID,NAME,DESCRIPTION,CREATEDDATE,CREATEDBY,LASTMODIFIEDBY,LASTMODIFIEDDATE, VERSION,CODE,TENANTID)
+values(nextval('seq_eg_role'),'Collection Operator','Can Create, Search and Update Receipt',now(),1,1,now(),0,'COLL_OPERATOR','default');
+
+INSERT INTO EG_ROLE (ID,NAME,DESCRIPTION,CREATEDDATE,CREATEDBY,LASTMODIFIEDBY,LASTMODIFIEDDATE, VERSION,CODE,TENANTID)
+values(nextval('seq_eg_role'),'Bank Collection Operator','Can Create, Search Receipt',now(),1,1,now(),0,'BANK_COLL_OPERATOR','default');
+
+INSERT INTO EG_ROLE (ID,NAME,DESCRIPTION,CREATEDDATE,CREATEDBY,LASTMODIFIEDBY,LASTMODIFIEDDATE, VERSION,CODE,TENANTID)
+values(nextval('seq_eg_role'),'CSC Collection Operator','Can Create, Search Receipt',now(),1,1,now(),0,'CSC_COLL_OPERATOR','default');
+
+
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170829175200__tl_tlcreator_role.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170829175200__tl_tlcreator_role.sql
new file mode 100644
index 00000000000..29d95decd25
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170829175200__tl_tlcreator_role.sql
@@ -0,0 +1,5 @@
+INSERT INTO EG_ROLE (ID,NAME,DESCRIPTION,CREATEDDATE,CREATEDBY,LASTMODIFIEDBY,LASTMODIFIEDDATE, VERSION,CODE,TENANTID)
+values(nextval('seq_eg_role'),'TL Creator','Who has a access to Trade License Transactions',now(),1,1,now(),0,'TL_CREATOR','default');
+
+
+--rollback delete from eg_role where name = 'TL_CREATOR' and tenantid = 'default';
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170831132404__egcl_legacy_receipt_creator_role.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170831132404__egcl_legacy_receipt_creator_role.sql
new file mode 100644
index 00000000000..37c97844220
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170831132404__egcl_legacy_receipt_creator_role.sql
@@ -0,0 +1,2 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Legacy Receipt Creator','LEGACY_RECEIPT_CREATOR','Legacy Receipt Creator',now(),1,1,now(),0,'default');
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170912164800__tl_tlapprover_role.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170912164800__tl_tlapprover_role.sql
new file mode 100644
index 00000000000..bdd4aa81f16
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170912164800__tl_tlapprover_role.sql
@@ -0,0 +1,4 @@
+INSERT INTO EG_ROLE (ID,NAME,DESCRIPTION,CREATEDDATE,CREATEDBY,LASTMODIFIEDBY,LASTMODIFIEDDATE, VERSION,CODE,TENANTID) values(nextval('seq_eg_role'),'TL Approver','Who has a access to Trade License Workflow',now(),1,1,now(),0,'TL_APPROVER','default');
+
+
+--rollback delete from eg_role where name = 'TL Approver' and tenantid = 'default';
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170913162108__collection_role_collectionreportviewer.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170913162108__collection_role_collectionreportviewer.sql
new file mode 100644
index 00000000000..0ffbad16d4d
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20170913162108__collection_role_collectionreportviewer.sql
@@ -0,0 +1,3 @@
+INSERT INTO EG_ROLE (ID,NAME,DESCRIPTION,CREATEDDATE,CREATEDBY,LASTMODIFIEDBY,LASTMODIFIEDDATE, VERSION,CODE,TENANTID)
+values(nextval('seq_eg_role'),'Collection Report Viewer','Collection Report Viewer can view Reports',now(),1,1,now(),0,'COLL_REP_VIEW','default');
+
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20171221115710__adding_new_role.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20171221115710__adding_new_role.sql
new file mode 100644
index 00000000000..67d2330caa1
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20171221115710__adding_new_role.sql
@@ -0,0 +1,11 @@
+INSERT INTO eg_role (name, code, description, createddate, createdby, tenantid, id)
+VALUES ('DMA Office Officer','DMA OFFICE OFFICER','Officer who supervises the ULBs performance', now(), 1, 'default', nextval('seq_eg_role'));
+
+INSERT INTO eg_role (name, code, description, createddate, createdby, tenantid, id)
+VALUES ('DMA Office Officer','DMA OFFICE OFFICER','Officer who supervises the ULBs performance', now(), 1, 'mh.rohatest', nextval('seq_eg_role'));
+
+INSERT INTO eg_role (name, code, description, createddate, createdby, tenantid, id)
+VALUES ('ULB Officer','ULB OFFICER','Officer at ULB Level', now(), 1, 'default', nextval('seq_eg_role'));
+
+INSERT INTO eg_role (name, code, description, createddate, createdby, tenantid, id)
+VALUES ('ULB Officer','ULB OFFICER','Officer at ULB Level', now(), 1, 'mh.rohatest', nextval('seq_eg_role'));
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20171221124638__adding_commissioner_role.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20171221124638__adding_commissioner_role.sql
new file mode 100644
index 00000000000..98999682c7f
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20171221124638__adding_commissioner_role.sql
@@ -0,0 +1,5 @@
+INSERT INTO eg_role (name, code, description, createddate, createdby, tenantid, id)
+VALUES ('Commissioner','COMMISSIONER','Commissioner', now(), 1, 'default', nextval('seq_eg_role'));
+
+INSERT INTO eg_role (name, code, description, createddate, createdby, tenantid, id)
+VALUES ('Commissioner','COMMISSIONER','Commissioner', now(), 1, 'mh.rohatest', nextval('seq_eg_role'));
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180104155010__insert_works_role_data.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180104155010__insert_works_role_data.sql
new file mode 100644
index 00000000000..0a00ce79c4a
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180104155010__insert_works_role_data.sql
@@ -0,0 +1,22 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Abstract Estimate Creator','AE_CREATOR','Who has a access to create Abstract Estimate',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Financials Approver','WORKS_FINANCIAL_APPROVER','Who has a access to capture Financial details and budgetary/financial sanction',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Detailed Estimate Creator','DE_CREATOR','Who has a access to create Detailed Estimate',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'LOA Creator','LOA_CREATOR','Who has a access to create Letter Of Acceptance',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'WO Creator','WO_CREATOR','Who has a access to create Work Order',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Works Bill Creator','WORKS_BILL_CREATOR','Who has a access to create Contractor Bill',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Contractor Advance creator','CONTRACTOR_ADVANCE_CREATOR','Who has a access to create Contractor Advance',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'MB creator','MB_CREATOR','Who has a access to create MB',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Works Approver','WORKS_APPROVER','Who has a access to approve/verify Works objects',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Works Administrator','WORKS_ADMINISTRATOR','Who has a access to all the transactions, masters and reports',now(),1,1,now(),0,'default');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Works Master creator','WORKS_MASTER_CREATOR','Who has a access to all the works masters.',now(),1,1,now(),0,'default');
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180330110224__roles_for_pb.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180330110224__roles_for_pb.sql
new file mode 100644
index 00000000000..f84c8ca2b71
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180330110224__roles_for_pb.sql
@@ -0,0 +1,34 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen','CITIZEN','Citizen who can raise complaint',now(),1,1,now(),0,'pb.amritsar');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'pb.amritsar');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Routing Officer','GRO','Grievance Routing Officer',now(),1,1,now(),0,'pb.amritsar');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen','CITIZEN','Citizen who can raise complaint',now(),1,1,now(),0,'pb.patiala');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'pb.patiala');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Routing Officer','GRO','Grievance Routing Officer',now(),1,1,now(),0,'pb.patiala');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen','CITIZEN','Citizen who can raise complaint',now(),1,1,now(),0,'pb.jalandhar');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'pb.jalandhar');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Routing Officer','GRO','Grievance Routing Officer',now(),1,1,now(),0,'pb.jalandhar');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen','CITIZEN','Citizen who can raise complaint',now(),1,1,now(),0,'pb.bathinda');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'pb.bathinda');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Routing Officer','GRO','Grievance Routing Officer',now(),1,1,now(),0,'pb.bathinda');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen','CITIZEN','Citizen who can raise complaint',now(),1,1,now(),0,'pb.hoshiarpur');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'pb.hoshiarpur');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Routing Officer','GRO','Grievance Routing Officer',now(),1,1,now(),0,'pb.hoshiarpur');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180619130525__role_csr_pb_dml.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180619130525__role_csr_pb_dml.sql
new file mode 100644
index 00000000000..27e9f6d0500
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180619130525__role_csr_pb_dml.sql
@@ -0,0 +1,14 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Customer Support Representative','CSR','Employee who files and follows up complaints on behalf of the citizen',now(),1,1,now(),0,'pb.amritsar');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Customer Support Representative','CSR','Employee who files and follows up complaints on behalf of the citizen',now(),1,1,now(),0,'pb.patiala');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Customer Support Representative','CSR','Employee who files and follows up complaints on behalf of the citizen',now(),1,1,now(),0,'pb.jalandhar');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Customer Support Representative','CSR','Employee who files and follows up complaints on behalf of the citizen',now(),1,1,now(),0,'pb.bathinda');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Customer Support Representative','CSR','Employee who files and follows up complaints on behalf of the citizen',now(),1,1,now(),0,'pb.hoshiarpur');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180709194344__role_pgradmin_update_csr_dml.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180709194344__role_pgradmin_update_csr_dml.sql
new file mode 100644
index 00000000000..146cba3844e
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180709194344__role_pgradmin_update_csr_dml.sql
@@ -0,0 +1,16 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'PGR Administrator','PGR-ADMIN','Admin role that has super access over the system',now(),1,1,now(),0,'pb.amritsar');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'PGR Administrator','PGR-ADMIN','Admin role that has super access over the system',now(),1,1,now(),0,'pb.patiala');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'PGR Administrator','PGR-ADMIN','Admin role that has super access over the system',now(),1,1,now(),0,'pb.jalandhar');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'PGR Administrator','PGR-ADMIN','Admin role that has super access over the system',now(),1,1,now(),0,'pb.bathinda');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'PGR Administrator','PGR-ADMIN','Admin role that has super access over the system',now(),1,1,now(),0,'pb.hoshiarpur');
+
+Update eg_role set name = 'Citizen Service Representative' where code = 'CSR' and tenantid LIKE 'pb%';
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180713164022__superuser_pb.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180713164022__superuser_pb.sql
new file mode 100644
index 00000000000..27cd5139ee6
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180713164022__superuser_pb.sql
@@ -0,0 +1,4 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Super User','SUPERUSER','System Administrator. Can change all master data and has access to all the system screens.',now(),1,1,now(),0,'pb.jalandhar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180725181512__eg_role_for_phagwara.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180725181512__eg_role_for_phagwara.sql
new file mode 100644
index 00000000000..94b9996ba5e
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180725181512__eg_role_for_phagwara.sql
@@ -0,0 +1,24 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen','CITIZEN','Citizen who can raise complaint',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Routing Officer','GRO','Grievance Routing Officer',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen Service Representative','CSR',
+'Employee who files and follows up complaints on behalf of the citizen',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'PGR Administrator','PGR-ADMIN','Admin role that has super access over the system',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Super User','SUPERUSER','System Administrator. Can change all master data and has access to all the system screens.',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180801122512__eg_role_citizen_pb.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180801122512__eg_role_citizen_pb.sql
new file mode 100644
index 00000000000..c411d6f71dc
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180801122512__eg_role_citizen_pb.sql
@@ -0,0 +1,3 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen','CITIZEN','Citizen who can raise complaint',now(),1,1,now(),0,'pb')
+ON CONFLICT (code, tenantid) DO NOTHING;
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180820193243__eg_role_for_pt_nawanshahr_dml.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180820193243__eg_role_for_pt_nawanshahr_dml.sql
new file mode 100644
index 00000000000..4dc797b597a
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180820193243__eg_role_for_pt_nawanshahr_dml.sql
@@ -0,0 +1,16 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Counter Employee','CEMP','Employee at the counter who performs assessment on behalf of citizen',now(),1,1,now(),0,'pb.nawanshahr')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Field Employee','FEMP','Employee on the field',now(),1,1,now(),0,'pb.nawanshahr')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'ULB Administrator','ULBADMIN','Admin role that as access over an ulb',now(),1,1,now(),0,'pb.nawanshahr')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'State Administrator','STADMIN',
+'Admin role that as access over a state',now(),1,1,now(),0,'pb.nawanshahr')
+ON CONFLICT (code, tenantid) DO NOTHING;
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180827021743__eg_role_for_financial_jalandhar.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180827021743__eg_role_for_financial_jalandhar.sql
new file mode 100644
index 00000000000..ae5648d8eee
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180827021743__eg_role_for_financial_jalandhar.sql
@@ -0,0 +1,7 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'EGF Bill Creator','EGF-BILL_CREATOR','Employee who creates Bills mainly expense bill',now(),1,1,now(),0,'pb.jalandhar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'EGF Bill Approver','EGF-BILL_APPROVER','Employee who takes part in Bills approval mainly expense bill',now(),1,1,now(),0,'pb.jalandhar')
+ON CONFLICT (code, tenantid) DO NOTHING;
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180925102410__eg_role_for_finance_jalandhar.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180925102410__eg_role_for_finance_jalandhar.sql
new file mode 100644
index 00000000000..a79e1228266
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180925102410__eg_role_for_finance_jalandhar.sql
@@ -0,0 +1,31 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Voucher Creator','EGF-VOUCHER_CREATOR','One who can create a voucher',now(),1,1,now(),0,'pb.jalandhar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Voucher Approver','EGF-VOUCHER_APPROVER','One who can approve a voucher',now(),1,1,now(),0,'pb.jalandhar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Payment Creator','EGF-PAYMENT_CREATOR','One who can create payment',now(),1,1,now(),0,'pb.jalandhar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Payment Approver','EGF-PAYMENT_APPROVER','One who can approve a payment',now(),1,1,now(),0,'pb.jalandhar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Master Admin','EGF-MASTER_ADMIN','One who is the administrator for all master data in Finance',now(),1,1,now(),0,'pb.jalandhar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Report View','EGF-REPORT_VIEW','One who has acess to all financial reports',now(),1,1,now(),0,'pb.jalandhar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Collections Receipt Creator','COLL_RECEIPT_CREATOR','One who can create and approve a receipt and receipt voucher',now(),1,1,now(),0,'pb.jalandhar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Collections Remitter','COLL_REMIT_TO_BANK','One who can remit the instruments to bank',now(),1,1,now(),0,'pb.jalandhar')
+ON CONFLICT (code, tenantid) DO NOTHING;
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180925102831__eg_role_for_finance_phagwara.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180925102831__eg_role_for_finance_phagwara.sql
new file mode 100644
index 00000000000..f796b7c54c7
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180925102831__eg_role_for_finance_phagwara.sql
@@ -0,0 +1,39 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'EGF Bill Creator','EGF-BILL_CREATOR','Employee who creates Bills mainly expense bill',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'EGF Bill Approver','EGF-BILL_APPROVER','Employee who takes part in Bills approval mainly expense bill',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Voucher Creator','EGF-VOUCHER_CREATOR','One who can create a voucher',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Voucher Approver','EGF-VOUCHER_APPROVER','One who can approve a voucher',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Payment Creator','EGF-PAYMENT_CREATOR','One who can create payment',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Payment Approver','EGF-PAYMENT_APPROVER','One who can approve a payment',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Master Admin','EGF-MASTER_ADMIN','One who is the administrator for all master data in Finance',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Report View','EGF-REPORT_VIEW','One who has acess to all financial reports',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Collections Receipt Creator','COLL_RECEIPT_CREATOR','One who can create and approve a receipt and receipt voucher',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Collections Remitter','COLL_REMIT_TO_BANK','One who can remit the instruments to bank',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180925103411__eg_role_for_financial_amritsar.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180925103411__eg_role_for_financial_amritsar.sql
new file mode 100644
index 00000000000..531d46c63dd
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180925103411__eg_role_for_financial_amritsar.sql
@@ -0,0 +1,43 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Super User','SUPERUSER','System Administrator. Can change all master data and has access to all the system screens.',now(),1,1,now(),0,'pb.amritsar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'EGF Bill Creator','EGF-BILL_CREATOR','Employee who creates Bills mainly expense bill',now(),1,1,now(),0,'pb.amritsar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'EGF Bill Approver','EGF-BILL_APPROVER','Employee who takes part in Bills approval mainly expense bill',now(),1,1,now(),0,'pb.amritsar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Voucher Creator','EGF-VOUCHER_CREATOR','One who can create a voucher',now(),1,1,now(),0,'pb.amritsar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Voucher Approver','EGF-VOUCHER_APPROVER','One who can approve a voucher',now(),1,1,now(),0,'pb.amritsar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Payment Creator','EGF-PAYMENT_CREATOR','One who can create payment',now(),1,1,now(),0,'pb.amritsar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Payment Approver','EGF-PAYMENT_APPROVER','One who can approve a payment',now(),1,1,now(),0,'pb.amritsar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Master Admin','EGF-MASTER_ADMIN','One who is the administrator for all master data in Finance',now(),1,1,now(),0,'pb.amritsar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Report View','EGF-REPORT_VIEW','One who has acess to all financial reports',now(),1,1,now(),0,'pb.amritsar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Collections Receipt Creator','COLL_RECEIPT_CREATOR','One who can create and approve a receipt and receipt voucher',now(),1,1,now(),0,'pb.amritsar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Collections Remitter','COLL_REMIT_TO_BANK','One who can remit the instruments to bank',now(),1,1,now(),0,'pb.amritsar')
+ON CONFLICT (code, tenantid) DO NOTHING;
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180927171820__sysintg_role_user.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180927171820__sysintg_role_user.sql
new file mode 100644
index 00000000000..30aa241f8be
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20180927171820__sysintg_role_user.sql
@@ -0,0 +1,31 @@
+ -- password is siwater123@
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', null, '1990-07-23 00:00:00', 'en_IN', 'SIWATER', '$2a$10$4e79gVHpe4zZHC6Xy/bWouZOVQaqwgrW5U6IdrhNVBmkbgXfBo8lm',
+'2025-12-31 00:00:00', null, null, null, '2018-09-01 00:00:00', '2018-09-01 00:00:00', 1, 1, true,
+'SYS INTG WATER', 2, null, null, 'SYSTEM', 0, 'Guardian name', 'Father',
+null, 'A_POSITIVE', null, 'identificationmark','pb.jalandhar');
+ -- password is sifinance123@
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', null, '1990-07-23 00:00:00', 'en_IN', 'SIFINANCE', '$2a$10$ehRKHzRqr0i8gQf4g8nQWOUhXAFNr43cdQLU/t48jcHkcKZEihM5y',
+'2025-12-31 00:00:00', null, null, null, '2018-09-01 00:00:00', '2018-09-01 00:00:00', 1, 1, true,
+'SYS INTG FINANCE', 2, null, null, 'SYSTEM', 0, 'Guardian name', 'Father',
+null, 'A_POSITIVE', null, 'identificationmark','pb.jalandhar');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'System Integrator Finance','SYS_INTEGRATOR_FINANCE','Role for allowing system integration of Finance app with rainmaker',now(),1,1,now(),0,'pb.jalandhar');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'System Integrator W&S','SYS_INTEGRATOR_WATER_SEW','Role for allowing system integration of Water and Sewerage app with rainmaker',now(),1,1,now(),0,'pb.jalandhar');
+
+insert into eg_userrole (roleid,roleidtenantid,userid,tenantid,lastmodifieddate) values((select id from eg_role where code='SYS_INTEGRATOR_WATER_SEW' and tenantid='pb.jalandhar'),'pb.jalandhar',(select id from eg_user where username='SIWATER' and tenantid='pb.jalandhar'),'pb.jalandhar','2018-09-01 00:00:00');
+
+insert into eg_userrole (roleid,roleidtenantid,userid,tenantid,lastmodifieddate) values((select id from eg_role where code='SYS_INTEGRATOR_FINANCE' and tenantid='pb.jalandhar'),'pb.jalandhar',(select id from eg_user where username='SIFINANCE' and tenantid='pb.jalandhar'),'pb.jalandhar','2018-09-01 00:00:00');
+
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181008191435__roles_tl_dml.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181008191435__roles_tl_dml.sql
new file mode 100644
index 00000000000..f79a0c5bc66
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181008191435__roles_tl_dml.sql
@@ -0,0 +1,15 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'TL Counter Employee','TL_CEMP','Counter Employee in Trade License who files TL on behalf of the citizen',now(),1,1,now(),0,'pb.amritsar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'TL Approver','TL_APPROVER','Approver who verifies and approves the TL application',now(),1,1,now(),0,'pb.amritsar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'TL Counter Employee','TL_CEMP','Counter Employee in Trade License who files TL on behalf of the citizen',now(),1,1,now(),0,'pb.jalandhar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'TL Approver','TL_APPROVER','Approver who verifies and approves the TL application',now(),1,1,now(),0,'pb.jalandhar')
+ON CONFLICT (code, tenantid) DO NOTHING;
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181010113411__eg_role_for_financial_mohali_nayagaon.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181010113411__eg_role_for_financial_mohali_nayagaon.sql
new file mode 100644
index 00000000000..8736f782387
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181010113411__eg_role_for_financial_mohali_nayagaon.sql
@@ -0,0 +1,90 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Super User','SUPERUSER','System Administrator. Can change all master data and has access to all the system screens.',now(),1,1,now(),0,'pb.mohali')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'EGF Bill Creator','EGF-BILL_CREATOR','Employee who creates Bills mainly expense bill',now(),1,1,now(),0,'pb.mohali')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'EGF Bill Approver','EGF-BILL_APPROVER','Employee who takes part in Bills approval mainly expense bill',now(),1,1,now(),0,'pb.mohali')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Voucher Creator','EGF-VOUCHER_CREATOR','One who can create a voucher',now(),1,1,now(),0,'pb.mohali')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Voucher Approver','EGF-VOUCHER_APPROVER','One who can approve a voucher',now(),1,1,now(),0,'pb.mohali')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Payment Creator','EGF-PAYMENT_CREATOR','One who can create payment',now(),1,1,now(),0,'pb.mohali')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Payment Approver','EGF-PAYMENT_APPROVER','One who can approve a payment',now(),1,1,now(),0,'pb.mohali')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Master Admin','EGF-MASTER_ADMIN','One who is the administrator for all master data in Finance',now(),1,1,now(),0,'pb.mohali')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Report View','EGF-REPORT_VIEW','One who has acess to all financial reports',now(),1,1,now(),0,'pb.mohali')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Collections Receipt Creator','COLL_RECEIPT_CREATOR','One who can create and approve a receipt and receipt voucher',now(),1,1,now(),0,'pb.mohali')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Collections Remitter','COLL_REMIT_TO_BANK','One who can remit the instruments to bank',now(),1,1,now(),0,'pb.mohali')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+-----
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Super User','SUPERUSER','System Administrator. Can change all master data and has access to all the system screens.',now(),1,1,now(),0,'pb.nayagaon')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'EGF Bill Creator','EGF-BILL_CREATOR','Employee who creates Bills mainly expense bill',now(),1,1,now(),0,'pb.nayagaon')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'EGF Bill Approver','EGF-BILL_APPROVER','Employee who takes part in Bills approval mainly expense bill',now(),1,1,now(),0,'pb.nayagaon')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Voucher Creator','EGF-VOUCHER_CREATOR','One who can create a voucher',now(),1,1,now(),0,'pb.nayagaon')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Voucher Approver','EGF-VOUCHER_APPROVER','One who can approve a voucher',now(),1,1,now(),0,'pb.nayagaon')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Payment Creator','EGF-PAYMENT_CREATOR','One who can create payment',now(),1,1,now(),0,'pb.nayagaon')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Payment Approver','EGF-PAYMENT_APPROVER','One who can approve a payment',now(),1,1,now(),0,'pb.nayagaon')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Master Admin','EGF-MASTER_ADMIN','One who is the administrator for all master data in Finance',now(),1,1,now(),0,'pb.nayagaon')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Report View','EGF-REPORT_VIEW','One who has acess to all financial reports',now(),1,1,now(),0,'pb.nayagaon')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Collections Receipt Creator','COLL_RECEIPT_CREATOR','One who can create and approve a receipt and receipt voucher',now(),1,1,now(),0,'pb.nayagaon')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Collections Remitter','COLL_REMIT_TO_BANK','One who can remit the instruments to bank',now(),1,1,now(),0,'pb.nayagaon')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181010174021__eg_employeerole_mohali_nayagaon.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181010174021__eg_employeerole_mohali_nayagaon.sql
new file mode 100644
index 00000000000..a69ce9451d2
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181010174021__eg_employeerole_mohali_nayagaon.sql
@@ -0,0 +1,6 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'pb.mohali')
+ON CONFLICT (code, tenantid) DO NOTHING;
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'pb.nayagaon')
+ON CONFLICT (code, tenantid) DO NOTHING;
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181010222820__sysintg_role_user_mohali_naya.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181010222820__sysintg_role_user_mohali_naya.sql
new file mode 100644
index 00000000000..01f0a889af0
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181010222820__sysintg_role_user_mohali_naya.sql
@@ -0,0 +1,63 @@
+ -- password is siwater123@
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', null, '1990-07-23 00:00:00', 'en_IN', 'SIWATER', '$2a$10$4e79gVHpe4zZHC6Xy/bWouZOVQaqwgrW5U6IdrhNVBmkbgXfBo8lm',
+'2025-12-31 00:00:00', null, null, null, '2018-09-01 00:00:00', '2018-09-01 00:00:00', 1, 1, true,
+'SYS INTG WATER', 2, null, null, 'SYSTEM', 0, 'Guardian name', 'Father',
+null, 'A_POSITIVE', null, 'identificationmark','pb.mohali');
+ -- password is sifinance123@
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', null, '1990-07-23 00:00:00', 'en_IN', 'SIFINANCE', '$2a$10$ehRKHzRqr0i8gQf4g8nQWOUhXAFNr43cdQLU/t48jcHkcKZEihM5y',
+'2025-12-31 00:00:00', null, null, null, '2018-09-01 00:00:00', '2018-09-01 00:00:00', 1, 1, true,
+'SYS INTG FINANCE', 2, null, null, 'SYSTEM', 0, 'Guardian name', 'Father',
+null, 'A_POSITIVE', null, 'identificationmark','pb.mohali');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'System Integrator Finance','SYS_INTEGRATOR_FINANCE','Role for allowing system integration of Finance app with rainmaker',now(),1,1,now(),0,'pb.mohali');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'System Integrator W&S','SYS_INTEGRATOR_WATER_SEW','Role for allowing system integration of Water and Sewerage app with rainmaker',now(),1,1,now(),0,'pb.mohali');
+
+insert into eg_userrole (roleid,roleidtenantid,userid,tenantid,lastmodifieddate) values((select id from eg_role where code='SYS_INTEGRATOR_WATER_SEW' and tenantid='pb.mohali'),'pb.mohali',(select id from eg_user where username='SIWATER' and tenantid='pb.mohali'),'pb.mohali','2018-09-01 00:00:00');
+
+insert into eg_userrole (roleid,roleidtenantid,userid,tenantid,lastmodifieddate) values((select id from eg_role where code='SYS_INTEGRATOR_FINANCE' and tenantid='pb.mohali'),'pb.mohali',(select id from eg_user where username='SIFINANCE' and tenantid='pb.mohali'),'pb.mohali','2018-09-01 00:00:00');
+
+---------------------------------------------------
+ -- password is siwater123@
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', null, '1990-07-23 00:00:00', 'en_IN', 'SIWATER', '$2a$10$4e79gVHpe4zZHC6Xy/bWouZOVQaqwgrW5U6IdrhNVBmkbgXfBo8lm',
+'2025-12-31 00:00:00', null, null, null, '2018-09-01 00:00:00', '2018-09-01 00:00:00', 1, 1, true,
+'SYS INTG WATER', 2, null, null, 'SYSTEM', 0, 'Guardian name', 'Father',
+null, 'A_POSITIVE', null, 'identificationmark','pb.nayagaon');
+ -- password is sifinance123@
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', null, '1990-07-23 00:00:00', 'en_IN', 'SIFINANCE', '$2a$10$ehRKHzRqr0i8gQf4g8nQWOUhXAFNr43cdQLU/t48jcHkcKZEihM5y',
+'2025-12-31 00:00:00', null, null, null, '2018-09-01 00:00:00', '2018-09-01 00:00:00', 1, 1, true,
+'SYS INTG FINANCE', 2, null, null, 'SYSTEM', 0, 'Guardian name', 'Father',
+null, 'A_POSITIVE', null, 'identificationmark','pb.nayagaon');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'System Integrator Finance','SYS_INTEGRATOR_FINANCE','Role for allowing system integration of Finance app with rainmaker',now(),1,1,now(),0,'pb.nayagaon');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'System Integrator W&S','SYS_INTEGRATOR_WATER_SEW','Role for allowing system integration of Water and Sewerage app with rainmaker',now(),1,1,now(),0,'pb.nayagaon');
+
+insert into eg_userrole (roleid,roleidtenantid,userid,tenantid,lastmodifieddate) values((select id from eg_role where code='SYS_INTEGRATOR_WATER_SEW' and tenantid='pb.nayagaon'),'pb.nayagaon',(select id from eg_user where username='SIWATER' and tenantid='pb.nayagaon'),'pb.nayagaon','2018-09-01 00:00:00');
+
+insert into eg_userrole (roleid,roleidtenantid,userid,tenantid,lastmodifieddate) values((select id from eg_role where code='SYS_INTEGRATOR_FINANCE' and tenantid='pb.nayagaon'),'pb.nayagaon',(select id from eg_user where username='SIFINANCE' and tenantid='pb.nayagaon'),'pb.nayagaon','2018-09-01 00:00:00');
+
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181011140910__sysintg_role_user_amritsar.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181011140910__sysintg_role_user_amritsar.sql
new file mode 100644
index 00000000000..a3e55f1d660
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181011140910__sysintg_role_user_amritsar.sql
@@ -0,0 +1,31 @@
+ -- password is siwater123@
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', null, '1990-07-23 00:00:00', 'en_IN', 'SIWATER', '$2a$10$4e79gVHpe4zZHC6Xy/bWouZOVQaqwgrW5U6IdrhNVBmkbgXfBo8lm',
+'2025-12-31 00:00:00', null, null, null, '2018-09-01 00:00:00', '2018-09-01 00:00:00', 1, 1, true,
+'SYS INTG WATER', 2, null, null, 'SYSTEM', 0, 'Guardian name', 'Father',
+null, 'A_POSITIVE', null, 'identificationmark','pb.amritsar');
+ -- password is sifinance123@
+INSERT INTO eg_user (
+id, title, salutation, dob, locale, username, password, pwdexpirydate, mobilenumber, altcontactnumber, emailid, createddate,
+lastmodifieddate, createdby, lastmodifiedby, active, name, gender, pan, aadhaarnumber, type, version, guardian, guardianrelation,
+signature, bloodgroup, photo, identificationmark,tenantid)
+VALUES (
+nextval('seq_eg_user'), 'title', null, '1990-07-23 00:00:00', 'en_IN', 'SIFINANCE', '$2a$10$ehRKHzRqr0i8gQf4g8nQWOUhXAFNr43cdQLU/t48jcHkcKZEihM5y',
+'2025-12-31 00:00:00', null, null, null, '2018-09-01 00:00:00', '2018-09-01 00:00:00', 1, 1, true,
+'SYS INTG FINANCE', 2, null, null, 'SYSTEM', 0, 'Guardian name', 'Father',
+null, 'A_POSITIVE', null, 'identificationmark','pb.amritsar');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'System Integrator Finance','SYS_INTEGRATOR_FINANCE','Role for allowing system integration of Finance app with rainmaker',now(),1,1,now(),0,'pb.amritsar');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'System Integrator W&S','SYS_INTEGRATOR_WATER_SEW','Role for allowing system integration of Water and Sewerage app with rainmaker',now(),1,1,now(),0,'pb.amritsar');
+
+insert into eg_userrole (roleid,roleidtenantid,userid,tenantid,lastmodifieddate) values((select id from eg_role where code='SYS_INTEGRATOR_WATER_SEW' and tenantid='pb.amritsar'),'pb.amritsar',(select id from eg_user where username='SIWATER' and tenantid='pb.amritsar'),'pb.amritsar','2018-09-01 00:00:00');
+
+insert into eg_userrole (roleid,roleidtenantid,userid,tenantid,lastmodifieddate) values((select id from eg_role where code='SYS_INTEGRATOR_FINANCE' and tenantid='pb.amritsar'),'pb.amritsar',(select id from eg_user where username='SIFINANCE' and tenantid='pb.amritsar'),'pb.amritsar','2018-09-01 00:00:00');
+
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181015150910__role_employeefin.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181015150910__role_employeefin.sql
new file mode 100644
index 00000000000..84f465a84e9
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181015150910__role_employeefin.sql
@@ -0,0 +1,7 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee Finance','EMPLOYEE_FINANCE','Role for all employees who are using finance',now(),1,1,now(),0,'pb.mohali');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee Finance','EMPLOYEE_FINANCE','Role for all employees who are using finance',now(),1,1,now(),0,'pb.nayagaon');
+
+
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181015190610__role_updatefin.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181015190610__role_updatefin.sql
new file mode 100644
index 00000000000..e357dd0b2e1
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181015190610__role_updatefin.sql
@@ -0,0 +1,9 @@
+update eg_role set code='EGF_BILL_CREATOR' where code='EGF-BILL_CREATOR';
+update eg_role set code='EGF_BILL_APPROVER' where code='EGF-BILL_APPROVER';
+update eg_role set code='EGF_VOUCHER_CREATOR' where code='EGF-VOUCHER_CREATOR';
+update eg_role set code='EGF_VOUCHER_APPROVER' where code='EGF-VOUCHER_APPROVER';
+update eg_role set code='EGF_PAYMENT_CREATOR' where code='EGF-PAYMENT_CREATOR';
+update eg_role set code='EGF_PAYMENT_APPROVER' where code='EGF-PAYMENT_APPROVER';
+update eg_role set code='EGF_MASTER_ADMIN' where code='EGF-MASTER_ADMIN';
+update eg_role set code='EGF_REPORT_VIEW' where code='EGF_REPORT_VIEW';
+
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181029143630__role_updatereport.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181029143630__role_updatereport.sql
new file mode 100644
index 00000000000..0dd0b240ddb
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181029143630__role_updatereport.sql
@@ -0,0 +1,2 @@
+update eg_role set code='EGF_REPORT_VIEW' where code='EGF-REPORT_VIEW';
+
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181102121133__role_financeadmin.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181102121133__role_financeadmin.sql
new file mode 100644
index 00000000000..41e6c2888a3
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181102121133__role_financeadmin.sql
@@ -0,0 +1,18 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Admin','EGF_ADMINISTRATOR','One who is the administrator for all master data in Finance',now(),1,1,now(),0,'pb.mohali') ON CONFLICT(code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Admin','EGF_ADMINISTRATOR','One who is the administrator for all master data in Finance',now(),1,1,now(),0,'pb.jalandhar') ON CONFLICT(code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Admin','EGF_ADMINISTRATOR','One who is the administrator for all master data in Finance',now(),1,1,now(),0,'pb.amritsar') ON CONFLICT(code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Admin','EGF_ADMINISTRATOR','One who is the administrator for all master data in Finance',now(),1,1,now(),0,'pb.kharar') ON CONFLICT(code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Admin','EGF_ADMINISTRATOR','One who is the administrator for all master data in Finance',now(),1,1,now(),0,'pb.zirakpur') ON CONFLICT(code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Finance Admin','EGF_ADMINISTRATOR','One who is the administrator for all master data in Finance',now(),1,1,now(),0,'pb.nayagaon') ON CONFLICT(code, tenantid) DO NOTHING;
+
diff --git a/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181102144300__dgro_role_dml.sql b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181102144300__dgro_role_dml.sql
new file mode 100644
index 00000000000..c12415f06d1
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/seed2/V20181102144300__dgro_role_dml.sql
@@ -0,0 +1,15 @@
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Department Grievance Routing Officer','DGRO','GRO for a sepcific dept who assings the grievances to last mile employees',now(),1,1,now(),0,'pb.amritsar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Department Grievance Routing Officer','DGRO','GRO for a sepcific dept who assings the grievances to last mile employees',now(),1,1,now(),0,'pb.jalandhar')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Department Grievance Routing Officer','DGRO','GRO for a sepcific dept who assings the grievances to last mile employees',now(),1,1,now(),0,'pb.phagwara')
+ON CONFLICT (code, tenantid) DO NOTHING;
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Department Grievance Routing Officer','DGRO','GRO for a sepcific dept who assings the grievances to last mile employees',now(),1,1,now(),0,'pb.nawanshahr')
+ON CONFLICT (code, tenantid) DO NOTHING;
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/test/V20180327160924__updating_roles_for_pb.sql b/core-services/egov-user/src/main/resources/db2/migration/test/V20180327160924__updating_roles_for_pb.sql
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/core-services/egov-user/src/main/resources/db2/migration/test2/V20180327160924__updating_roles_for_pb.sql b/core-services/egov-user/src/main/resources/db2/migration/test2/V20180327160924__updating_roles_for_pb.sql
new file mode 100644
index 00000000000..ff2a5f8684b
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/test2/V20180327160924__updating_roles_for_pb.sql
@@ -0,0 +1,44 @@
+delete from eg_userrole where tenantid='pb.Amritsar';
+delete from eg_user where tenantid='pb.Amritsar';
+
+
+delete from eg_role where tenantid='pb.Amritsar';
+delete from eg_role where tenantid='pb.Patiala';
+delete from eg_role where tenantid='pb.Jalandhar';
+delete from eg_role where tenantid='pb.Bathinda';
+delete from eg_role where tenantid='pb.Hoshiarpur';
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen','CITIZEN','Citizen who can raise complaint',now(),1,1,now(),0,'pb.amritsar');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'pb.amritsar');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Routing Officer','GRO','Grievance Routing Officer',now(),1,1,now(),0,'pb.amritsar');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen','CITIZEN','Citizen who can raise complaint',now(),1,1,now(),0,'pb.patiala');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'pb.patiala');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Routing Officer','GRO','Grievance Routing Officer',now(),1,1,now(),0,'pb.patiala');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen','CITIZEN','Citizen who can raise complaint',now(),1,1,now(),0,'pb.jalandhar');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'pb.jalandhar');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Routing Officer','GRO','Grievance Routing Officer',now(),1,1,now(),0,'pb.jalandhar');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen','CITIZEN','Citizen who can raise complaint',now(),1,1,now(),0,'pb.bathinda');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'pb.bathinda');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Routing Officer','GRO','Grievance Routing Officer',now(),1,1,now(),0,'pb.bathinda');
+
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Citizen','CITIZEN','Citizen who can raise complaint',now(),1,1,now(),0,'pb.hoshiarpur');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Employee','EMPLOYEE','Default role for all employees',now(),1,1,now(),0,'pb.hoshiarpur');
+insert into eg_role (id,name,code,description,createddate,createdby,lastmodifiedby,lastmodifieddate,version,tenantid)values
+(nextval('SEQ_EG_ROLE'),'Grievance Routing Officer','GRO','Grievance Routing Officer',now(),1,1,now(),0,'pb.hoshiarpur');
\ No newline at end of file
diff --git a/core-services/egov-user/src/main/resources/db2/migration/test2/V20180330100224__delete_script_for_pbroles.sql b/core-services/egov-user/src/main/resources/db2/migration/test2/V20180330100224__delete_script_for_pbroles.sql
new file mode 100644
index 00000000000..d278e32ca09
--- /dev/null
+++ b/core-services/egov-user/src/main/resources/db2/migration/test2/V20180330100224__delete_script_for_pbroles.sql
@@ -0,0 +1,9 @@
+delete from eg_userrole where tenantid='pb.amritsar';
+delete from eg_user where tenantid='pb.amritsar';
+
+delete from eg_role where tenantid='pb.amritsar';
+delete from eg_role where tenantid='pb.patiala';
+delete from eg_role where tenantid='pb.jalandhar';
+delete from eg_role where tenantid='pb.bathinda';
+delete from eg_role where tenantid='pb.hoshiarpur';
+
diff --git a/core-services/egov-user/src/test/java/org/egov/user/domain/model/UserTest.java b/core-services/egov-user/src/test/java/org/egov/user/domain/model/UserTest.java
index 009a496ca58..525dac9cb20 100644
--- a/core-services/egov-user/src/test/java/org/egov/user/domain/model/UserTest.java
+++ b/core-services/egov-user/src/test/java/org/egov/user/domain/model/UserTest.java
@@ -18,7 +18,7 @@ public class UserTest {
public void testUserWithEmptyNameIsInvalid() throws Exception {
User user = User.builder()
.mobileNumber("8899776655")
- .username("foolan_devi")
+ .userName("foolan_devi")
.active(Boolean.TRUE)
.gender(Gender.FEMALE)
.type(UserType.CITIZEN)
@@ -45,7 +45,7 @@ public void testUserWithEmptyUserNameIsInvalid() throws Exception {
@Test(expected = InvalidUserCreateException.class)
public void testUserWithEmptyMobileIsInvalid() throws Exception {
User user = User.builder()
- .username("foolan_devi")
+ .userName("foolan_devi")
.name("foolan")
.active(Boolean.TRUE)
.gender(Gender.FEMALE)
@@ -60,7 +60,7 @@ public void testUserWithEmptyMobileIsInvalid() throws Exception {
@Test(expected = InvalidUserCreateException.class)
public void testUserWithEmptyTypeIsInvalid() throws Exception {
User user = User.builder()
- .username("foolan_devi")
+ .userName("foolan_devi")
.name("foolan")
.mobileNumber("9988776655")
.active(Boolean.TRUE)
@@ -74,7 +74,7 @@ public void testUserWithEmptyTypeIsInvalid() throws Exception {
@Test(expected = InvalidUserCreateException.class)
public void test_should_throw_exception_when_tenant_id_is_not_present() {
User user = User.builder()
- .username("foolan_devi")
+ .userName("foolan_devi")
.name("foolan")
.mobileNumber("9988776655")
.active(Boolean.TRUE)
@@ -90,7 +90,7 @@ public void test_should_throw_exception_when_tenant_id_is_not_present() {
@Test(expected = InvalidUserCreateException.class)
public void test_should_throw_exception_when_roles_is_not_present() {
User user = User.builder()
- .username("foolan_devi")
+ .userName("foolan_devi")
.name("foolan")
.mobileNumber("9988776655")
.active(Boolean.TRUE)
@@ -110,7 +110,7 @@ public void test_should_throw_exception_when_role_code_is_not_present() {
final Role role2 = Role.builder().code(null).build();
User user = User.builder()
- .username("foolan_devi")
+ .userName("foolan_devi")
.name("foolan")
.mobileNumber("9988776655")
.active(Boolean.TRUE)
@@ -246,7 +246,7 @@ public void test_should_return_false_when_otp_reference_is_present() {
public void test_should_not_throw_exception_on_user_create_with_all_mandatory_fields() {
final Role role1 = Role.builder().code("roleCode1").build();
User user = User.builder()
- .username("foolan_devi")
+ .userName("foolan_devi")
.name("foolan")
.mobileNumber("9988776655")
.password("password")
@@ -312,7 +312,7 @@ public void test_should_nullify_fields() {
Role role1 = Role.builder().code("roleCode1").build();
Role role2 = Role.builder().code("roleCode2").build();
User user = User.builder()
- .username("userName")
+ .userName("userName")
.mobileNumber("mobileNumber")
.password("password")
.passwordExpiryDate(new Date())
@@ -321,7 +321,7 @@ public void test_should_nullify_fields() {
user.nullifySensitiveFields();
- assertNull(user.getUsername());
+ assertNull(user.getUserName());
assertNull(user.getMobileNumber());
assertNull(user.getPassword());
assertNull(user.getPasswordExpiryDate());
diff --git a/core-services/egov-user/src/test/java/org/egov/user/domain/service/UserServiceTest.java b/core-services/egov-user/src/test/java/org/egov/user/domain/service/UserServiceTest.java
index 6a1a9a47e04..c3241046bf6 100644
--- a/core-services/egov-user/src/test/java/org/egov/user/domain/service/UserServiceTest.java
+++ b/core-services/egov-user/src/test/java/org/egov/user/domain/service/UserServiceTest.java
@@ -107,7 +107,7 @@ public void test_should_save_a_valid_user() {
when(userRepository.create(domainUser)).thenReturn(expectedEntityUser);
when(encryptionDecryptionUtil.encryptObject(domainUser, "User", User.class)).thenReturn(domainUser);
- when(encryptionDecryptionUtil.decryptObject(expectedEntityUser, "UserSelf", User.class,
+ when(encryptionDecryptionUtil.decryptObject(expectedEntityUser, "UserListSelf", User.class,
getValidRequestInfo())).thenReturn(expectedEntityUser);
User returnedUser = userService.createUser(domainUser, getValidRequestInfo());
@@ -136,7 +136,7 @@ public void test_should_create_a_valid_citizen() {
when(domainUser.getPassword()).thenReturn("P@assw0rd");
when(userRepository.create(domainUser)).thenReturn(expectedUser);
when(encryptionDecryptionUtil.encryptObject(domainUser, "User", User.class)).thenReturn(domainUser);
- when(encryptionDecryptionUtil.decryptObject(expectedUser, "UserSelf", User.class, getValidRequestInfo())).thenReturn(expectedUser);
+ when(encryptionDecryptionUtil.decryptObject(expectedUser, "UserListSelf", User.class, getValidRequestInfo())).thenReturn(expectedUser);
User returnedUser = userService.createCitizen(domainUser, getValidRequestInfo());
assertEquals(expectedUser, returnedUser);
@@ -147,7 +147,7 @@ public void test_should_not_create_citizenWithWrongUserName() {
userService = new UserService(userRepository, otpRepository, fileRepository, passwordEncoder,
encryptionDecryptionUtil, tokenStore, DEFAULT_PASSWORD_EXPIRY_IN_DAYS,
true, false, pwdRegex, pwdMaxLength, pwdMinLength);
- org.egov.user.domain.model.User domainUser = User.builder().username("TestUser").name("Test").active(true)
+ org.egov.user.domain.model.User domainUser = User.builder().userName("TestUser").name("Test").active(true)
.tenantId("default").mobileNumber("123456789").type(UserType.CITIZEN).build();
userService.createCitizen(domainUser, getValidRequestInfo());
}
@@ -276,7 +276,7 @@ public void test_should_validate_user_on_update() {
// @Ignore
//// @Test(expected = DuplicateUserNameException.class)
-//// public void test_should_throw_error_when_username_exists_while_updating() throws Exception {
+//// public void test_should_throw_error_when_userName_exists_while_updating() throws Exception {
//// User domainUser = validDomainUser(false);
//// when(userRepository.isUserPresent(any(String.class), any(String.class))).thenReturn(true);
////
@@ -322,7 +322,7 @@ public void test_should_partially_update_user() {
@Test(expected = UserProfileUpdateDeniedException.class)
public void test_should_throw_exception_when_logged_in_user_is_different_from_user_being_updated() {
- final User user = User.builder().id(12L).username("xyz").uuid("zyz").type(UserType.CITIZEN).loggedInUserId(11L)
+ final User user = User.builder().id(12L).userName("xyz").uuid("zyz").type(UserType.CITIZEN).loggedInUserId(11L)
.tenantId
("default").build();
when(encryptionDecryptionUtil.encryptObject(user, "User", User.class)).thenReturn(user);
@@ -342,7 +342,7 @@ public void test_should_validate_update_password_request() {
.newPassword("newPassword")
.existingPassword("existingPassword")
.build();
- User user = User.builder().username("xyz").tenantId("default").type(UserType.CITIZEN).build();
+ User user = User.builder().userName("xyz").tenantId("default").type(UserType.CITIZEN).build();
when(userRepository.findAll(any(UserSearchCriteria.class))).thenReturn(Collections.singletonList(user));
when(passwordEncoder.matches(anyString(), anyString())).thenReturn(true);
@@ -356,7 +356,7 @@ public void test_should_throwexception_incaseofloginotpenabledastrue_forcitizen_
userService = new UserService(userRepository, otpRepository, fileRepository, passwordEncoder,
encryptionDecryptionUtil, tokenStore, DEFAULT_PASSWORD_EXPIRY_IN_DAYS,
true, isEmployeeLoginOtpBased, pwdRegex, pwdMaxLength, pwdMinLength);
- User user = User.builder().username("xyz").tenantId("default").type(UserType.CITIZEN).build();
+ User user = User.builder().userName("xyz").tenantId("default").type(UserType.CITIZEN).build();
when(userRepository.findAll(any(UserSearchCriteria.class))).thenReturn(Collections.singletonList(user));
final LoggedInUserUpdatePasswordRequest updatePasswordRequest = LoggedInUserUpdatePasswordRequest.builder()
.userName("xyz")
@@ -374,7 +374,7 @@ public void test_should_throwexception_incaseofloginotpenabledastrue_foremployee
userService = new UserService(userRepository, otpRepository, fileRepository, passwordEncoder,
encryptionDecryptionUtil, tokenStore, DEFAULT_PASSWORD_EXPIRY_IN_DAYS,
false, true, pwdRegex, pwdMaxLength, pwdMinLength);
- User user = User.builder().username("xyz").tenantId("default").type(UserType.EMPLOYEE).build();
+ User user = User.builder().userName("xyz").tenantId("default").type(UserType.EMPLOYEE).build();
when(userRepository.findAll(any(UserSearchCriteria.class))).thenReturn(Collections.singletonList(user));
final LoggedInUserUpdatePasswordRequest updatePasswordRequest = LoggedInUserUpdatePasswordRequest.builder()
.userName("xyz")
@@ -405,7 +405,7 @@ public void test_should_throw_exception_when_existing_password_does_not_match_on
.newPassword("newPassword")
.existingPassword("existingPassword")
.build();
- User user = User.builder().username("xyz").tenantId("default").type(UserType.CITIZEN).password("existingPasswordEncoded").build();
+ User user = User.builder().userName("xyz").tenantId("default").type(UserType.CITIZEN).password("existingPasswordEncoded").build();
when(passwordEncoder.matches("wrongPassword", "existingPasswordEncoded")).thenReturn(false);
when(userRepository.findAll(any(UserSearchCriteria.class))).thenReturn(Collections.singletonList(user));
@@ -422,7 +422,7 @@ public void test_should_update_password_for_logged_in_user() {
.existingPassword("existingPassword")
.build();
Long id =(long) 123;
- User domainUser = User.builder().id(id).username("xyz").tenantId("default").type(UserType.CITIZEN).password("existingPasswordEncoded").build();
+ User domainUser = User.builder().id(id).userName("xyz").tenantId("default").type(UserType.CITIZEN).password("existingPasswordEncoded").build();
when(passwordEncoder.matches("existingPassword", "existingPasswordEncoded")).thenReturn(true);
when(userRepository.findAll(any(UserSearchCriteria.class))).thenReturn(Collections.singletonList(domainUser));
@@ -583,7 +583,7 @@ public void test_should_persist_changes_on_updating_password_for_non_logged_in_u
}
private org.egov.user.domain.model.User validDomainUser(boolean otpValidationMandatory) {
- return User.builder().username("supandi_rocks").name("Supandi").gender(Gender.MALE).type(UserType.CITIZEN)
+ return User.builder().userName("supandi_rocks").name("Supandi").gender(Gender.MALE).type(UserType.CITIZEN)
.active(Boolean.TRUE).mobileNumber("9988776655").tenantId("tenantId").otpReference("12312")
.password("P@ssw0rd").roles(Collections.singleton(Role.builder().code("roleCode1").build()))
.accountLocked(false).otpValidationMandatory(otpValidationMandatory).build();
@@ -601,6 +601,6 @@ private RequestInfo getValidRequestInfo() {
}
private User getUserObject() {
- return User.builder().id(ID.get(0)).emailId(EMAIL).username(USER_NAME).build();
+ return User.builder().id(ID.get(0)).emailId(EMAIL).userName(USER_NAME).build();
}
}
diff --git a/core-services/egov-user/src/test/java/org/egov/user/persistence/repository/OtpRepositoryTest.java b/core-services/egov-user/src/test/java/org/egov/user/persistence/repository/OtpRepositoryTest.java
index 3250e54df88..3da24d0b4e5 100644
--- a/core-services/egov-user/src/test/java/org/egov/user/persistence/repository/OtpRepositoryTest.java
+++ b/core-services/egov-user/src/test/java/org/egov/user/persistence/repository/OtpRepositoryTest.java
@@ -1,5 +1,13 @@
package org.egov.user.persistence.repository;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.springframework.test.web.client.ExpectedCount.once;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
+
import org.egov.user.Resources;
import org.egov.user.domain.model.OtpValidationRequest;
import org.egov.user.web.contract.Otp;
@@ -14,12 +22,6 @@
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.springframework.test.web.client.ExpectedCount.once;
-import static org.springframework.test.web.client.match.MockRestRequestMatchers.*;
-import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
-
@RunWith(MockitoJUnitRunner.class)
public class OtpRepositoryTest {
@@ -36,19 +38,7 @@ public void setUp() throws Exception {
this.otpRepository = new OtpRepository(otpHost, otpSearchContext, otpValidateContext, restTemplate);
}
- @Test
- public void testShouldReturnTrueWhenOtpHasBeenValidated() throws Exception {
- server.expect(once(), requestTo("http://otp-host.com/otp/_search")).andExpect(method(HttpMethod.POST))
- .andExpect(content().string(new Resources().getFileContents("otpSearchSuccessRequest.json")))
- .andRespond(withSuccess(new Resources().getFileContents("otpSearchValidatedResponse.json"),
- MediaType.APPLICATION_JSON_UTF8));
- final OtpValidationRequest request = buildRequest();
-
- boolean isOtpValidated = otpRepository.isOtpValidationComplete(request);
-
- server.verify();
- assertEquals(Boolean.TRUE, isOtpValidated);
- }
+
@Test
@Ignore
@@ -81,32 +71,9 @@ public void testShouldReturnTrueWhenOtpValidated() throws Exception {
}
- @Test
- public void testShouldReturnFalseWhenOtpHasNotBeenValidated() throws Exception {
- server.expect(once(), requestTo("http://otp-host.com/otp/_search")).andExpect(method(HttpMethod.POST))
- .andExpect(content().string(new Resources().getFileContents("otpSearchSuccessRequest.json")))
- .andRespond(withSuccess(new Resources().getFileContents("otpSearchNonValidatedResponse.json"),
- MediaType.APPLICATION_JSON_UTF8));
- final OtpValidationRequest request = buildRequest();
-
- boolean isOtpValidated = otpRepository.isOtpValidationComplete(request);
- server.verify();
- assertFalse(isOtpValidated);
- }
-
- @Test
- public void testShouldReturnFalseWhenOtpIdentityDoesNotMatch() throws Exception {
- server.expect(once(), requestTo("http://otp-host.com/otp/_search")).andExpect(method(HttpMethod.POST))
- .andExpect(content().string(new Resources().getFileContents("otpSearchSuccessRequest.json")))
- .andRespond(withSuccess(new Resources().getFileContents("otpSearchIdentityDifferentResponse.json"),
- MediaType.APPLICATION_JSON_UTF8));
- final OtpValidationRequest request = buildRequest();
-
- boolean isOtpValidated = otpRepository.isOtpValidationComplete(request);
+
- server.verify();
- assertFalse(isOtpValidated);
- }
+
private OtpValidationRequest buildRequest() {
return OtpValidationRequest.builder().otpReference("2b936aae-c3b6-4c89-b3b3-a098cdcbb706")
diff --git a/core-services/egov-user/src/test/java/org/egov/user/persistence/repository/UserRepositoryTest.java b/core-services/egov-user/src/test/java/org/egov/user/persistence/repository/UserRepositoryTest.java
index 9e36223a9f3..9246bdc3ef4 100644
--- a/core-services/egov-user/src/test/java/org/egov/user/persistence/repository/UserRepositoryTest.java
+++ b/core-services/egov-user/src/test/java/org/egov/user/persistence/repository/UserRepositoryTest.java
@@ -111,7 +111,7 @@ public void test_get_user_by_userName() {
User user = userRepository.findAll(UserSearchCriteria.builder().userName("bigcat399")
.tenantId("ap.public").type(UserType.EMPLOYEE).build()).get(0);
assertThat(user.getId().equals(1l));
- assertThat(user.getUsername().equals("bigcat399"));
+ assertThat(user.getUserName().equals("bigcat399"));
assertThat(user.getMobileNumber().equals("9731123456"));
assertThat(user.getEmailId().equals("kay.alexander@example.com"));
assertThat(user.getTenantId().equals("ap.public"));
@@ -124,7 +124,7 @@ public void test_should_save_entity_user() {
final Set roles = new HashSet<>();
final String roleCode = "EMP";
roles.add(Role.builder().code(roleCode).tenantId("ap.public").build());
- User domainUser = User.builder().roles(roles).name("test1").username("TestUserName").password("password")
+ User domainUser = User.builder().roles(roles).name("test1").userName("TestUserName").password("password")
.emailId("Test@gmail.com").aadhaarNumber("AadharNumber").mobileNumber("1234567890").active(true)
.gender(Gender.FEMALE).bloodGroup(BloodGroup.A_NEGATIVE).accountLocked(true).loggedInUserId(10l)
.createdBy(10l).tenantId("ap.public").build();
@@ -133,7 +133,7 @@ public void test_should_save_entity_user() {
assertThat(actualUser != null);
assertThat(actualUser.getId().equals(1l));
assertThat(actualUser.getRoles().size() == 1l);
- assertThat(actualUser.getUsername().equals("TestUserName"));
+ assertThat(actualUser.getUserName().equals("TestUserName"));
assertThat(actualUser.getEmailId().equals("Test@gmail.com"));
assertThat(actualUser.getAadhaarNumber().equals("AadharNumber"));
assertThat(actualUser.getMobileNumber().equals("1234567890"));
@@ -153,14 +153,14 @@ public void test_should_save_correspondence_address_on_creating_new_user() {
final String roleCode = "EMP";
roles.add(Role.builder().code(roleCode).tenantId("ap.public").build());
User domainUser = User.builder().roles(roles)
- .username("TestUserName").password("password").tenantId("ap.public")
+ .userName("TestUserName").password("password").tenantId("ap.public")
.correspondenceAddress(correspondenceAddress).build();
User actualUser = userRepository.create(domainUser);
assertThat(actualUser != null);
assertThat(actualUser.getId().equals(1l));
assertThat(actualUser.getRoles().size() == 1l);
- assertThat(actualUser.getUsername().equals("TestUserName"));
+ assertThat(actualUser.getUserName().equals("TestUserName"));
assertThat(actualUser.getTenantId().equals("ap.public"));
assertThat(actualUser.getCorrespondenceAddress() != null);
assertThat(actualUser.getCorrespondenceAddress().getAddressType().toString().equals("CORRESPONDENCE"));
@@ -179,14 +179,14 @@ public void test_should_save_permanent_address_on_creating_new_user() {
final String roleCode = "EMP";
roles.add(Role.builder().code(roleCode).tenantId("ap.public").build());
User domainUser = User.builder().roles(roles)
- .username("TestUserName").password("password").tenantId("ap.public").permanentAddress(permanentAddress)
+ .userName("TestUserName").password("password").tenantId("ap.public").permanentAddress(permanentAddress)
.build();
User actualUser = userRepository.create(domainUser);
assertThat(actualUser != null);
assertThat(actualUser.getId().equals(1l));
assertThat(actualUser.getRoles().size() == 1l);
- assertThat(actualUser.getUsername().equals("TestUserName"));
+ assertThat(actualUser.getUserName().equals("TestUserName"));
assertThat(actualUser.getTenantId().equals("ap.public"));
assertThat(actualUser.getPermanentAddress() != null);
assertThat(actualUser.getPermanentAddress().getAddressType().toString().equals("PERMANENT"));
@@ -215,7 +215,7 @@ public void test_should_set_encrypted_password_to_new_user() {
roles.add(org.egov.user.domain.model.Role.builder().code(roleCode).tenantId("ap.public").build());
final String rawPassword = "rawPassword";
User domainUser = User.builder().roles(roles)
- .username("Test UserName").password(rawPassword).tenantId("ap.public").build();
+ .userName("Test UserName").password(rawPassword).tenantId("ap.public").build();
User actualUser = userRepository.create(domainUser);
assertThat(actualUser != null);
assertThat(actualUser.getId().equals(1l));
@@ -230,7 +230,7 @@ public void test_should_save_new_user_when_enriched_roles() {
final Set roles = new HashSet<>();
roles.add(Role.builder().code("EMP").tenantId("ap.public").build());
roles.add(Role.builder().code("EADMIN").tenantId("ap.public").build());
- User domainUser = User.builder().roles(roles).username("Test UserName").password("pasword")
+ User domainUser = User.builder().roles(roles).userName("Test UserName").password("pasword")
.tenantId("ap.public").build();
User actualUser = userRepository.create(domainUser);
assertThat(actualUser != null);
@@ -348,7 +348,7 @@ public void test_should_update_entity_user() {
final Set roles = new HashSet<>();
final String roleCode = "EMP";
roles.add(Role.builder().code(roleCode).build());
- User domainUser = User.builder().roles(roles).name("test1").id(1L).username("TestUserName").password("password")
+ User domainUser = User.builder().roles(roles).name("test1").id(1L).userName("TestUserName").password("password")
.emailId("Test@gmail.com").aadhaarNumber("AadharNumber").mobileNumber("1234567890").active(true)
.gender(Gender.FEMALE).bloodGroup(BloodGroup.A_NEGATIVE).accountLocked(true).loggedInUserId(10L)
.createdBy(10L).tenantId("ap.public").build();
@@ -360,7 +360,7 @@ public void test_should_update_entity_user() {
assertThat(actualUser != null);
assertThat(actualUser.getId().equals(1L));
assertThat(actualUser.getRoles().size() == 1L);
- assertThat(actualUser.getUsername().equals("TestUserName"));
+ assertThat(actualUser.getUserName().equals("TestUserName"));
assertThat(actualUser.getEmailId().equals("Test@gmail.com"));
assertThat(actualUser.getAadhaarNumber().equals("AadharNumber"));
assertThat(actualUser.getGender().toString().equals("FEMALE"));
diff --git a/core-services/egov-user/src/test/java/org/egov/user/web/contract/UserRequestTest.java b/core-services/egov-user/src/test/java/org/egov/user/web/contract/UserRequestTest.java
index 7fa73754fb5..7bd8cc4ba36 100644
--- a/core-services/egov-user/src/test/java/org/egov/user/web/contract/UserRequestTest.java
+++ b/core-services/egov-user/src/test/java/org/egov/user/web/contract/UserRequestTest.java
@@ -20,7 +20,7 @@ public void test_domain_to_contract_conversion() {
UserRequest userRequestContract = new UserRequest(domainUser);
assertThat(userRequestContract.getId()).isEqualTo(domainUser.getId());
- assertThat(userRequestContract.getUserName()).isEqualTo(domainUser.getUsername());
+ assertThat(userRequestContract.getUserName()).isEqualTo(domainUser.getUserName());
assertThat(userRequestContract.getSalutation()).isEqualTo(domainUser.getSalutation());
assertThat(userRequestContract.getName()).isEqualTo(domainUser.getName());
assertThat(userRequestContract.getGender()).isEqualTo(domainUser.getGender().toString());
@@ -65,7 +65,7 @@ public void test_contract_to_domain_conversion() {
String expectedDate = c.getTime().toString();
assertEquals("Kroorveer", userForCreate.getName());
- assertEquals("yakku", userForCreate.getUsername());
+ assertEquals("yakku", userForCreate.getUserName());
assertEquals("Dr.", userForCreate.getSalutation());
assertEquals("8967452310", userForCreate.getMobileNumber());
assertEquals("kroorkool@maildrop.cc", userForCreate.getEmailId());
@@ -142,7 +142,7 @@ private User getUser() {
return User.builder()
.id(1L)
- .username("userName")
+ .userName("userName")
.salutation("salutation")
.name("name")
.gender(Gender.FEMALE)
@@ -161,7 +161,7 @@ private User getUser() {
.accountLocked(false)
.roles(getListOfRoles())
.guardian("name of relative")
- .guardianRelation(GuardianRelation.FATHER)
+ .guardianRelation(GuardianRelation.Father)
.signature("7a9d7f12-bdcb-4487-9d43-709838a0ad39")
.bloodGroup(BloodGroup.A_POSITIVE)
.photo("3b26fb49-e43d-401b-899a-f8f0a1572de0")
diff --git a/core-services/egov-user/src/test/java/org/egov/user/web/controller/UserControllerTest.java b/core-services/egov-user/src/test/java/org/egov/user/web/controller/UserControllerTest.java
index c6bac7c79f9..569fe003d20 100644
--- a/core-services/egov-user/src/test/java/org/egov/user/web/controller/UserControllerTest.java
+++ b/core-services/egov-user/src/test/java/org/egov/user/web/controller/UserControllerTest.java
@@ -194,7 +194,7 @@ public void test_should_update_user_profile() throws Exception {
@Ignore
public void test_should_update_user_details() throws Exception {
- org.egov.user.domain.model.User userRequest = org.egov.user.domain.model.User.builder().name("foo").username("userName").dob(new Date("04/08/1986")).guardian("name of relative").build();
+ org.egov.user.domain.model.User userRequest = org.egov.user.domain.model.User.builder().name("foo").userName("userName").dob(new Date("04/08/1986")).guardian("name of relative").build();
when(userService.updateWithoutOtpValidation(any(org.egov.user.domain.model.User.class), any())).thenReturn
(userRequest);
mockMvc.perform(post("/users/112/_updatenovalidate")
@@ -211,7 +211,7 @@ public void test_should_update_user_details() throws Exception {
public void test_should_create_citizen() throws Exception {
final Date expectedDate = toDate(LocalDateTime.of(1986, 8, 4, 5, 30));
final org.egov.user.domain.model.User user = org.egov.user.domain.model.User.builder()
- .username("userName")
+ .userName("userName")
.name("foo")
.dob(expectedDate)
.guardian("name of relative")
@@ -231,7 +231,7 @@ public void test_should_create_citizen() throws Exception {
public void test_should_create_user_without_otp_validation() throws Exception {
final Date expectedDate = toDate(LocalDateTime.of(1986, 8, 4, 0, 0));
final org.egov.user.domain.model.User expectedUser = org.egov.user.domain.model.User.builder()
- .username("userName")
+ .userName("userName")
.name("foo")
.dob(expectedDate)
.guardian("name of relative")
@@ -249,7 +249,7 @@ public void test_should_create_user_without_otp_validation() throws Exception {
final org.egov.user.domain.model.User actualUser = argumentCaptor.getValue();
assertEquals("foo", actualUser.getName());
- assertEquals("userName", actualUser.getUsername());
+ assertEquals("userName", actualUser.getUserName());
assertEquals("name of relative", actualUser.getGuardian());
}
@@ -295,12 +295,12 @@ private List getUserModels() {
org.egov.user.domain.model.User user = org.egov.user.domain.model.User.builder()
.id(1L)
.tenantId("")
- .username("userName")
+ .userName("userName")
.title("title")
.password("password")
.salutation("salutation")
.guardian("name of relative")
- .guardianRelation(GuardianRelation.FATHER)
+ .guardianRelation(GuardianRelation.Father)
.name("name")
.gender(Gender.FEMALE)
.mobileNumber("mobileNumber1")
diff --git a/core-services/egov-user/src/test/java/org/egov/user/web/controller/UserRequestControllerTest.java b/core-services/egov-user/src/test/java/org/egov/user/web/controller/UserRequestControllerTest.java
index eb43b25e53d..d18b23c947a 100644
--- a/core-services/egov-user/src/test/java/org/egov/user/web/controller/UserRequestControllerTest.java
+++ b/core-services/egov-user/src/test/java/org/egov/user/web/controller/UserRequestControllerTest.java
@@ -118,7 +118,7 @@ private User buildUser() {
return User.builder()
.id(12L)
.name("Jamaal Bhai")
- .username("jamaalbhai")
+ .userName("jamaalbhai")
.salutation("dawakhana@charminar")
.gender(Gender.MALE)
.mobileNumber("9988776655")
diff --git a/core-services/egov-workflow-v2/pom.xml b/core-services/egov-workflow-v2/pom.xml
index 0ec1e31ea76..086ee94461e 100644
--- a/core-services/egov-workflow-v2/pom.xml
+++ b/core-services/egov-workflow-v2/pom.xml
@@ -127,7 +127,7 @@
org.postgresql
postgresql
- 42.2.2.jre7
+ 42.2.18
diff --git a/core-services/egov-workflow-v2/src/main/resources/db/Dockerfile b/core-services/egov-workflow-v2/src/main/resources/db/Dockerfile
index 3c4ecd3c667..f38638a269f 100644
--- a/core-services/egov-workflow-v2/src/main/resources/db/Dockerfile
+++ b/core-services/egov-workflow-v2/src/main/resources/db/Dockerfile
@@ -1,4 +1,4 @@
-FROM upyogio/flyway:4.1.2
+FROM egovio/flyway:10.7.1
COPY ./migration/main /flyway/sql
@@ -6,4 +6,4 @@ COPY migrate.sh /usr/bin/migrate.sh
RUN chmod +x /usr/bin/migrate.sh
-CMD ["/usr/bin/migrate.sh"]
+ENTRYPOINT ["/usr/bin/migrate.sh"]
diff --git a/core-services/egov-workflow-v2/src/main/resources/db/migrate.sh b/core-services/egov-workflow-v2/src/main/resources/db/migrate.sh
index 43960b25cdb..8d8089316d5 100644
--- a/core-services/egov-workflow-v2/src/main/resources/db/migrate.sh
+++ b/core-services/egov-workflow-v2/src/main/resources/db/migrate.sh
@@ -1,3 +1,3 @@
#!/bin/sh
-flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate
\ No newline at end of file
+flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -validateOnMigrate=false migrate
\ No newline at end of file
diff --git a/core-services/libraries/digit-models/.gitignore b/core-services/libraries/digit-models/.gitignore
index 2af7cefb0a3..3467f05c98a 100644
--- a/core-services/libraries/digit-models/.gitignore
+++ b/core-services/libraries/digit-models/.gitignore
@@ -21,4 +21,5 @@ build/
nbbuild/
dist/
nbdist/
-.nb-gradle/
\ No newline at end of file
+.nb-gradle/
+/bin/
diff --git a/core-services/libraries/digit-models/pom.xml b/core-services/libraries/digit-models/pom.xml
index 400e6d08bf1..5f58b549c9c 100644
--- a/core-services/libraries/digit-models/pom.xml
+++ b/core-services/libraries/digit-models/pom.xml
@@ -73,7 +73,7 @@
org.egov.services
services-common
- 1.1.0-SNAPSHOT
+ 1.1.1-SNAPSHOT
jakarta.validation
diff --git a/core-services/libraries/digit-models/src/main/java/digit/models/coremodels/user/Role.java b/core-services/libraries/digit-models/src/main/java/digit/models/coremodels/user/Role.java
index 290503083f9..1db6fcbd7ca 100644
--- a/core-services/libraries/digit-models/src/main/java/digit/models/coremodels/user/Role.java
+++ b/core-services/libraries/digit-models/src/main/java/digit/models/coremodels/user/Role.java
@@ -3,7 +3,7 @@
import lombok.*;
import java.util.Date;
-
+@NoArgsConstructor
@Getter
@Setter
@Builder
diff --git a/core-services/libraries/digit-models/src/main/java/digit/models/coremodels/user/enums/GuardianRelation.java b/core-services/libraries/digit-models/src/main/java/digit/models/coremodels/user/enums/GuardianRelation.java
index 34859c66fb5..390efeece2f 100644
--- a/core-services/libraries/digit-models/src/main/java/digit/models/coremodels/user/enums/GuardianRelation.java
+++ b/core-services/libraries/digit-models/src/main/java/digit/models/coremodels/user/enums/GuardianRelation.java
@@ -41,5 +41,5 @@
package digit.models.coremodels.user.enums;
public enum GuardianRelation {
- FATHER, MOTHER, HUSBAND, OTHER;
+ Father, Mother, Husband, Other;
}
diff --git a/core-services/libraries/enc-client/bin/Dockerfile b/core-services/libraries/enc-client/bin/Dockerfile
new file mode 100644
index 00000000000..cd50dd4120d
--- /dev/null
+++ b/core-services/libraries/enc-client/bin/Dockerfile
@@ -0,0 +1,17 @@
+FROM egovio/alpine-maven-builder-jdk-8:1-master-NA-6036091e AS build
+ARG WORK_DIR
+ARG nexusUsername
+ARG nexusPassword
+WORKDIR /app
+# copy the project files
+COPY ${WORK_DIR}/pom.xml ./pom.xml
+COPY ${WORK_DIR}/settings.xml ./settings.xml
+# COPY build/maven/settings.xml ./settings.xml
+# COPY build/maven/start.sh ./start.sh
+COPY ${WORK_DIR}/src ./src
+# not useful for stateless builds
+# RUN mvn -B dependency:go-offline
+RUN cd ${WORK_DIR} \
+ && mvn -B -f /app/pom.xml test verify deploy -s settings.xml \
+ -Dnexus.user=${nexusUsername} -Dnexus.password=${nexusPassword}
+FROM scratch
\ No newline at end of file
diff --git a/core-services/libraries/enc-client/bin/README.md b/core-services/libraries/enc-client/bin/README.md
new file mode 100644
index 00000000000..75601e7a775
--- /dev/null
+++ b/core-services/libraries/enc-client/bin/README.md
@@ -0,0 +1,2 @@
+# Encryption Client APIs (enc-client)
+
diff --git a/core-services/libraries/enc-client/bin/pom.xml b/core-services/libraries/enc-client/bin/pom.xml
new file mode 100644
index 00000000000..36ce61dcd99
--- /dev/null
+++ b/core-services/libraries/enc-client/bin/pom.xml
@@ -0,0 +1,147 @@
+
+
+ 4.0.0
+ org.egov
+ enc-client
+ 1.1.0-beta-SNAPSHOT
+
+
+ repo.digit.org
+ eGov ERP Releases Repository
+ https://nexus-repo.digit.org/nexus/content/repositories/releases/
+
+
+ repo.digit.org
+ eGov ERP Snapshots Repository
+ https://nexus-repo.digit.org/nexus/content/repositories/snapshots/
+
+
+
+ 2.17.1
+ UTF-8
+ 1.8
+ UTF-8
+
+
+
+ org.egov.services
+ services-common
+ 0.12.1
+
+
+ org.egov.services
+ tracer
+ 1.1.5-SNAPSHOT
+
+
+ org.egov
+ mdms-client
+ 0.0.2-SNAPSHOT
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.9.8
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ 2.9.8
+
+
+ org.reflections
+ reflections
+ 0.9.11
+
+
+ com.jayway.jsonpath
+ json-path
+ 2.4.0
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+ org.mockito
+ mockito-all
+ 1.9.5
+ test
+
+
+ org.springframework
+ spring-core
+ 4.3.6.RELEASE
+
+
+ org.springframework
+ spring-test
+ 4.3.6.RELEASE
+ test
+
+
+ org.springframework.boot
+ spring-boot-test
+ 2.1.3.RELEASE
+ test
+
+
+ org.projectlombok
+ lombok
+ 1.18.4
+ provided
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.25
+
+
+ ch.qos.logback
+ logback-classic
+ 1.1.11
+
+
+ ch.qos.logback
+ logback-core
+ 1.1.11
+
+
+
+
+ repo.egovernments.org
+ eGov ERP Releases Repository
+ https://nexus-repo.egovernments.org/nexus/content/repositories/releases/
+
+
+ snapshots.repo.egovernments.org
+ eGov ERP Snapshots Repository
+ https://nexus-repo.egovernments.org/nexus/content/repositories/snapshots/
+
+
+
+
+
+ maven-compiler-plugin
+
+
+ 8
+
+
+
+ maven-source-plugin
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+
+
diff --git a/core-services/libraries/enc-client/bin/settings.xml b/core-services/libraries/enc-client/bin/settings.xml
new file mode 100644
index 00000000000..8de43f8a369
--- /dev/null
+++ b/core-services/libraries/enc-client/bin/settings.xml
@@ -0,0 +1,23 @@
+
+
+
+
+ nexus
+ central
+ https://nexus-repo.egovernments.org/nexus/content/groups/public/
+
+
+
+
+ repo.digit.org
+ ${nexus.user}
+ ${nexus.password}
+
+
+
+ com.versioneye
+
+
diff --git a/core-services/libraries/enc-client/bin/src/main/resources/enc.properties b/core-services/libraries/enc-client/bin/src/main/resources/enc.properties
new file mode 100644
index 00000000000..dcef3af1690
--- /dev/null
+++ b/core-services/libraries/enc-client/bin/src/main/resources/enc.properties
@@ -0,0 +1,18 @@
+#------------egov-enc-service config----------------#
+egov.enc.host=https://msewapunjab.niua.org/
+egov.enc.encrypt.endpoint=/egov-enc-service/crypto/v1/_encrypt
+egov.enc.decrypt.endpoint=/egov-enc-service/crypto/v1/_decrypt
+
+#----------------MDMS config---------------------#
+egov.mdms.host=https://msewapunjab.niua.org/
+egov.mdms.search.endpoint=/egov-mdms-service/v1/_search
+
+egov.state.level.tenant.id=pb
+
+#-----------Kafka Audit Topic Name------------#
+kafka.topic.audit=audit_data
+
+#------------Kafka Config----------------------#
+kafka.config.bootstrap_server_config=localhost:9092
+spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
+spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer
diff --git a/core-services/libraries/enc-client/src/test/resources/DecryptionABAC.json b/core-services/libraries/enc-client/bin/src/test/resources/DecryptionABAC.json
similarity index 100%
rename from core-services/libraries/enc-client/src/test/resources/DecryptionABAC.json
rename to core-services/libraries/enc-client/bin/src/test/resources/DecryptionABAC.json
diff --git a/core-services/libraries/enc-client/src/test/resources/EncryptionPolicy.json b/core-services/libraries/enc-client/bin/src/test/resources/EncryptionPolicy.json
similarity index 100%
rename from core-services/libraries/enc-client/src/test/resources/EncryptionPolicy.json
rename to core-services/libraries/enc-client/bin/src/test/resources/EncryptionPolicy.json
diff --git a/core-services/libraries/enc-client/pom.xml b/core-services/libraries/enc-client/pom.xml
index 36ce61dcd99..60b75937d83 100644
--- a/core-services/libraries/enc-client/pom.xml
+++ b/core-services/libraries/enc-client/pom.xml
@@ -4,7 +4,7 @@
4.0.0
org.egov
enc-client
- 1.1.0-beta-SNAPSHOT
+ 2.0.4-SNAPSHOT
repo.digit.org
@@ -27,7 +27,7 @@
org.egov.services
services-common
- 0.12.1
+ 1.0.1-SNAPSHOT
org.egov.services
@@ -37,7 +37,7 @@
org.egov
mdms-client
- 0.0.2-SNAPSHOT
+ 0.0.3-SNAPSHOT
com.fasterxml.jackson.core
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/EncryptionService.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/EncryptionService.java
index 8c36c8a92d5..f49b4b5ff48 100644
--- a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/EncryptionService.java
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/EncryptionService.java
@@ -1,20 +1,24 @@
package org.egov.encryption;
import com.fasterxml.jackson.databind.JsonNode;
-import org.egov.common.contract.request.User;
+import org.egov.common.contract.request.RequestInfo;
import java.io.IOException;
import java.util.List;
public interface EncryptionService {
- public JsonNode encryptJson(Object plaintextJson, String key, String tenantId) throws IOException;
+ public JsonNode encryptJson(Object plaintextJson, String model, String tenantId) throws IOException;
- public P encryptJson(Object plaintextJson, String key, String tenantId, Class valueType) throws IOException;
+ public P encryptJson(Object plaintextJson, String model, String tenantId, Class valueType) throws IOException;
- public JsonNode decryptJson(Object ciphertextJson, String key, User user) throws IOException;
+ public JsonNode decryptJson(RequestInfo requestInfo, Object ciphertextJson, String model,
+ String purpose) throws IOException;
- public P decryptJson(Object ciphertextJson, String key, User user, Class valueType) throws IOException;
+ public P decryptJson(RequestInfo requestInfo, Object ciphertextJson, String model, String purpose,
+ Class valueType) throws IOException;
+
+ public String encryptValue(Object plaintext, String tenantId) throws IOException;
public String encryptValue(Object plaintext, String tenantId, String type) throws IOException;
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/EncryptionServiceImpl.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/EncryptionServiceImpl.java
index 780a932c706..a6df7626bf5 100644
--- a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/EncryptionServiceImpl.java
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/EncryptionServiceImpl.java
@@ -2,19 +2,23 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
import lombok.extern.slf4j.Slf4j;
+import org.egov.common.contract.request.RequestInfo;
import org.egov.common.contract.request.Role;
-import org.egov.common.contract.request.User;
-import org.egov.encryption.accesscontrol.AbacFilter;
-import org.egov.encryption.config.AbacConfiguration;
+import org.egov.encryption.audit.AuditService;
+import org.egov.encryption.config.DecryptionPolicyConfiguration;
import org.egov.encryption.config.EncClientConstants;
+import org.egov.encryption.config.EncProperties;
import org.egov.encryption.config.EncryptionPolicyConfiguration;
import org.egov.encryption.masking.MaskingService;
-import org.egov.encryption.models.AccessType;
import org.egov.encryption.models.Attribute;
+import org.egov.encryption.models.UniqueIdentifier;
+import org.egov.encryption.models.Visibility;
import org.egov.encryption.util.ConvertClass;
import org.egov.encryption.util.JSONBrowseUtil;
import org.egov.encryption.util.JacksonUtils;
+import org.egov.encryption.util.JsonPathConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -29,105 +33,126 @@
@Service
public class EncryptionServiceImpl implements EncryptionService {
+ @Autowired
+ private EncProperties encProperties;
@Autowired
private EncryptionServiceRestConnection encryptionServiceRestConnection;
@Autowired
private EncryptionPolicyConfiguration encryptionPolicyConfiguration;
@Autowired
- private AbacConfiguration abacConfiguration;
- @Autowired
- private AbacFilter abacFilter;
+ private DecryptionPolicyConfiguration decryptionPolicyConfiguration;
@Autowired
private MaskingService maskingService;
@Autowired
+ private AuditService auditService;
+ @Autowired
private ObjectMapper objectMapper;
- public JsonNode encryptJson(Object plaintextJson, String key, String tenantId) throws IOException {
-
- JsonNode plaintextNode = createJsonNode(plaintextJson);
+ private JsonNode encryptJsonArray(JsonNode plaintextNode, String model, String tenantId) throws IOException {
JsonNode encryptNode = plaintextNode.deepCopy();
+ List attributes = encryptionPolicyConfiguration.getAttributeDetailsForModel(model);
+ List attributesToEncrypt = attributes.stream().map(Attribute::getJsonPath).collect(Collectors.toList());
+ attributesToEncrypt = JsonPathConverter.convertToArrayJsonPaths(attributesToEncrypt);
+ JsonNode jsonNode = JacksonUtils.filterJsonNodeForPaths(plaintextNode, attributesToEncrypt);
+
+ if (!jsonNode.isEmpty(objectMapper.getSerializerProvider())) {
+ JsonNode returnedEncryptedNode = objectMapper.valueToTree(encryptionServiceRestConnection.callEncrypt(tenantId,
+ encProperties.getDefaultEncryptDataType(), jsonNode));
+ encryptNode = JacksonUtils.merge(returnedEncryptedNode, encryptNode);
+ }
- List attributesToEncrypt = encryptionPolicyConfiguration.getAttributesForKey(key);
- Map> typeAttributeMap = encryptionPolicyConfiguration.getTypeAttributeMap(attributesToEncrypt);
-
- for (String type : typeAttributeMap.keySet()) {
- List attributes = typeAttributeMap.get(type);
- List paths = attributes.stream().map(Attribute::getJsonPath).collect(Collectors.toList());
+ return encryptNode;
+ }
- JsonNode jsonNode = JacksonUtils.filterJsonNodeForPaths(plaintextNode, paths);
+ public JsonNode encryptJson(Object plaintextJson, String model, String tenantId) throws IOException {
+ JsonNode plaintextNode = createJsonNode(plaintextJson);
+ JsonNode plaintextNodeCopy = plaintextNode.deepCopy();
- if(! jsonNode.isEmpty(objectMapper.getSerializerProvider())) {
- JsonNode returnedEncryptedNode = objectMapper.valueToTree(encryptionServiceRestConnection.callEncrypt(tenantId,
- type, jsonNode));
- encryptNode = JacksonUtils.merge(returnedEncryptedNode, encryptNode);
- }
+ // Convert input to array if it isn't already
+ if (!plaintextNodeCopy.isArray()) {
+ ArrayNode arrayNode = objectMapper.createArrayNode();
+ arrayNode.add(plaintextNodeCopy);
+ plaintextNodeCopy = arrayNode;
}
+ JsonNode encryptedNode = encryptJsonArray(plaintextNodeCopy, model, tenantId);
- return encryptNode;
+ if (!plaintextNode.isArray()) {
+ return encryptedNode.get(0);
+ }
+ return encryptedNode;
}
- public P encryptJson(Object plaintextJson, String key, String tenantId, Class valueType) throws IOException {
- return ConvertClass.convertTo(encryptJson(plaintextJson, key, tenantId), valueType);
+ public P encryptJson(Object plaintextJson, String model, String tenantId, Class valueType) throws IOException {
+ return ConvertClass.convertTo(encryptJson(plaintextJson, model, tenantId), valueType);
}
-
- public JsonNode decryptJson(Object ciphertextJson, Map attributeAccessTypeMap, User user)
- throws IOException {
+ private JsonNode decryptJson(RequestInfo requestInfo, Object ciphertextJson,
+ Map attributesVisibilityMap,
+ String model, String purpose, UniqueIdentifier uniqueIdentifier) throws IOException {
JsonNode ciphertextNode = createJsonNode(ciphertextJson);
JsonNode decryptNode = ciphertextNode.deepCopy();
- if(attributeAccessTypeMap.containsValue(AccessType.NONE)) {
- List attributesToBeRemoved = attributeAccessTypeMap.keySet().stream()
- .filter(attribute -> attributeAccessTypeMap.get(attribute) == AccessType.NONE).collect(Collectors.toList());
- List pathsToBeRemoved = attributesToBeRemoved.stream().map(Attribute::getJsonPath).collect(Collectors.toList());
- JsonNode nodeToBeEmptied = JacksonUtils.filterJsonNodeForPaths(decryptNode, pathsToBeRemoved);
+ // Convert input to array if it isn't already
+ if (!decryptNode.isArray()) {
+ ArrayNode arrayNode = objectMapper.createArrayNode();
+ arrayNode.add(decryptNode);
+ decryptNode = arrayNode;
+ }
+
+ if (attributesVisibilityMap.containsValue(Visibility.NONE)) {
+ List attributesToBeRemoved = attributesVisibilityMap.keySet().stream()
+ .filter(attribute -> attributesVisibilityMap.get(attribute) == Visibility.NONE).collect(Collectors.toList());
+ List pathToBeRemoved = attributesToBeRemoved.stream().map(Attribute::getJsonPath).collect(Collectors.toList());
+ JsonNode nodeToBeEmptied = JacksonUtils.filterJsonNodeForPaths(decryptNode, pathToBeRemoved);
JsonNode emptyNode = JSONBrowseUtil.mapValues(nodeToBeEmptied, __ -> EncClientConstants.STRING_FOR_NONE_ACCESS);
decryptNode = JacksonUtils.merge(emptyNode, decryptNode);
}
- List attributesToBeDecrypted = attributeAccessTypeMap.keySet().stream()
- .filter(attribute -> attributeAccessTypeMap.get(attribute) != AccessType.NONE).collect(Collectors.toList());
+ List attributesToBeDecrypted = attributesVisibilityMap.keySet().stream()
+ .filter(attribute -> attributesVisibilityMap.get(attribute) != Visibility.NONE).collect(Collectors.toList());
List pathsToBeDecrypted = attributesToBeDecrypted.stream().map(Attribute::getJsonPath).collect(Collectors.toList());
-
+ pathsToBeDecrypted = JsonPathConverter.convertToArrayJsonPaths(pathsToBeDecrypted);
JsonNode jsonNode = JacksonUtils.filterJsonNodeForPaths(ciphertextNode, pathsToBeDecrypted);
- if(! jsonNode.isEmpty(objectMapper.getSerializerProvider())) {
+ if (!jsonNode.isEmpty(objectMapper.getSerializerProvider())) {
JsonNode returnedDecryptedNode = encryptionServiceRestConnection.callDecrypt(jsonNode);
decryptNode = JacksonUtils.merge(returnedDecryptedNode, decryptNode);
}
- if(attributeAccessTypeMap.containsValue(AccessType.MASK)) {
- List attributesToBeMasked = attributeAccessTypeMap.keySet().stream()
- .filter(attribute -> attributeAccessTypeMap.get(attribute) == AccessType.MASK).collect(Collectors.toList());
- decryptNode = maskingService.maskData(decryptNode, attributesToBeMasked);
+ if (attributesVisibilityMap.containsValue(Visibility.MASKED)) {
+ List attributesToBeMasked = attributesVisibilityMap.keySet().stream()
+ .filter(attribute -> attributesVisibilityMap.get(attribute) == Visibility.MASKED).collect(Collectors.toList());
+ decryptNode = maskingService.maskData(decryptNode, attributesToBeMasked, uniqueIdentifier, requestInfo);
}
+ // auditService.audit(decryptNode, model, purpose, requestInfo);
+
return decryptNode;
}
+ @Override
+ public JsonNode decryptJson(RequestInfo requestInfo, Object ciphertextJson, String model, String purpose) throws IOException {
+ List roles = requestInfo.getUserInfo().getRoles().stream().map(Role::getCode).collect(Collectors.toList());
+ Map attributesVisibilityMap = decryptionPolicyConfiguration.getRoleAttributeAccessListForModel(requestInfo, model, roles);
- public JsonNode decryptJson(Object ciphertextJson, String key, User user) throws IOException {
-
- List roles = user.getRoles().stream().map(Role::getCode).collect(Collectors.toList());
-
- Map attributeAccessTypeMap = abacFilter.getAttributeAccessForRoles(roles,
- abacConfiguration.getRoleAttributeAccessListForKey(key));
-
- JsonNode decryptedNode = decryptJson(ciphertextJson, attributeAccessTypeMap, user);
+ UniqueIdentifier uniqueIdentifier = decryptionPolicyConfiguration.getSecurityPolicyUniqueIdentifier(model);
+ JsonNode decryptedNode = decryptJson(requestInfo, ciphertextJson, attributesVisibilityMap, model, purpose, uniqueIdentifier);
return decryptedNode;
}
- public P decryptJson(Object ciphertextJson, String key, User user, Class valueType) throws IOException {
- return ConvertClass.convertTo(decryptJson(ciphertextJson, key, user), valueType);
+ public P decryptJson(RequestInfo requestInfo, Object ciphertextJson, String model, String purpose
+ , Class valueType) throws IOException {
+ return ConvertClass.convertTo(decryptJson(requestInfo, ciphertextJson, model, purpose), valueType);
}
+
JsonNode createJsonNode(Object json) throws IOException {
JsonNode jsonNode;
- if(json instanceof JsonNode)
+ if (json instanceof JsonNode)
jsonNode = (JsonNode) json;
- else if(json instanceof String)
+ else if (json instanceof String)
jsonNode = objectMapper.readTree((String) json); //JsonNode from JSON String
else
jsonNode = objectMapper.valueToTree(json); //JsonNode from POJO or Map
@@ -135,6 +160,10 @@ else if(json instanceof String)
}
+ public String encryptValue(Object plaintext, String tenantId) throws IOException {
+ return encryptValue(plaintext, tenantId, encProperties.getDefaultEncryptDataType());
+ }
+
public String encryptValue(Object plaintext, String tenantId, String type) throws IOException {
return encryptValue(new ArrayList<>(Collections.singleton(plaintext)), tenantId, type).get(0);
}
@@ -144,5 +173,4 @@ public List encryptValue(List plaintext, String tenantId, String
return ConvertClass.convertTo(objectMapper.valueToTree(encryptionResponse), List.class);
}
-
}
\ No newline at end of file
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/EncryptionServiceRestConnection.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/EncryptionServiceRestConnection.java
index 147fa008f5b..ed3bfec8f93 100644
--- a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/EncryptionServiceRestConnection.java
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/EncryptionServiceRestConnection.java
@@ -4,8 +4,10 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.egov.encryption.config.EncProperties;
+import org.egov.encryption.config.ErrorConstants;
import org.egov.encryption.web.contract.EncReqObject;
import org.egov.encryption.web.contract.EncryptionRequest;
+import org.egov.tracer.model.CustomException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
@@ -28,20 +30,28 @@ class EncryptionServiceRestConnection {
Object callEncrypt(String tenantId, String type, Object value) throws IOException {
-
EncReqObject encReqObject = new EncReqObject(tenantId, type, value);
EncryptionRequest encryptionRequest = new EncryptionRequest();
encryptionRequest.setEncryptionRequests(new ArrayList<>(Collections.singleton(encReqObject)));
- ResponseEntity response = restTemplate.postForEntity(encProperties.getEgovEncHost() + encProperties.getEgovEncEncryptPath() ,
- encryptionRequest, String.class);
- return objectMapper.readTree(response.getBody()).get(0);
+ try {
+ ResponseEntity response = restTemplate.postForEntity(encProperties.getEgovEncHost() + encProperties.getEgovEncEncryptPath(),
+ encryptionRequest, String.class);
+ return objectMapper.readTree(response.getBody()).get(0);
+ } catch (Exception e) {
+ log.error(ErrorConstants.ENCRYPTION_SERVICE_ERROR_MESSAGE, e);
+ throw new CustomException(ErrorConstants.ENCRYPTION_SERVICE_ERROR, ErrorConstants.ENCRYPTION_SERVICE_ERROR_MESSAGE);
+ }
}
- JsonNode callDecrypt(Object ciphertext) throws IOException {
- ResponseEntity response = restTemplate.postForEntity(
- encProperties.getEgovEncHost() + encProperties.getEgovEncDecryptPath(), ciphertext, JsonNode.class);
- return response.getBody();
+ JsonNode callDecrypt(Object ciphertext) {
+ try {
+ ResponseEntity response = restTemplate.postForEntity(
+ encProperties.getEgovEncHost() + encProperties.getEgovEncDecryptPath(), ciphertext, JsonNode.class);
+ return response.getBody();
+ } catch (Exception e) {
+ throw new CustomException(ErrorConstants.ENCRYPTION_SERVICE_ERROR, ErrorConstants.ENCRYPTION_SERVICE_ERROR_MESSAGE);
+ }
}
}
\ No newline at end of file
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/audit/AuditService.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/audit/AuditService.java
index 3b61cb673f6..57c72a77a55 100644
--- a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/audit/AuditService.java
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/audit/AuditService.java
@@ -2,16 +2,18 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.LongNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.fasterxml.jackson.databind.node.TextNode;
+import org.egov.common.contract.request.RequestInfo;
import org.egov.common.contract.request.User;
+import org.egov.encryption.config.DecryptionPolicyConfiguration;
import org.egov.encryption.config.EncProperties;
import org.egov.encryption.models.AuditObject;
+import org.egov.encryption.models.UniqueIdentifier;
import org.egov.encryption.producer.Producer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
+import java.util.List;
import java.util.UUID;
@Service
@@ -23,28 +25,35 @@ public class AuditService {
private EncProperties encProperties;
@Autowired
private ObjectMapper objectMapper;
+ @Autowired
+ private DecryptionPolicyConfiguration decryptionPolicyConfiguration;
+
+ public void audit(JsonNode json, String model, String purpose, RequestInfo requestInfo) {
+ User user = requestInfo.getUserInfo();
- public void audit(JsonNode data, User user) {
AuditObject auditObject = AuditObject.builder().build();
- auditObject.setData(data);
+ auditObject.setId(UUID.randomUUID().toString());
auditObject.setTimestamp(System.currentTimeMillis());
auditObject.setUserId(user.getUuid());
- auditObject.setId(UUID.randomUUID().toString());
-
- producer.push(encProperties.getAuditTopicName(), auditObject.getId(), objectMapper.valueToTree(auditObject).toString());
- }
-
- public void audit(String userId, Long timestamp, String purpose, JsonNode abacParams, JsonNode data) {
- ObjectNode auditObject = objectMapper.createObjectNode();
-
- auditObject.set("id", TextNode.valueOf(UUID.randomUUID().toString()));
- auditObject.set("userId", TextNode.valueOf(userId));
- auditObject.set("timestamp", LongNode.valueOf(timestamp));
- auditObject.set("purpose", TextNode.valueOf(purpose));
- auditObject.set("abacParams", abacParams);
- auditObject.set("data", data);
-
- producer.push(encProperties.getAuditTopicName(), auditObject.get("id").asText(), auditObject);
+ auditObject.setModel(model);
+ auditObject.setPurpose(purpose);
+
+ if (requestInfo.getPlainAccessRequest() != null) {
+ auditObject.setPlainAccessRequest(requestInfo.getPlainAccessRequest());
+ }
+
+ UniqueIdentifier uniqueIdentifier =
+ decryptionPolicyConfiguration.getUniqueIdentifierForModel(model);
+ List entityIds = new ArrayList<>();
+ for (JsonNode node : json) {
+ if(node.at(uniqueIdentifier.getJsonPath())!=null) {
+ String nodeUuid = node.at(uniqueIdentifier.getJsonPath()).asText();
+ entityIds.add(nodeUuid);
+ }
+ }
+ auditObject.setEntityIds(entityIds);
+
+ producer.push(encProperties.getAuditTopicName(), auditObject.getId(), auditObject);
}
}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/DecryptionPolicyConfiguration.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/DecryptionPolicyConfiguration.java
new file mode 100644
index 00000000000..33b66c41eec
--- /dev/null
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/DecryptionPolicyConfiguration.java
@@ -0,0 +1,199 @@
+package org.egov.encryption.config;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
+import lombok.extern.slf4j.Slf4j;
+import net.minidev.json.JSONArray;
+import org.egov.common.contract.request.RequestInfo;
+import org.egov.encryption.models.*;
+import org.egov.encryption.util.MdmsFetcher;
+import org.egov.tracer.model.CustomException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.client.RestTemplate;
+
+import javax.annotation.PostConstruct;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Component
+public class DecryptionPolicyConfiguration {
+
+ @Autowired
+ private EncProperties encProperties;
+
+ @Autowired
+ private MdmsFetcher mdmsFetcher;
+ @Autowired
+ private RestTemplate restTemplate;
+ @Autowired
+ private ObjectMapper objectMapper;
+
+ private Map> modelAttributeAccessMap;
+
+ private Map>> modelRoleBasedDecryptionPolicyMap;
+
+ private Map uniqueIdentifierMap;
+
+
+ void initializeModelAttributeAccessMap(List modelRoleAttributeAccessList) {
+ modelAttributeAccessMap = modelRoleAttributeAccessList.stream()
+ .collect(Collectors.toMap(SecurityPolicy::getModel,
+ SecurityPolicy::getAttributes));
+ }
+
+ void initializeRoleBasedDecryptionPolicyMap(List modelRoleAttributeAccessList) {
+ modelRoleBasedDecryptionPolicyMap = new HashMap<>();
+ for (SecurityPolicy securityPolicy : modelRoleAttributeAccessList) {
+ modelRoleBasedDecryptionPolicyMap.put(securityPolicy.getModel(),
+ makeRoleAttributeAccessMapping(securityPolicy.getRoleBasedDecryptionPolicy()));
+ }
+ }
+
+ void initializeUniqueIdentifierMap(List modelRoleAttributeAccessList) {
+ uniqueIdentifierMap = modelRoleAttributeAccessList.stream()
+ .collect(Collectors.toMap(SecurityPolicy::getModel,
+ SecurityPolicy::getUniqueIdentifier));
+ }
+
+ @PostConstruct
+ void initializeModelAttributeAccessMapFromMdms() {
+ List securityPolicyList = null;
+ try {
+ JSONArray securityPolicyJson = mdmsFetcher.getSecurityMdmsForFilter(null);
+ ObjectReader reader = objectMapper.readerFor(objectMapper.getTypeFactory().constructCollectionType(List.class,
+ SecurityPolicy.class));
+ securityPolicyList = reader.readValue(securityPolicyJson.toString());
+ } catch (IOException e) {
+ log.error(ErrorConstants.SECURITY_POLICY_READING_ERROR_MESSAGE, e);
+ throw new CustomException(ErrorConstants.SECURITY_POLICY_READING_ERROR, ErrorConstants.SECURITY_POLICY_READING_ERROR_MESSAGE);
+ }
+
+ initializeModelAttributeAccessMap(securityPolicyList);
+ initializeRoleBasedDecryptionPolicyMap(securityPolicyList);
+ initializeUniqueIdentifierMap(securityPolicyList);
+ }
+
+ public UniqueIdentifier getUniqueIdentifierForModel(String model) {
+ return uniqueIdentifierMap.get(model);
+ }
+
+ public Map getRoleAttributeAccessListForModel(RequestInfo requestInfo, String model, List roles) {
+ Map mapping = new HashMap<>();
+ try {
+ List attributesList = modelAttributeAccessMap.get(model);
+ Map> roleAttributeAccessMap =
+ modelRoleBasedDecryptionPolicyMap.get(model);
+
+ boolean isAttributeListEmpty = CollectionUtils.isEmpty(attributesList);
+ boolean isRoleAttributeAccessMapEmpty = CollectionUtils.isEmpty(roleAttributeAccessMap);
+
+ if (isAttributeListEmpty) {
+ throw new CustomException("DECRYPTION_NULL_ERROR", "Attribute list is empty");
+ }
+
+
+ if (!isAttributeListEmpty && !isRoleAttributeAccessMapEmpty) {
+ Map attributesMap = makeAttributeMap(attributesList);
+
+ List secondLevelVisibility = new ArrayList<>();
+
+ for (String role : roles) {
+ if (!roleAttributeAccessMap.containsKey(role))
+ continue;
+
+ List attributeList = roleAttributeAccessMap.get(role);
+
+ for (AttributeAccess attributeAccess : attributeList) {
+ String attributeName = attributeAccess.getAttribute();
+ Attribute attribute = attributesMap.get(attributeName);
+ if (requestInfo.getPlainAccessRequest() != null && !CollectionUtils.isEmpty(requestInfo.getPlainAccessRequest().getPlainRequestFields())
+ && requestInfo.getPlainAccessRequest().getPlainRequestFields().contains(attributeName)
+ && attributeAccess.getSecondLevelVisibility() != null && !secondLevelVisibility.contains(attributeName)) {
+ secondLevelVisibility.add(attributeName);
+ }
+ String firstLevelVisibility = attributeAccess.getFirstLevelVisibility() != null ?
+ String.valueOf(attributeAccess.getFirstLevelVisibility()) : String.valueOf(attribute.getDefaultVisibility());
+ Visibility visibility = Visibility.valueOf(firstLevelVisibility);
+ if (mapping.containsKey(attribute)) {
+ if (mapping.get(attribute).ordinal() > visibility.ordinal()) {
+ mapping.remove(attribute);
+ mapping.put(attribute, visibility);
+ }
+ } else {
+ mapping.put(attribute, visibility);
+ }
+ }
+ }
+
+ if (requestInfo.getPlainAccessRequest() != null)
+ requestInfo.getPlainAccessRequest().setPlainRequestFields(secondLevelVisibility);
+ }
+
+ List mappingAttributesList = new ArrayList<>(mapping.keySet());
+ List attributesToAvoidlist = new ArrayList<>();
+ for (Attribute attribute : mappingAttributesList)
+ attributesToAvoidlist.add(attribute.getName());
+
+
+ if (!isAttributeListEmpty)
+ getDefaultVisibilityMapping(attributesList, mapping, attributesToAvoidlist);
+
+
+ return mapping;
+ } catch (Exception e) {
+ throw new CustomException("DECRYPTION_NULL_ERROR", "Error in decryption process");
+ }
+ }
+
+ private Map> makeRoleAttributeAccessMapping(List roleBasedDecryptionPolicyList) {
+ Map> roleAttributeAccessMap = new HashMap<>();
+ for (RoleBasedDecryptionPolicy roleBasedDecryptionPolicy : roleBasedDecryptionPolicyList) {
+ List roles = roleBasedDecryptionPolicy.getRoles();
+ List attributeAccessList = roleBasedDecryptionPolicy.getAttributeAccessList();
+ for (String role : roles) {
+ roleAttributeAccessMap.put(role, attributeAccessList);
+ }
+ }
+ return roleAttributeAccessMap;
+ }
+
+ private Map makeAttributeMap(List attributesList) {
+ Map atrributesMap = new HashMap<>();
+
+ for (Attribute attribute : attributesList) {
+ String filedName = attribute.getName();
+ atrributesMap.put(filedName, attribute);
+ }
+ return atrributesMap;
+ }
+
+ public UniqueIdentifier getSecurityPolicyUniqueIdentifier(String model) {
+ return uniqueIdentifierMap.get(model);
+ }
+
+ private void getDefaultVisibilityMapping(List attributesList, Map mapping, List attributesToAvoidlist) {
+
+ for (Attribute attribute : attributesList) {
+ String defaultVisibility = String.valueOf(attribute.getDefaultVisibility());
+ Visibility visibility = Visibility.valueOf(defaultVisibility);
+ if (!attributesToAvoidlist.contains(attribute.getName())) {
+ if (mapping.containsKey(attribute)) {
+ if (mapping.get(attribute).ordinal() > visibility.ordinal()) {
+ mapping.remove(attribute);
+ mapping.put(attribute, visibility);
+ }
+ } else {
+ mapping.put(attribute, visibility);
+ }
+ }
+ }
+ }
+
+}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncClientConstants.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncClientConstants.java
index 113077a8039..82ad2a239ac 100644
--- a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncClientConstants.java
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncClientConstants.java
@@ -4,9 +4,11 @@ public class EncClientConstants {
public static final String MDMS_MODULE_NAME = "DataSecurity";
- public static final String MDMS_ENCRYPTION_MASTER_NAME = "EncryptionPolicy";
+ public static final String MDMS_SECURITY_POLICY_MASTER_NAME = "SecurityPolicy";
- public static final String MDMS_DECRYPTION_MASTER_NAME = "DecryptionABAC";
+ public static final String MDMS_MASKING_PATTERN_MASTER_NAME = "MaskingPatterns";
public static final String STRING_FOR_NONE_ACCESS = "Confidential Information";
+
+ public static final String TENANTID_MDC = "TENANTID";
}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncProperties.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncProperties.java
index e20e227db6c..ca408934242 100644
--- a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncProperties.java
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncProperties.java
@@ -1,11 +1,12 @@
package org.egov.encryption.config;
-import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
+import lombok.Getter;
+
@Getter
@Configuration
@PropertySource("classpath:enc.properties")
@@ -16,17 +17,21 @@ public class EncProperties {
@Value("${egov.mdms.host}")
private String egovMdmsHost;
+
@Value("${egov.mdms.search.endpoint}")
private String egovMdmsSearchEndpoint;
- @Value("${egov.state.level.tenant.id}")
+ @Value("${state.level.tenant.id}")
private String stateLevelTenantId;
+ @Value("${default.encrypt.data.type}")
+ private String defaultEncryptDataType;
@Value("${egov.enc.host}")
private String egovEncHost;
+
@Value("${egov.enc.encrypt.endpoint}")
private String egovEncEncryptPath;
+
@Value("${egov.enc.decrypt.endpoint}")
private String egovEncDecryptPath;
-
}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncryptionConfiguration.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncryptionConfiguration.java
index c474c8115a6..cdce12df813 100644
--- a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncryptionConfiguration.java
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncryptionConfiguration.java
@@ -2,12 +2,15 @@
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.egov.common.utils.MultiStateInstanceUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
@Configuration
@ComponentScan(basePackages = {"org.egov.encryption"})
+@Import({MultiStateInstanceUtil.class})
public class EncryptionConfiguration {
@Bean
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncryptionPolicyConfiguration.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncryptionPolicyConfiguration.java
index 5f45410d8e7..a1ee893b4b9 100644
--- a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncryptionPolicyConfiguration.java
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/EncryptionPolicyConfiguration.java
@@ -1,82 +1,56 @@
package org.egov.encryption.config;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
+import lombok.extern.slf4j.Slf4j;
import net.minidev.json.JSONArray;
-import org.egov.common.contract.request.RequestInfo;
import org.egov.encryption.models.Attribute;
-import org.egov.encryption.models.EncryptionPolicy;
-import org.egov.mdms.model.*;
+import org.egov.encryption.models.SecurityPolicy;
+import org.egov.encryption.util.MdmsFetcher;
+import org.egov.tracer.model.CustomException;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
-import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
import java.io.IOException;
-import java.util.*;
+import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
+@Slf4j
@Component
public class EncryptionPolicyConfiguration {
@Autowired
- private EncProperties encProperties;
- @Autowired
- private RestTemplate restTemplate;
+ private MdmsFetcher mdmsFetcher;
@Autowired
private ObjectMapper objectMapper;
- private Map> keyAttributeMap;
+ private Map> encryptionPolicyAttributesMap;
@PostConstruct
- void initializeKeyAttributeMapFromMdms() {
- List encryptionPolicyList = null;
+ void initializeEncryptionPolicyAttributesMapFromMdms() throws JsonProcessingException {
try {
- MasterDetail masterDetail = MasterDetail.builder().name(EncClientConstants.MDMS_ENCRYPTION_MASTER_NAME).build();
- ModuleDetail moduleDetail = ModuleDetail.builder().moduleName(EncClientConstants.MDMS_MODULE_NAME)
- .masterDetails(Arrays.asList(masterDetail)) .build();
-
- MdmsCriteria mdmsCriteria = MdmsCriteria.builder().tenantId(encProperties.getStateLevelTenantId())
- .moduleDetails(Arrays.asList(moduleDetail)).build();
-
- MdmsCriteriaReq mdmsCriteriaReq = MdmsCriteriaReq.builder().requestInfo(RequestInfo.builder().build())
- .mdmsCriteria(mdmsCriteria).build();
-
- ResponseEntity response =
- restTemplate.postForEntity(encProperties.getEgovMdmsHost() + encProperties.getEgovMdmsSearchEndpoint(),
- mdmsCriteriaReq, MdmsResponse.class);
-
- JSONArray policyListJSON = response.getBody().getMdmsRes().get(EncClientConstants.MDMS_MODULE_NAME)
- .get(EncClientConstants.MDMS_ENCRYPTION_MASTER_NAME);
-
+ JSONArray attributesDetailsJSON = mdmsFetcher.getSecurityMdmsForFilter(null);
ObjectReader reader = objectMapper.readerFor(objectMapper.getTypeFactory().constructCollectionType(List.class,
- EncryptionPolicy.class));
- encryptionPolicyList = reader.readValue(policyListJSON.toString());
- } catch (IOException e) {}
-
- initializeKeyAttributeMap(encryptionPolicyList);
+ SecurityPolicy.class));
+ List securityPolicies = reader.readValue(attributesDetailsJSON.toString());
+ encryptionPolicyAttributesMap = securityPolicies.stream()
+ .collect(Collectors.toMap(SecurityPolicy::getModel, SecurityPolicy::getAttributes));
+ } catch (IOException e) {
+ log.error(ErrorConstants.SECURITY_POLICY_READING_ERROR_MESSAGE, e);
+ throw new CustomException(ErrorConstants.SECURITY_POLICY_READING_ERROR, ErrorConstants.SECURITY_POLICY_READING_ERROR_MESSAGE);
+ }
}
- void initializeKeyAttributeMap(List encryptionPolicyList) {
- keyAttributeMap = encryptionPolicyList.stream().collect(Collectors
- .toMap(EncryptionPolicy::getKey, EncryptionPolicy::getAttributeList));
- }
+ public List getAttributeDetailsForModel(String modelName) {
+ try {
+ return encryptionPolicyAttributesMap.get(modelName);
+ } catch (Exception e) {
+ throw new CustomException("DECRYPTION_ERROR", "Error in retrieving MDMS data");
+ }
- public List getAttributesForKey(String key) {
- return keyAttributeMap.get(key);
}
- public Map> getTypeAttributeMap(List attributeList) {
- Map> typeAttributeMap = new HashMap<>();
- for (Attribute attribute : attributeList) {
- String type = attribute.getType();
- if (! typeAttributeMap.containsKey(type)) {
- List attributesToEncrypt = new ArrayList<>();
- typeAttributeMap.put(type, attributesToEncrypt);
- }
- typeAttributeMap.get(type).add(attribute);
- }
- return typeAttributeMap;
- }
-}
+}
\ No newline at end of file
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/ErrorConstants.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/ErrorConstants.java
new file mode 100644
index 00000000000..e54d570c954
--- /dev/null
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/config/ErrorConstants.java
@@ -0,0 +1,20 @@
+package org.egov.encryption.config;
+
+public class ErrorConstants {
+
+ public static final String MDMS_FETCH_ERROR = "MDMS_FETCH_ERROR";
+ public static final String MDMS_FETCH_ERROR_MESSAGE = "Error occurred while fetching MDMS Configs";
+
+ public static final String ENCRYPTION_SERVICE_ERROR = "ENCRYPTION_SERVICE_ERROR";
+ public static final String ENCRYPTION_SERVICE_ERROR_MESSAGE
+ = "Error occurred while calling Encryption Service";
+
+ public static final String SECURITY_POLICY_READING_ERROR = "SECURITY_POLICY_READING_ERROR";
+ public static final String SECURITY_POLICY_READING_ERROR_MESSAGE
+ = "Error occurred while reading Security Policy from MDMS Config";
+
+ public static final String MASKING_PATTERN_READING_ERROR = "MASKING_PATTER_READING_ERROR";
+ public static final String MASKING_PATTER_READING_ERROR_MESSAGE
+ = "Error occurred while reading Masking Pattern from MDMS Config";
+
+}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/masking/MaskingService.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/masking/MaskingService.java
index a8c01be2ef8..093fabf7a59 100644
--- a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/masking/MaskingService.java
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/masking/MaskingService.java
@@ -1,50 +1,109 @@
package org.egov.encryption.masking;
import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import lombok.extern.slf4j.Slf4j;
+import net.minidev.json.JSONArray;
+import org.egov.common.contract.request.RequestInfo;
+import org.egov.encryption.config.EncProperties;
+import org.egov.encryption.config.ErrorConstants;
import org.egov.encryption.models.Attribute;
+import org.egov.encryption.models.UniqueIdentifier;
import org.egov.encryption.util.JSONBrowseUtil;
import org.egov.encryption.util.JacksonUtils;
-import org.reflections.Reflections;
+import org.egov.encryption.util.JsonPathConverter;
+import org.egov.encryption.util.MdmsFetcher;
+import org.egov.tracer.model.CustomException;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
import java.util.*;
+@Slf4j
@Service
public class MaskingService {
- Map maskingTechniqueMap;
+ Map maskingPatternMap = new HashMap<>();
+ @Autowired
+ private EncProperties encProperties;
+ @Autowired
+ private RestTemplate restTemplate;
+ @Autowired
+ private ObjectMapper objectMapper;
+ @Autowired
+ private MdmsFetcher mdmsFetcher;
@PostConstruct
- private void init() throws IllegalAccessException, InstantiationException {
- maskingTechniqueMap = new HashMap<>();
-
- Reflections reflections = new Reflections(getClass().getPackage().getName());
- Set> maskingTechniques = reflections.getSubTypesOf(Masking.class);
- for(Class extends Masking> maskingTechnique : maskingTechniques) {
- Masking masking = maskingTechnique.newInstance();
- maskingTechniqueMap.put(masking.getMaskingTechnique(), masking);
+ private void initMaskingPatternMap() {
+ try {
+ JSONArray maskingPatternListJSON = mdmsFetcher.getMaskingMdmsForFilter(null);
+ for (int i = 0; i < maskingPatternListJSON.size(); i++) {
+ Map obj = objectMapper.convertValue(maskingPatternListJSON.get(i), Map.class);
+ maskingPatternMap.put(obj.get("patternId"), obj.get("pattern"));
+ }
+ } catch (Exception e) {
+ log.error(ErrorConstants.MASKING_PATTER_READING_ERROR_MESSAGE, e);
+ throw new CustomException(ErrorConstants.MASKING_PATTERN_READING_ERROR, ErrorConstants.MASKING_PATTER_READING_ERROR_MESSAGE);
}
}
public T maskData(T data, Attribute attribute) {
- Masking masking = maskingTechniqueMap.get(attribute.getMaskingTechnique());
+ String value = String.valueOf(data);
+ String patternId = attribute.getPatternId();
+ String maskingRegex = maskingPatternMap.get(patternId);
+ value = value.replaceAll(maskingRegex, "*");
- return masking.maskData(data);
+ return (T) value;
}
- public JsonNode maskData(JsonNode decryptedNode, List attributes) {
+ public JsonNode maskData(JsonNode decryptedNode, List attributes, UniqueIdentifier uniqueIdentifier, RequestInfo requestInfo) {
JsonNode maskedNode = decryptedNode.deepCopy();
-
- for(Attribute attribute : attributes) {
- JsonNode jsonNode = JacksonUtils.filterJsonNodeForPaths(maskedNode, Arrays.asList(attribute.getJsonPath()));
-
+ for (Attribute attribute : attributes) {
+ JsonNode jsonNode = JacksonUtils.filterJsonNodeForPaths(maskedNode,
+ JsonPathConverter.convertToArrayJsonPaths(Arrays.asList(attribute.getJsonPath())));
jsonNode = JSONBrowseUtil.mapValues(jsonNode, value -> maskData(value, attribute));
-
maskedNode = JacksonUtils.merge(jsonNode, maskedNode);
}
-
+ if (requestInfo.getPlainAccessRequest() != null && requestInfo.getPlainAccessRequest().getRecordId() != null) {
+ maskedNode = addPlainRequestAccessValues((ArrayNode) maskedNode, (ArrayNode) decryptedNode, attributes, uniqueIdentifier, requestInfo);
+ }
return maskedNode;
}
+ private JsonNode addPlainRequestAccessValues(ArrayNode maskedArray, ArrayNode decryptedArray,
+ List attributes,
+ UniqueIdentifier uniqueIdentifier,
+ RequestInfo requestInfo) {
+ String recordId = requestInfo.getPlainAccessRequest().getRecordId();
+ List plainRequestFields = requestInfo.getPlainAccessRequest().getPlainRequestFields();
+ for (int i = 0; i < maskedArray.size(); i++) {
+ JsonNode maskedNode = maskedArray.get(i);
+ JsonNode decryptedNode = decryptedArray.get(i);
+ String nodeUuid = maskedNode.at(uniqueIdentifier.getJsonPath()).asText();
+ if (recordId.equals(nodeUuid)) {
+ JsonNode plainNode = createPlainNode(decryptedNode, plainRequestFields, attributes);
+ plainNode = JacksonUtils.merge(plainNode, maskedNode);
+ maskedArray.remove(i);
+ maskedArray.insert(i, plainNode);
+ }
+ }
+ return maskedArray;
+ }
+
+ private JsonNode createPlainNode(JsonNode decryptedNode, List plainRequestFields,
+ List attributes) {
+ JsonNode plainNode = decryptedNode.deepCopy();
+ List plainPaths = new ArrayList<>();
+ for (Attribute attribute : attributes) {
+ if (plainRequestFields.contains(attribute.getName())) {
+ plainPaths.add(attribute.getJsonPath());
+ }
+ }
+ plainNode = JacksonUtils.filterJsonNodeForPaths(plainNode, plainPaths);
+ return plainNode;
+ }
+
}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/Attribute.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/Attribute.java
index 6222ba5e941..5beca1a8f66 100644
--- a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/Attribute.java
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/Attribute.java
@@ -1,6 +1,5 @@
package org.egov.encryption.models;
-
import lombok.*;
@Getter
@@ -8,12 +7,14 @@
@Builder
@AllArgsConstructor
@NoArgsConstructor
-@EqualsAndHashCode(of = {"jsonPath"})
-@ToString
public class Attribute {
- private String jsonPath;
- private String maskingTechnique;
- private String type;
+ private String name = null;
+
+ private String jsonPath = null;
+
+ private String patternId = null;
+
+ private Visibility defaultVisibility = null;
-}
\ No newline at end of file
+}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/AttributeAccess.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/AttributeAccess.java
index 40034d4f380..8210877c1bf 100644
--- a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/AttributeAccess.java
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/AttributeAccess.java
@@ -7,20 +7,12 @@
@Builder
@AllArgsConstructor
@NoArgsConstructor
-@EqualsAndHashCode
-@ToString
public class AttributeAccess {
- private Attribute attribute;
- private AccessType accessType;
+ private String attribute = null;
- public AttributeAccess(Attribute attribute) {
- this.attribute = attribute;
- this.accessType = AccessType.PLAIN;
- }
+ private Visibility firstLevelVisibility = null;
- @Override
- public String toString() {
- return attribute + ", AccessType : " + accessType;
- }
-}
\ No newline at end of file
+ private Visibility secondLevelVisibility = null;
+
+}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/AttributeVisibility.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/AttributeVisibility.java
new file mode 100644
index 00000000000..f5dcfe8d085
--- /dev/null
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/AttributeVisibility.java
@@ -0,0 +1,15 @@
+package org.egov.encryption.models;
+
+import lombok.*;
+
+@Getter
+@Setter
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class AttributeVisibility {
+
+ private Attribute attribute;
+ private Visibility visibility;
+
+}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/AuditObject.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/AuditObject.java
index 2490e8448e0..80449ace194 100644
--- a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/AuditObject.java
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/AuditObject.java
@@ -2,6 +2,9 @@
import com.fasterxml.jackson.databind.JsonNode;
import lombok.*;
+import org.egov.common.contract.request.PlainAccessRequest;
+
+import java.util.List;
@Getter
@Setter
@@ -16,6 +19,14 @@ public class AuditObject {
private Long timestamp;
- private JsonNode data;
+ private String purpose;
+
+ private String model;
+
+ private List entityIds;
+
+ private PlainAccessRequest plainAccessRequest;
+
+ private JsonNode additionalInfo;
}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/MaskingPattern.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/MaskingPattern.java
new file mode 100644
index 00000000000..aaa9f4e3c77
--- /dev/null
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/MaskingPattern.java
@@ -0,0 +1,16 @@
+package org.egov.encryption.models;
+
+import lombok.*;
+
+@Getter
+@Setter
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class MaskingPattern {
+
+ private String id = null;
+
+ private String pattern = null;
+
+}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/RoleBasedDecryptionPolicy.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/RoleBasedDecryptionPolicy.java
new file mode 100644
index 00000000000..21e40f0ce39
--- /dev/null
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/RoleBasedDecryptionPolicy.java
@@ -0,0 +1,18 @@
+package org.egov.encryption.models;
+
+import lombok.*;
+
+import java.util.List;
+
+@Getter
+@Setter
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class RoleBasedDecryptionPolicy {
+
+ private List roles = null;
+
+ private List attributeAccessList = null;
+
+}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/SecurityPolicy.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/SecurityPolicy.java
new file mode 100644
index 00000000000..bff9e97724e
--- /dev/null
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/SecurityPolicy.java
@@ -0,0 +1,22 @@
+package org.egov.encryption.models;
+
+import lombok.*;
+
+import java.util.List;
+
+@Getter
+@Setter
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class SecurityPolicy {
+
+ private String model = null;
+
+ private UniqueIdentifier uniqueIdentifier = null;
+
+ private List attributes = null;
+
+ private List roleBasedDecryptionPolicy = null;
+
+}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/UniqueIdentifier.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/UniqueIdentifier.java
new file mode 100644
index 00000000000..f9551bd143c
--- /dev/null
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/UniqueIdentifier.java
@@ -0,0 +1,16 @@
+package org.egov.encryption.models;
+
+import lombok.*;
+
+@Getter
+@Setter
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class UniqueIdentifier {
+
+ private String name = null;
+
+ private String jsonPath = null;
+
+}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/Visibility.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/Visibility.java
new file mode 100644
index 00000000000..395c380ab50
--- /dev/null
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/models/Visibility.java
@@ -0,0 +1,33 @@
+package org.egov.encryption.models;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+
+public enum Visibility {
+ PLAIN("PLAIN"),
+ MASKED("MASKED"),
+ NONE("NONE");
+
+ private final String value;
+
+ Visibility(String value) {
+ this.value = value;
+ }
+
+ @JsonCreator
+ public static Visibility fromValue(String text) {
+ for (Visibility b : Visibility.values()) {
+ if (String.valueOf(b.value).equals(text)) {
+ return b;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ @JsonValue
+ public String toString() {
+ return String.valueOf(value);
+ }
+}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/ConvertClass.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/ConvertClass.java
index b4fb9740262..3adadfc55a0 100644
--- a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/ConvertClass.java
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/ConvertClass.java
@@ -10,16 +10,15 @@
public class ConvertClass {
- public static P convertTo(JsonNode jsonNode, Class valueType) throws IOException {
+ public static P convertTo(JsonNode jsonNode, Class valueType) throws IOException {
ObjectMapper objectMapper = new ObjectMapper(new JsonFactory());
- if(jsonNode.isArray())
- {
+ if (jsonNode.isArray()) {
ObjectReader reader =
objectMapper.readerFor(objectMapper.getTypeFactory().constructCollectionType(List.class, valueType));
return reader.readValue(jsonNode);
} else {
- return (P)objectMapper.treeToValue(jsonNode, valueType);
+ return (P) objectMapper.treeToValue(jsonNode, valueType);
}
}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/JSONBrowseUtil.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/JSONBrowseUtil.java
index bc4d88da71f..417c602b351 100644
--- a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/JSONBrowseUtil.java
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/JSONBrowseUtil.java
@@ -9,36 +9,36 @@
public class JSONBrowseUtil {
public static JsonNode mapValues(JsonNode jsonNode, Function valueMapper) {
- if(jsonNode.isArray()) {
+ if (jsonNode.isArray()) {
jsonNode = mapValuesForArrayNode((ArrayNode) jsonNode, valueMapper);
- } else if(jsonNode.isObject()) {
+ } else if (jsonNode.isObject()) {
jsonNode = mapValuesForObjectNode((ObjectNode) jsonNode, valueMapper);
- } else if(jsonNode.isValueNode()) {
+ } else if (jsonNode.isValueNode()) {
jsonNode = mapValuesForValueNode((ValueNode) jsonNode, valueMapper);
}
return jsonNode;
}
- private static ArrayNode mapValuesForArrayNode(ArrayNode arrayNode, Function valueMapper) {
- for(int i = 0; i < arrayNode.size(); i++) {
+ private static ArrayNode mapValuesForArrayNode(ArrayNode arrayNode, Function valueMapper) {
+ for (int i = 0; i < arrayNode.size(); i++) {
arrayNode.set(i, mapValues(arrayNode.get(i), valueMapper));
}
return arrayNode;
}
- private static ObjectNode mapValuesForObjectNode(ObjectNode objectNode, Function valueMapper) {
+ private static ObjectNode mapValuesForObjectNode(ObjectNode objectNode, Function valueMapper) {
Iterator fields = objectNode.fieldNames();
- while(fields.hasNext()) {
- String field = fields.next();
- objectNode.set(field, mapValues(objectNode.get(field), valueMapper));
+ while (fields.hasNext()) {
+ String field = fields.next();
+ objectNode.set(field, mapValues(objectNode.get(field), valueMapper));
}
return objectNode;
}
private static ValueNode mapValuesForValueNode(ValueNode valueNode, Function valueMapper) {
- if(valueNode.isNull())
+ if (valueNode.isNull())
return NullNode.getInstance();
- return new TextNode(String.valueOf(valueMapper.apply( (T) valueNode.asText())));
+ return new TextNode(String.valueOf(valueMapper.apply((T) valueNode.asText())));
}
}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/JacksonUtils.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/JacksonUtils.java
index be7b36ec616..10617f435a2 100644
--- a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/JacksonUtils.java
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/JacksonUtils.java
@@ -15,26 +15,26 @@
public class JacksonUtils {
public static JsonNode merge(JsonNode newNode, JsonNode originalNode) {
- if(newNode == null || newNode.isNull())
+ if (newNode == null || newNode.isNull())
return originalNode;
- else if(originalNode == null || originalNode.isNull())
+ else if (originalNode == null || originalNode.isNull())
return newNode;
- if(newNode.isObject())
- newNode = mergeObjectNodes( (ObjectNode) newNode, (ObjectNode) originalNode);
- else if(newNode.isArray())
- newNode = mergeArrayNode( (ArrayNode) newNode, (ArrayNode) originalNode);
+ if (newNode.isObject())
+ newNode = mergeObjectNodes((ObjectNode) newNode, (ObjectNode) originalNode);
+ else if (newNode.isArray())
+ newNode = mergeArrayNode((ArrayNode) newNode, (ArrayNode) originalNode);
return newNode;
}
static ArrayNode mergeArrayNode(ArrayNode newNode, ArrayNode originalNode) {
int size = newNode.size();
- if(newNode.size() < originalNode.size())
+ if (newNode.size() < originalNode.size())
size = originalNode.size();
for (int i = 0; i < size; i++) {
JsonNode jsonNode = merge(newNode.get(i), originalNode.get(i));
- if(i < newNode.size())
+ if (i < newNode.size())
newNode.set(i, jsonNode);
else
newNode.add(jsonNode);
@@ -67,14 +67,14 @@ public static JsonNode filterJsonNodeForPaths(JsonNode jsonNode, List fi
ObjectMapper mapper = new ObjectMapper(new JsonFactory());
JsonNode filteredNode;
- if(jsonNode instanceof ArrayNode)
+ if (jsonNode instanceof ArrayNode)
filteredNode = mapper.createArrayNode();
- else if(jsonNode instanceof ObjectNode)
+ else if (jsonNode instanceof ObjectNode)
filteredNode = mapper.createObjectNode();
else
return null;
- for(String path : filterPaths) {
+ for (String path : filterPaths) {
JsonNode singlePathFilterNode = filterJsonNodeForPath(jsonNode, path);
filteredNode = merge(singlePathFilterNode, filteredNode);
}
@@ -85,9 +85,9 @@ else if(jsonNode instanceof ObjectNode)
static JsonNode filterJsonNodeForPath(JsonNode jsonNode, String filterPath) {
ObjectMapper objectMapper = new ObjectMapper(new JsonFactory());
- if(filterPath == null)
+ if (filterPath == null)
return jsonNode;
- else if(jsonNode == null)
+ else if (jsonNode == null)
return null;
String key = getFirstJsonKeyForPath(filterPath);
@@ -99,7 +99,7 @@ else if(jsonNode == null)
newNode = objectMapper.createArrayNode();
for (JsonNode value : arrayNode) {
JsonNode filteredNode = filterJsonNodeForPath(value, getRemainingJsonKeyForPath(filterPath));
- if(filteredNode != null && ! filteredNode.isNull())
+ if (filteredNode != null && !filteredNode.isNull())
((ArrayNode) newNode).add(filteredNode);
}
} else { //ObjectNode
@@ -107,7 +107,7 @@ else if(jsonNode == null)
newNode = objectMapper.createObjectNode();
JsonNode value = objectNode.get(key);
JsonNode filteredNode = filterJsonNodeForPath(value, getRemainingJsonKeyForPath(filterPath));
- if(filteredNode != null && ! filteredNode.isNull())
+ if (filteredNode != null && !filteredNode.isNull())
((ObjectNode) newNode).set(key, filteredNode);
}
} catch (ClassCastException e) {
@@ -124,46 +124,46 @@ static String getFirstJsonKeyForPath(String path) {
static String getRemainingJsonKeyForPath(String path) {
String keys[] = path.split("/", 2);
- if(keys.length == 1)
+ if (keys.length == 1)
return null;
return keys[1];
}
public static JsonNode filterJsonNodeWithFields(JsonNode jsonNode, List filterFields) {
- if(checkIfNoFieldExistsInJsonNode(jsonNode, filterFields))
+ if (checkIfNoFieldExistsInJsonNode(jsonNode, filterFields))
return null;
ObjectMapper mapper = new ObjectMapper(new JsonFactory());
- if(jsonNode.isObject()) {
+ if (jsonNode.isObject()) {
ObjectNode objectNode = (ObjectNode) jsonNode;
ObjectNode filteredObjectNode = mapper.createObjectNode();
Iterator fieldIterator = objectNode.fieldNames();
while (fieldIterator.hasNext()) {
String field = fieldIterator.next();
- if(filterFields.contains(field) && !objectNode.get(field).isNull()) {
+ if (filterFields.contains(field) && !objectNode.get(field).isNull()) {
filteredObjectNode.set(field, objectNode.get(field));
} else {
JsonNode filteredJsonNode = filterJsonNodeWithFields(objectNode.get(field), filterFields);
- if(filteredJsonNode != null) {
+ if (filteredJsonNode != null) {
filteredObjectNode.set(field, filteredJsonNode);
}
}
}
- if(filteredObjectNode.isEmpty(mapper.getSerializerProvider()))
+ if (filteredObjectNode.isEmpty(mapper.getSerializerProvider()))
return null;
return filteredObjectNode;
- } else if(jsonNode.isArray()) {
+ } else if (jsonNode.isArray()) {
ArrayNode arrayNode = (ArrayNode) jsonNode;
ArrayNode filteredArrayNode = mapper.createArrayNode();
- for(int i = 0; i < arrayNode.size(); i++) {
+ for (int i = 0; i < arrayNode.size(); i++) {
JsonNode filteredJsonNode = filterJsonNodeWithFields(arrayNode.get(i), filterFields);
- if(filteredJsonNode == null) {
- if(arrayNode.get(i).isArray())
+ if (filteredJsonNode == null) {
+ if (arrayNode.get(i).isArray())
filteredJsonNode = mapper.createArrayNode();
- else if(arrayNode.get(i).isObject())
+ else if (arrayNode.get(i).isObject())
filteredJsonNode = mapper.createObjectNode();
else
filteredJsonNode = NullNode.getInstance();
@@ -178,8 +178,8 @@ else if(arrayNode.get(i).isObject())
static boolean checkIfNoFieldExistsInJsonNode(JsonNode jsonNode, List fields) {
- for(String field : fields) {
- if(! String.valueOf(jsonNode.findPath(field)).isEmpty())
+ for (String field : fields) {
+ if (!String.valueOf(jsonNode.findPath(field)).isEmpty())
return false;
}
return true;
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/JsonPathConverter.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/JsonPathConverter.java
new file mode 100644
index 00000000000..3ba904dbd8f
--- /dev/null
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/JsonPathConverter.java
@@ -0,0 +1,15 @@
+package org.egov.encryption.util;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class JsonPathConverter {
+
+ public static List convertToArrayJsonPaths(List jsonPaths) {
+ List arrayJsonPaths = new ArrayList<>();
+ jsonPaths.stream().map(path -> "*/" + path).forEach(arrayJsonPaths::add);
+ return arrayJsonPaths;
+ }
+
+}
diff --git a/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/MdmsFetcher.java b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/MdmsFetcher.java
new file mode 100644
index 00000000000..4447191d736
--- /dev/null
+++ b/core-services/libraries/enc-client/src/main/java/org/egov/encryption/util/MdmsFetcher.java
@@ -0,0 +1,67 @@
+package org.egov.encryption.util;
+
+import lombok.extern.slf4j.Slf4j;
+import net.minidev.json.JSONArray;
+import org.egov.common.contract.request.RequestInfo;
+import org.egov.common.utils.MultiStateInstanceUtil;
+import org.egov.encryption.config.EncClientConstants;
+import org.egov.encryption.config.EncProperties;
+import org.egov.encryption.config.ErrorConstants;
+import org.egov.mdms.model.*;
+import org.egov.tracer.model.CustomException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+import org.slf4j.MDC;
+import java.util.Arrays;
+
+@Slf4j
+@Component
+public class MdmsFetcher {
+
+ @Autowired
+ private EncProperties encProperties;
+ @Autowired
+ private RestTemplate restTemplate;
+
+ @Autowired
+ private MultiStateInstanceUtil multiStateInstanceUtil;
+
+ public static final String TENANTID_MDC_STRING = "TENANTID";
+
+ public JSONArray getSecurityMdmsForFilter(String filter) {
+ return getMdmsForFilter(filter, EncClientConstants.MDMS_SECURITY_POLICY_MASTER_NAME);
+ }
+
+ public JSONArray getMaskingMdmsForFilter(String filter) {
+ return getMdmsForFilter(filter, EncClientConstants.MDMS_MASKING_PATTERN_MASTER_NAME);
+ }
+
+ public JSONArray getMdmsForFilter(String filter, String masterName) {
+ MasterDetail masterDetail = MasterDetail.builder().name(masterName)
+ .filter(filter).build();
+ ModuleDetail moduleDetail = ModuleDetail.builder().moduleName(EncClientConstants.MDMS_MODULE_NAME)
+ .masterDetails(Arrays.asList(masterDetail)).build();
+ MdmsCriteria mdmsCriteria = MdmsCriteria.builder().tenantId(encProperties.getStateLevelTenantId())
+ .moduleDetails(Arrays.asList(moduleDetail)).build();
+
+ MdmsCriteriaReq mdmsCriteriaReq = MdmsCriteriaReq.builder().requestInfo(RequestInfo.builder().build())
+ .mdmsCriteria(mdmsCriteria).build();
+ if(multiStateInstanceUtil.getIsEnvironmentCentralInstance()){
+ MDC.put(TENANTID_MDC_STRING, encProperties.getStateLevelTenantId());
+ }
+
+ try {
+ ResponseEntity response =
+ restTemplate.postForEntity(encProperties.getEgovMdmsHost() + encProperties.getEgovMdmsSearchEndpoint(),
+ mdmsCriteriaReq, MdmsResponse.class);
+ return response.getBody().getMdmsRes().get(EncClientConstants.MDMS_MODULE_NAME)
+ .get(masterName);
+ } catch (Exception e) {
+ log.error(ErrorConstants.MDMS_FETCH_ERROR_MESSAGE, e);
+ throw new CustomException(ErrorConstants.MDMS_FETCH_ERROR, ErrorConstants.MDMS_FETCH_ERROR_MESSAGE);
+ }
+ }
+
+}
diff --git a/core-services/libraries/enc-client/src/main/resources/enc.properties b/core-services/libraries/enc-client/src/main/resources/enc.properties
index 0159a0fc408..f756a7c6675 100644
--- a/core-services/libraries/enc-client/src/main/resources/enc.properties
+++ b/core-services/libraries/enc-client/src/main/resources/enc.properties
@@ -1,13 +1,14 @@
#------------egov-enc-service config----------------#
-egov.enc.host=http://localhost:1234
+egov.enc.host=https://msewapunjab.niua.org/
egov.enc.encrypt.endpoint=/egov-enc-service/crypto/v1/_encrypt
egov.enc.decrypt.endpoint=/egov-enc-service/crypto/v1/_decrypt
#----------------MDMS config---------------------#
-egov.mdms.host=https://dev.digit.org
+egov.mdms.host=https://msewapunjab.niua.org/
egov.mdms.search.endpoint=/egov-mdms-service/v1/_search
-egov.state.level.tenant.id=pb
+state.level.tenant.id=pb
+default.encrypt.data.type=Normal
#-----------Kafka Audit Topic Name------------#
kafka.topic.audit=audit_data
diff --git a/core-services/libraries/enc-client/src/test/java/org/egov/encryption/EncryptionServiceImplTest.java b/core-services/libraries/enc-client/src/test/java/org/egov/encryption/EncryptionServiceImplTest.java
index d061b84798b..0fe09c2691b 100644
--- a/core-services/libraries/enc-client/src/test/java/org/egov/encryption/EncryptionServiceImplTest.java
+++ b/core-services/libraries/enc-client/src/test/java/org/egov/encryption/EncryptionServiceImplTest.java
@@ -4,6 +4,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
+import org.egov.common.contract.request.RequestInfo;
import org.egov.common.contract.request.Role;
import org.egov.common.contract.request.User;
import org.junit.Before;
@@ -22,11 +23,10 @@
//@SpringBootTest(classes = TestConfiguration.class)
public class EncryptionServiceImplTest {
- @Autowired
- private EncryptionServiceImpl encryptionServiceImpl;
-
ObjectMapper mapper;
User user;
+ @Autowired
+ private EncryptionServiceImpl encryptionServiceImpl;
@Before
public void init() throws InstantiationException, IllegalAccessException, IOException {
@@ -42,7 +42,7 @@ public void init() throws InstantiationException, IllegalAccessException, IOExce
@Ignore
@Test
public void encryptValueTest() throws IOException {
- log.info( encryptionServiceImpl.encryptValue(1, "pb", "Normal") );
+ log.info(encryptionServiceImpl.encryptValue(1, "pb", "Normal"));
}
@Ignore
@@ -61,40 +61,43 @@ public void encryptJsonUsingKey() throws IOException {
@Ignore
@Test
public void decryptJsonArrayUsingRoles() throws IOException {
+ RequestInfo requestInfo = new RequestInfo();
JsonNode ciphertext = mapper.readTree("[{\"User\":{\"mobileNumber\":\"341642|WfYfJPRug15R2wFh17PlQr5d9YhNkFk1" +
"\",\"name\":\"341642|Ca5NbGHu3aB2ufjrNfZarW1VGBA=\"," +
"\"userName\":\"341642|Ca5NbGHu3aB2ufjrNfZarW1VGBA=\",\"gender\":\"male\",\"active\":true," +
- "\"type\":\"CITIZEN\",\"password\":\"password\"},\"RequestInfo\":{\"api_id\":\"1\",\"ver\":\"1\"," +
- "\"ts\":null,\"action\":\"create\",\"did\":\"\",\"key\":\"\",\"msg_id\":\"\",\"requester_id\":\"\"," +
- "\"auth_token\":null}}]");
+ "\"type\":\"CITIZEN\",\"password\":\"password\"}}]");
User user = User.builder().roles(Arrays.asList(Role.builder().code("GRO").build())).build();
- JsonNode plaintext = encryptionServiceImpl.decryptJson(ciphertext, "PGR-Complaints-Report", user);
+ requestInfo.setUserInfo(user);
+ JsonNode plaintext = encryptionServiceImpl.decryptJson(requestInfo, ciphertext, "PGR-Complaints-Report",
+ "Report");
log.info(plaintext.toString());
}
@Ignore
@Test
public void decryptJsonObjectUsingRoles() throws IOException {
+ RequestInfo requestInfo = new RequestInfo();
JsonNode ciphertext = mapper.readTree("{\"User\":{\"mobileNumber\":\"341642|WfYfJPRug15R2wFh17PlQr5d9YhNkFk1" +
"\",\"name\":\"341642|Ca5NbGHu3aB2ufjrNfZarW1VGBA=\"," +
"\"userName\":\"341642|Ca5NbGHu3aB2ufjrNfZarW1VGBA=\",\"gender\":\"male\",\"active\":true," +
- "\"type\":\"CITIZEN\",\"password\":\"password\"},\"RequestInfo\":{\"api_id\":\"1\",\"ver\":\"1\"," +
- "\"ts\":null,\"action\":\"create\",\"did\":\"\",\"key\":\"\",\"msg_id\":\"\",\"requester_id\":\"\"," +
- "\"auth_token\":null}}");
+ "\"type\":\"CITIZEN\",\"password\":\"password\"}}");
User user = User.builder().roles(Arrays.asList(Role.builder().code("GRO").build())).build();
- JsonNode plaintext = encryptionServiceImpl.decryptJson(ciphertext, "PGR-Complaints-Report", user, JsonNode.class);
+ requestInfo.setUserInfo(user);
+ JsonNode plaintext = encryptionServiceImpl.decryptJson(requestInfo, ciphertext, "PGR-Complaints-Report",
+ "Report", JsonNode.class);
log.info(plaintext.toString());
}
@Ignore
@Test
public void test() throws IOException {
+ RequestInfo requestInfo = new RequestInfo();
Map data = new HashMap<>();
data.put("name", "341642|Ca5NbGHu3aB2ufjrNfZarW1VGBA=");
data.put("mobileNumber", "341642|WfYfJPRug15R2wFh17PlQr5d9YhNkFk1");
user.setRoles(Arrays.asList(Role.builder().code("CITIZEN").build()));
-
- data = encryptionServiceImpl.decryptJson(data, "User", user, Map.class);
+ requestInfo.setUserInfo(user);
+ data = encryptionServiceImpl.decryptJson(requestInfo, data, "User", "UserSearch", Map.class);
log.info(String.valueOf(data));
}
diff --git a/core-services/libraries/enc-client/src/test/java/org/egov/encryption/util/JSONBrowseUtilTest.java b/core-services/libraries/enc-client/src/test/java/org/egov/encryption/util/JSONBrowseUtilTest.java
index a4bf31afd8d..4bdb9050d81 100644
--- a/core-services/libraries/enc-client/src/test/java/org/egov/encryption/util/JSONBrowseUtilTest.java
+++ b/core-services/libraries/enc-client/src/test/java/org/egov/encryption/util/JSONBrowseUtilTest.java
@@ -3,14 +3,13 @@
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ValueNode;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
@Slf4j
public class JSONBrowseUtilTest {
@@ -25,7 +24,7 @@ public void init() {
@Test
public void test() throws IOException {
JsonNode jsonNode = mapper.readTree("{\"asd\" : \"qwe\"}");
- jsonNode = JSONBrowseUtil.mapValues(jsonNode, v -> ((String) v).length() );
+ jsonNode = JSONBrowseUtil.mapValues(jsonNode, v -> ((String) v).length());
JsonNode expectedNode = mapper.readTree("{\"asd\" : \"3\"}");
diff --git a/core-services/libraries/enc-client/src/test/java/org/egov/encryption/util/JacksonUtilsTest.java b/core-services/libraries/enc-client/src/test/java/org/egov/encryption/util/JacksonUtilsTest.java
index 15f6770100c..93c474420dd 100644
--- a/core-services/libraries/enc-client/src/test/java/org/egov/encryption/util/JacksonUtilsTest.java
+++ b/core-services/libraries/enc-client/src/test/java/org/egov/encryption/util/JacksonUtilsTest.java
@@ -214,5 +214,4 @@ public void test1() throws IOException {
}
-
}
\ No newline at end of file
diff --git a/core-services/libraries/mdms-client/bin/pom.xml b/core-services/libraries/mdms-client/bin/pom.xml
new file mode 100644
index 00000000000..2703d27de82
--- /dev/null
+++ b/core-services/libraries/mdms-client/bin/pom.xml
@@ -0,0 +1,138 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.22.RELEASE
+
+
+ org.egov
+ mdms-client
+ 0.0.3-SNAPSHOT
+
+
+ repo.egovernments.org
+ eGov ERP Releases Repository
+ https://nexus-repo.egovernments.org/nexus/content/repositories/releases/
+
+
+ repo.egovernments.org
+ eGov ERP Snapshots Repository
+ https://nexus-repo.egovernments.org/nexus/content/repositories/snapshots/
+
+
+
+ 2.17.1
+ UTF-8
+ 1.8
+ UTF-8
+ 3.3.9
+ 1.18.8
+ 2.6
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ commons-lang
+ commons-lang
+ ${commons-lang-version}
+
+
+ org.apache.commons
+ commons-lang3
+ 3.0
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.egov.services
+ services-common
+ 0.9.0
+
+
+ com.jayway.jsonpath
+ json-path
+ 2.2.0
+
+
+ org.json
+ json
+ 20160810
+
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-yaml
+ 2.7.9
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.7.9
+
+
+ org.egov.services
+ tracer
+ 1.1.4-SNAPSHOT
+
+
+
+
+ repo.egovernments.org.snapshots
+ eGov ERP Snapshots Repository
+ https://nexus-repo.egovernments.org/nexus/content/repositories/snapshots/
+
+
+ repo.egovernments.org
+ eGov ERP Releases Repository
+ https://nexus-repo.egovernments.org/nexus/content/repositories/releases/
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+