Skip to content
Draft
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions db_scripts/mosip_prereg/ddl/user_details.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
-- ================================================================================================
-- MOSIP Pre-Registration PII Security: Canonical User Registry Table
-- Purpose: Centralized surrogate user ID mapping for cr_by/upd_by/cr_appuser_id
-- ================================================================================================
-- This table eliminates plaintext PII replication across the tables
-- Stores: hash(authUserId) -> UUID surrogate mapping + encrypted original for notifications/audit
-- Usage:
-- 1. Resolve: hash(authUserId) -> user_id (fast lookup)
-- 2. Store: user_id in cr_by/upd_by/cr_appuser_id/contact_info fields(instead of plaintext)
-- 3. Recover: decrypt from user_details for notifications/audit

-- ========== CREATE TABLE: Canonical User Registry ==========

CREATE TABLE IF NOT EXISTS prereg.user_details (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add cols like cr_dt etc

user_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
identifier_hash VARCHAR(128) NOT NULL UNIQUE,
identifier_encrypted TEXT
);
Comment on lines +14 to +20

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if there are any other DDL or migration scripts that might populate this table with null values
echo "=== Searching for user_details references in migration/ddl scripts ==="
find . -path "*/db_scripts/*" -name "*.sql" -exec grep -l "user_details" {} \;

echo -e "\n=== Checking entity definition for nullable annotations ==="
cat pre-registration/pre-registration-core/src/main/java/io/mosip/preregistration/core/common/entity/UserDetails.java 2>/dev/null | head -50

Repository: mosip/pre-registration

Length of output: 1266


🏁 Script executed:

# Examine the actual DDL file to confirm NOT NULL constraints
echo "=== Full DDL for user_details table ==="
cat db_scripts/mosip_prereg/ddl/user_details.sql

Repository: mosip/pre-registration

Length of output: 1764


🏁 Script executed:

# Find and examine UserDetailsService to verify repair logic
echo "=== Searching for UserDetailsService ==="
find . -name "UserDetailsService.java" -type f

echo -e "\n=== Checking for repair/null-handling logic ==="
find . -name "UserDetailsService.java" -type f -exec cat {} \; 2>/dev/null | head -300

Repository: mosip/pre-registration

Length of output: 12086


🏁 Script executed:

# Check the main DDL file for any additional constraints or migration info
echo "=== Checking main DDL file ==="
grep -A 20 -B 5 "user_details" db_scripts/mosip_prereg/ddl.sql 2>/dev/null || echo "Pattern not found or file structure differs"

Repository: mosip/pre-registration

Length of output: 336


DDL NOT NULL constraints conflict with repair logic and partial index design.

The DDL declares identifier_encrypted TEXT NOT NULL and cr_dtimes TIMESTAMP NOT NULL, but UserDetailsService.findOrCreateByIdentifier() (lines 252, 255-256) contains explicit null checks and repair logic that attempts to update these fields from null to populated values. Additionally, the partial index idx_prereg_user_details_active filters WHERE identifier_encrypted IS NOT NULL, which is only necessary if the column can contain null values.

This contradiction creates a runtime risk: if the repair logic encounters an existing row with null values, the UPDATE will fail due to the NOT NULL constraint.

Resolve this by either:

  1. Removing NOT NULL constraints to allow the repair logic to function, or
  2. Removing the null-handling repair logic if the table will only be populated through the create path (which always sets these fields).

If migrating legacy data, ensure migration scripts populate these fields before applying the NOT NULL constraints.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@db_scripts/mosip_prereg/ddl/user_details.sql` around lines 14 - 20, The table
DDL conflicts with runtime repair logic in
UserDetailsService.findOrCreateByIdentifier(): either make the table columns
nullable so repair updates can succeed or remove the repair code; to fix
quickly, update the DDL to allow nulls for identifier_encrypted, cr_dtimes, and
encrypted_dtimes (remove NOT NULL on those columns) so the partial index
idx_prereg_user_details_active (which filters WHERE identifier_encrypted IS NOT
NULL) remains valid and the existing repair/update logic in
findOrCreateByIdentifier() (referenced by that method name) can operate;
alternatively, if you choose the other option, remove the null-check/repair
blocks in UserDetailsService.findOrCreateByIdentifier() so the table can keep
NOT NULL constraints and ensure any migration populates those fields before
applying NOT NULL.



-- ========== CREATE INDEXES ==========

-- Primary: UNIQUE constraint covers 99% of lookups
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_prereg_user_details_hash
ON prereg.user_details(identifier_hash);

-- Composite for active user lookups + joins
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_prereg_user_details_active
ON prereg.user_details(user_id) WHERE identifier_encrypted IS NOT NULL;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated


-- ================================================================================================
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public class OtpTransaction {
@Column(name = "upd_dtimes")
private LocalDateTime updDTimes;

public String getEffectiveCrBy() {
return this.crBy;
}

public String getEffectiveUpdBy() {
return this.updBy;
}

@Column(name = "is_deleted")
private Boolean isDeleted;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import io.mosip.preregistration.core.exception.PreIdInvalidForUserIdException;
import io.mosip.preregistration.core.util.AuditLogUtil;
import io.mosip.preregistration.core.util.ValidationUtil;
import io.mosip.preregistration.core.common.service.UserDetailsService;

@Service
public class ApplicationService implements ApplicationServiceIntf {
Expand All @@ -83,6 +84,9 @@ public class ApplicationService implements ApplicationServiceIntf {
@Autowired
ValidationUtil validationUtil;

@Autowired
private UserDetailsService userDetailsService;

/**
* ObjectMapper global object creation
*/
Expand Down Expand Up @@ -332,9 +336,9 @@ public MainResponseDTO<ApplicationResponseDTO> addLostOrUpdateApplication(
appplicationResponse.setApplicationStatusCode(applicationEntity.getApplicationStatusCode());
appplicationResponse.setBookingStatusCode(applicationEntity.getBookingStatusCode());
appplicationResponse.setLangCode(applicationRequest.getLangCode());
appplicationResponse.setCreatedBy(applicationEntity.getCrBy());
appplicationResponse.setCreatedBy(applicationEntity.getEffectiveCrBy());
appplicationResponse.setCreatedDateTime(serviceUtil.getLocalDateString(applicationEntity.getCrDtime()));
appplicationResponse.setUpdatedBy(applicationEntity.getUpdBy());
appplicationResponse.setUpdatedBy(applicationEntity.getEffectiveUpdBy());
appplicationResponse.setUpdatedDateTime(serviceUtil.getLocalDateString(applicationEntity.getUpdDtime()));
mainResponseDTO.setResponse(appplicationResponse);
mainResponseDTO.setResponsetime(serviceUtil.getCurrentResponseTime());
Expand Down Expand Up @@ -422,7 +426,19 @@ public MainResponseDTO<DeleteApplicationDTO> deleteLostOrUpdateApplication(Strin
if (bookingType.equals(BookingTypeCodes.LOST_FORGOTTEN_UIN.toString())
|| bookingType.equals(BookingTypeCodes.UPDATE_REGISTRATION.toString())) {
//userValidation(applicationEntity);
if (!authUserDetails().getUserId().trim().equals(applicationEntity.getCrBy().trim())) {
String authUserId = authUserDetails().getUserId();
String canonicalAuthUserId = null;
try {
io.mosip.preregistration.core.common.entity.UserDetails mappedUser =
userDetailsService.findOrCreateByIdentifier(authUserId);
if (mappedUser != null && mappedUser.getUserId() != null) {
canonicalAuthUserId = mappedUser.getUserId().toString();
}
} catch (Exception ex) {
log.warn(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID,
"Failed to map auth user to canonical UUID: " + authUserId, ex);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
if (canonicalAuthUserId == null || !canonicalAuthUserId.trim().equals(applicationEntity.getEffectiveCrBy().trim())) {
throw new PreIdInvalidForUserIdException(ApplicationErrorCodes.PRG_APP_015.getCode(),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
ApplicationErrorMessages.INVALID_APPLICATION_ID_FOR_USER.getMessage());
}
Expand Down Expand Up @@ -483,7 +499,19 @@ public MainResponseDTO<ApplicationsListDTO> getAllApplicationsForUser() {
response.setVersion(version);
response.setResponsetime(DateTimeFormatter.ofPattern(mosipDateTimeFormat).format(LocalDateTime.now()));
try {
List<ApplicationEntity> applicationEntities = applicationRepository.findByCreatedBy(userId);
// Map auth user ID to canonical UUID for query
String canonicalUserId = userId;
try {
io.mosip.preregistration.core.common.entity.UserDetails mappedUser =
userDetailsService.findOrCreateByIdentifier(userId);
if (mappedUser != null && mappedUser.getUserId() != null) {
canonicalUserId = mappedUser.getUserId().toString();
}
} catch (Exception ex) {
log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID,
"Could not map userId to canonical UUID, using raw userId: " + userId);
}
List<ApplicationEntity> applicationEntities = applicationRepository.findByCreatedBy(canonicalUserId);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Number of applications found for the current user: "+ applicationEntities.size());
applicationsListDTO.setAllApplications(applicationEntities);
response.setResponse(applicationsListDTO);
Expand Down Expand Up @@ -539,7 +567,20 @@ private void userValidation(ApplicationEntity applicationEntity) {
if (list.contains("ROLE_INDIVIDUAL")) {
log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In userValidation method of ApplicationService with applicationId "
+ applicationEntity.getApplicationId() + " and userID " + authUserId);
if (!authUserDetails().getUserId().trim().equals(applicationEntity.getCrBy().trim())) {
// Map auth user to canonical UUID for comparison
String canonicalAuthUserId = null;
try {
io.mosip.preregistration.core.common.entity.UserDetails mappedUser =
userDetailsService.findOrCreateByIdentifier(authUserId);
if (mappedUser != null && mappedUser.getUserId() != null) {
canonicalAuthUserId = mappedUser.getUserId().toString();
}
} catch (Exception ex) {
log.warn(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID,
"Failed to map auth user to canonical UUID: " + authUserId, ex);
}
// Compare canonical UUIDs
if (canonicalAuthUserId == null || !canonicalAuthUserId.trim().equals(applicationEntity.getCrBy().trim())) {
throw new PreIdInvalidForUserIdException(ApplicationErrorCodes.PRG_APP_015.getCode(),
ApplicationErrorMessages.INVALID_APPLICATION_ID_FOR_USER.getMessage());
}
Expand Down Expand Up @@ -582,7 +623,19 @@ public MainResponseDTO<ApplicationsListDTO> getAllApplicationsForUserForBookingT
ApplicationErrorMessages.INVALID_BOOKING_TYPE.getMessage());

}
List<ApplicationEntity> applicationEntities = applicationRepository.findByCreatedByBookingType(userId,
// Map auth user ID to canonical UUID for query
String canonicalUserId = userId;
try {
io.mosip.preregistration.core.common.entity.UserDetails mappedUser =
userDetailsService.findOrCreateByIdentifier(userId);
if (mappedUser != null && mappedUser.getUserId() != null) {
canonicalUserId = mappedUser.getUserId().toString();
}
} catch (Exception ex) {
log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID,
"Could not map userId to canonical UUID, using raw userId: " + userId);
}
List<ApplicationEntity> applicationEntities = applicationRepository.findByCreatedByBookingType(canonicalUserId,
type.toUpperCase());
log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "Number of applications found for the current user: {" + applicationEntities.size() + "} and booking type: {" + type + "}");
applicationsListDTO.setAllApplications(applicationEntities);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import java.util.Collection;
import java.util.List;

import io.mosip.preregistration.core.common.entity.UserDetails;
import io.mosip.preregistration.core.common.service.UserDetailsService;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -71,6 +73,9 @@ public class AppointmentServiceImpl implements AppointmentService {
@Autowired
AnonymousProfileUtil anonymousProfileUtil;

@Autowired
private UserDetailsService userDetailsService;

@Value("${version}")
private String version;

Expand Down Expand Up @@ -163,9 +168,26 @@ private void userValidation(String applicationId) {
throw new AppointmentExecption(ApplicationErrorCodes.PRG_APP_013.getCode(),
ApplicationErrorMessages.NO_RECORD_FOUND.getMessage());
}
if (applicationEntity != null && !authUserId.trim().equals(applicationEntity.getCrBy().trim())) {
throw new AppointmentExecption(AppointmentErrorCodes.INVALID_APP_ID_FOR_USER.getCode(),
AppointmentErrorCodes.INVALID_APP_ID_FOR_USER.getMessage());
if (applicationEntity != null) {
// Map the auth user to canonical UUID for comparison
String canonicalAuthUserId = null;
try {
io.mosip.preregistration.core.common.entity.UserDetails mappedUser =
userDetailsService.findOrCreateByIdentifier(authUserId);
if (mappedUser != null && mappedUser.getUserId() != null) {
canonicalAuthUserId = mappedUser.getUserId().toString();
}
} catch (Exception ex) {
log.warn(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID,
"Failed to map auth user to canonical UUID: " + authUserId, ex);
}

// Compare canonical UUIDs
String expectedCrBy = applicationEntity.getCrBy();
if (canonicalAuthUserId == null || !canonicalAuthUserId.trim().equals(expectedCrBy.trim())) {
throw new AppointmentExecption(AppointmentErrorCodes.INVALID_APP_ID_FOR_USER.getCode(),
AppointmentErrorCodes.INVALID_APP_ID_FOR_USER.getMessage());
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}
}
}
}
Expand Down Expand Up @@ -447,8 +469,23 @@ private ApplicationEntity updateApplicationEntity(String preRegistrationId, Book
try {
return applicationRepostiory.save(applicationEntity);
} catch (Exception ex) {
// Map to canonical UUID if service available
try {
UserDetails mappedUser = userDetailsService.findOrCreateByIdentifier(authUserDetails().getUserId());
if (mappedUser != null && mappedUser.getUserId() != null) {
applicationEntity.setUpdBy(mappedUser.getUserId().toString());
// attempt save again with canonical id
try {
return applicationRepostiory.save(applicationEntity);
} catch (Exception ex2) {
// fall through to logging and throwing below
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}
} catch (Exception e) {
log.warn(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "UserDetails mapping failed for appointment update", e);
}
log.error(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID,
"Failed to update application for the preregistrationId: " + preRegistrationId);
"Failed to update application for the preregistrationId: " + preRegistrationId, ex);
throw new AppointmentExecption(AppointmentErrorCodes.FAILED_TO_UPDATE_APPLICATIONS.getCode(),
String.format(AppointmentErrorCodes.FAILED_TO_UPDATE_APPLICATIONS.getMessage(), preRegistrationId));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
import io.mosip.preregistration.core.util.CryptoUtil;
import io.mosip.preregistration.core.util.ValidationUtil;
import io.mosip.preregistration.demographic.exception.system.SystemFileIOException;
import io.mosip.preregistration.core.common.service.UserDetailsService;

/**
* This class provides the service implementation for Demographic
Expand Down Expand Up @@ -143,6 +144,9 @@ public class DemographicService implements DemographicServiceIntf {
@Autowired
CommonServiceUtil commonServiceUtil;

@Autowired
private UserDetailsService userDetailsService;

/**
* Autowired reference for {@link #AuditLogUtil}
*/
Expand Down Expand Up @@ -422,7 +426,7 @@ public MainResponseDTO<DemographicUpdateResponseDTO> updatePreRegistration(
"JSON validator end time : " + DateUtils.getUTCCurrentDateTimeString());
DemographicEntity demographicEntity = demographicRepository.findBypreRegistrationId(preRegistrationId);
if (!serviceUtil.isNull(demographicEntity)) {
userValidation(userId, demographicEntity.getCreatedBy());
userValidation(userId, demographicEntity.getEffectiveCreatedBy());
if (!serviceUtil.isDemographicBookedOrExpired(demographicEntity, validationUtil)) {
demographicEntity = demographicRepository.update(serviceUtil.prepareDemographicEntityForUpdate(
demographicEntity, demographicRequest, demographicEntity.getStatusCode(),
Expand Down Expand Up @@ -662,7 +666,7 @@ public MainResponseDTO<DeletePreRegistartionDTO> deleteIndividual(String preregI
if (bookingType.equals(BookingTypeCodes.NEW_PREREGISTRATION.toString())) {
DemographicEntity demographicEntity = demographicRepository.findBypreRegistrationId(preregId);
if (!serviceUtil.isNull(demographicEntity)) {
userValidation(userId, demographicEntity.getCreatedBy());
userValidation(userId, demographicEntity.getEffectiveCreatedBy());
if (serviceUtil.checkStatusForDeletion(demographicEntity.getStatusCode())) {
getDocumentServiceToDeleteAllByPreId(preregId);
if ((demographicEntity.getStatusCode().equals(StatusCodes.BOOKED.getCode()))) {
Expand Down Expand Up @@ -869,7 +873,47 @@ public MainResponseDTO<Map<String, String>> getUpdatedDateTimeForPreIds(
public void userValidation(String authUserId, String preregUserId) {
log.info(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "In getDemographicData method of userValidation with priid "
+ preregUserId + " and userID " + authUserId);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
if (!authUserId.trim().equals(preregUserId.trim())) {
// Map the auth user to canonical UUID for comparison
String canonicalAuthUserId = null;
try {
io.mosip.preregistration.core.common.entity.UserDetails mappedUser =
userDetailsService.findOrCreateByIdentifier(authUserId);
if (mappedUser != null && mappedUser.getUserId() != null) {
canonicalAuthUserId = mappedUser.getUserId().toString();
}
} catch (Exception ex) {
log.warn(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID,
"Failed to map auth user to canonical UUID: " + authUserId, ex);
}

// Compare using canonical UUID
if (canonicalAuthUserId == null) {
throw new PreIdInvalidForUserIdException(DemographicErrorCodes.PRG_PAM_APP_017.getCode(),
DemographicErrorMessages.INVALID_PREID_FOR_USER.getMessage());
}

String trimmedPreregUserId = preregUserId != null ? preregUserId.trim() : "";
String trimmedCanonicalAuthUserId = canonicalAuthUserId.trim();

// Check if preregUserId is already a UUID (new data) or a raw identifier (old data)
if (!trimmedPreregUserId.equals(trimmedCanonicalAuthUserId)) {
// Try mapping preregUserId to canonical UUID in case it's old data
// (if database stores raw identifier in createdBy field)
try {
io.mosip.preregistration.core.common.entity.UserDetails mappedPreregUser =
userDetailsService.findOrCreateByIdentifier(trimmedPreregUserId);
if (mappedPreregUser != null && mappedPreregUser.getUserId() != null) {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
String canonicalPreregUserId = mappedPreregUser.getUserId().toString();
if (canonicalPreregUserId.equals(trimmedCanonicalAuthUserId)) {
// Match found after mapping both IDs to canonical UUIDs
return;
}
}
} catch (Exception ex) {
log.debug(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID,
"Could not map preregUserId to canonical UUID, might already be a UUID: " + trimmedPreregUserId);
}
// No match found in either direct comparison or mapping
throw new PreIdInvalidForUserIdException(DemographicErrorCodes.PRG_PAM_APP_017.getCode(),
DemographicErrorMessages.INVALID_PREID_FOR_USER.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import javax.xml.bind.DatatypeConverter;

import io.mosip.preregistration.core.common.entity.UserDetails;
import io.mosip.preregistration.core.common.service.UserDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -99,6 +101,9 @@ public class OTPManager {
@Autowired
NotificationServiceUtil notification;

@Autowired
private UserDetailsService userDetailsService;

/**
* Generate OTP with information of {@link MediaType } and OTP generation
* time-out.
Expand Down Expand Up @@ -134,6 +139,16 @@ public boolean sendOtp(MainRequestDTO<OtpRequestDTO> requestDTO, String channelT
OtpTransaction otpTxn = otpRepo.findTopByOtpHashAndStatusCode(otpHash, PreRegLoginConstant.ACTIVE_STATUS);
otpTxn.setOtpHash(otpHash);
otpTxn.setUpdBy(environment.getProperty(PreRegLoginConstant.MOSIP_PRE_REG_CLIENTID));
try {
UserDetails mappedUser = userDetailsService.findOrCreateByIdentifier(environment.getProperty(PreRegLoginConstant.MOSIP_PRE_REG_CLIENTID));
if (mappedUser != null && mappedUser.getUserId() != null) {
otpTxn.setUpdBy(mappedUser.getUserId().toString());
} else {
otpTxn.setUpdBy(environment.getProperty(PreRegLoginConstant.MOSIP_PRE_REG_CLIENTID));
}
} catch (Exception e) {
logger.warn(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "UserDetails mapping failed for otp update", e);
}
otpTxn.setUpdDTimes(DateUtils.getUTCCurrentDateTime());
otpTxn.setExpiryDtimes(DateUtils.getUTCCurrentDateTime().plusSeconds(
environment.getProperty(PreRegLoginConstant.MOSIP_KERNEL_OTP_EXPIRY_TIME, Long.class)));
Expand All @@ -144,8 +159,18 @@ public boolean sendOtp(MainRequestDTO<OtpRequestDTO> requestDTO, String channelT
txn.setId(UUID.randomUUID().toString());
txn.setRefId(hash(userId));
txn.setOtpHash(otpHash);
txn.setCrBy(environment.getProperty(PreRegLoginConstant.MOSIP_PRE_REG_CLIENTID));
txn.setCrDtimes(DateUtils.getUTCCurrentDateTime());
txn.setCrBy(environment.getProperty(PreRegLoginConstant.MOSIP_PRE_REG_CLIENTID)); // Map the client id to canonical user id, and store canonical id into cr_by
try {
UserDetails mappedUser = userDetailsService.findOrCreateByIdentifier(environment.getProperty(PreRegLoginConstant.MOSIP_PRE_REG_CLIENTID));
if (mappedUser != null && mappedUser.getUserId() != null) {
txn.setCrBy(mappedUser.getUserId().toString());
} else {
txn.setCrBy(environment.getProperty(PreRegLoginConstant.MOSIP_PRE_REG_CLIENTID));
}
} catch (Exception e) {
logger.warn(LOGGER_SESSIONID, LOGGER_IDTYPE, LOGGER_ID, "UserDetails mapping failed for otp create", e);
txn.setCrBy(environment.getProperty(PreRegLoginConstant.MOSIP_PRE_REG_CLIENTID));
} txn.setCrDtimes(DateUtils.getUTCCurrentDateTime());
txn.setGeneratedDtimes(DateUtils.getUTCCurrentDateTime());
txn.setExpiryDtimes(DateUtils.getUTCCurrentDateTime().plusSeconds(
environment.getProperty(PreRegLoginConstant.MOSIP_KERNEL_OTP_EXPIRY_TIME, Long.class)));
Expand Down
Loading
Loading