Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ public void getAutoLogoutPopupTimeout(@NonNull AuthResponsePigeon.Result<String>

@Override
public void getRolesByUserId(@NonNull String userId, @NonNull AuthResponsePigeon.Result<List<String>> result) {
auditManagerService.audit(AuditEvent.FETCH_USR_ROLE, Components.LOGIN);
try {
List<String> roles = loginService.getRolesByUserId(userId);
result.success(roles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ public void saveOperatorBiometrics(@NonNull BiometricsPigeon.Result<String> resu
public void addBioException(@NonNull String fieldId, @NonNull String modality, @NonNull String attribute,
@NonNull BiometricsPigeon.Result<String> result) {
try {
auditManagerService.audit(AuditEvent.REG_BIO_EXCEPTION_MARKING, Components.REGISTRATION);
if(fieldId.equals(OPERATOR_BIOMETRICS)){


Expand Down Expand Up @@ -589,6 +590,7 @@ public void addBioException(@NonNull String fieldId, @NonNull String modality, @
public void removeBioException(@NonNull String fieldId, @NonNull String modality, @NonNull String attribute,
@NonNull BiometricsPigeon.Result<String> result) {
try {
auditManagerService.audit(AuditEvent.REG_BIO_EXCEPTION_REMOVING, Components.REGISTRATION);
if(fieldId.equals(OPERATOR_BIOMETRICS)){
OPERATOR_EXCEPTIONS.remove(attribute);

Expand Down Expand Up @@ -940,6 +942,12 @@ private void rcapture(String callbackId, String deviceId) {
}

try {
auditManagerService.auditWithArguments(
AuditEvent.REG_BIO_SCAN,
Components.REGISTRATION.getId(),
Components.REGISTRATION.getName(),
String.valueOf(currentModality)
);
Intent intent = new Intent();
// callbackId = callbackId.replace("\\.info","");
intent.setAction(callbackId + RegistrationConstants.R_CAPTURE_INTENT_ACTION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import javax.inject.Inject;
import javax.inject.Singleton;

import io.mosip.registration.clientmanager.constant.AuditEvent;
import io.mosip.registration.clientmanager.constant.Components;
import io.mosip.registration.clientmanager.dto.registration.RegistrationDto;
import io.mosip.registration.clientmanager.repository.GlobalParamRepository;
import io.mosip.registration.clientmanager.spi.AuditManagerService;
Expand Down Expand Up @@ -44,6 +46,7 @@ public DemographicsDetailsApi(RegistrationService registrationService, AuditMana
@Override
public void addDemographicField(@NonNull String fieldId, @NonNull String value, @NonNull DemographicsDataPigeon.Result<String> result) {
try {
auditManagerService.audit(AuditEvent.SAVE_DETAIL_TO_DTO, Components.REGISTRATION);
this.registrationService.getRegistrationDto().addDemographicField(fieldId, value);
result.success("Ok");
} catch (Exception e) {
Expand Down Expand Up @@ -81,6 +84,7 @@ public void getHashValue(@NonNull byte[] bytes, @NonNull DemographicsDataPigeon.
@Override
public void addSimpleTypeDemographicField(@NonNull String fieldId, @NonNull String value, @NonNull String language, @NonNull DemographicsDataPigeon.Result<Void> result) {
try {
auditManagerService.audit(AuditEvent.SAVE_DETAIL_TO_DTO, Components.REGISTRATION);
this.registrationService.getRegistrationDto().addDemographicField(fieldId, value, language);
} catch (Exception e) {
Log.e(getClass().getSimpleName(), "Add simple type field failed!" + Arrays.toString(e.getStackTrace()));
Expand Down Expand Up @@ -116,6 +120,7 @@ public void getSimpleTypeDemographicField(@NonNull String fieldId, @NonNull Stri
@Override
public void setDateField(@NonNull String fieldId, @NonNull String subType, @NonNull String day, @NonNull String month, @NonNull String year, @NonNull DemographicsDataPigeon.Result<Void> result) {
try {
auditManagerService.audit(AuditEvent.SAVE_DETAIL_TO_DTO, Components.REGISTRATION);
this.registrationService.getRegistrationDto().setDateField(fieldId, subType, day, month, year);
} catch (Exception e) {
Log.e(getClass().getSimpleName(), "Add date field failed!" + Arrays.toString(e.getStackTrace()));
Expand All @@ -134,6 +139,7 @@ public void removeDemographicField(@NonNull String fieldId, @NonNull Demographic
@Override
public void setConsentField(@NonNull String consentData, @NonNull DemographicsDataPigeon.Result<Void> result) {
try {
auditManagerService.audit(AuditEvent.SAVE_DETAIL_TO_DTO, Components.REGISTRATION);
this.registrationService.getRegistrationDto().setConsent(consentData);
} catch (Exception e) {
Log.e(getClass().getSimpleName(), "Add consent dto failed!" + Arrays.toString(e.getStackTrace()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void getMachineDetails(@NonNull MachinePigeon.Result<MachinePigeon.Machin

@Override
public void getCenterName(@NonNull String regCenterId, @NonNull String langCode, @NonNull MachinePigeon.Result<String> result) {
auditManagerService.audit(AuditEvent.FETCH_CNTR_NAME, Components.LOGIN);
List<RegistrationCenter> registrationCenterList = new ArrayList<>();
RegistrationCenter registrationCenter;
String regCenter = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void getUserDetailsSync(@NonNull Boolean isManualSync, @NonNull String jo
try {
masterDataService.syncUserDetails(() -> {
auditManagerService.audit(
AuditEvent.SYNC_USER_MAPPING,
AuditEvent.SYNC_USER_DETAILS,
Components.REGISTRATION
);
Log.i(TAG, "User details sync Completed.");
Expand Down Expand Up @@ -435,6 +435,11 @@ public void getNextSyncTimeByJobId(@NonNull String jobId, @NonNull MasterDataSyn

@Override
public void getActiveSyncJobs(@NonNull MasterDataSyncPigeon.Result<List<String>> result) {
try {
auditManagerService.audit(AuditEvent.SYNCJOB_INFO_FETCH, Components.JOB_SERVICE);
} catch (Exception e) {
Log.e(TAG, "Audit logging failed for SYNCJOB_INFO_FETCH", e);
}
List<SyncJobDef> list = syncJobDefRepository.getActiveSyncJobs();
List<String> value = new ArrayList<>();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public void inProgress(String RID) {
public void onComplete(String RID, PacketTaskStatus status) {
if (status.equals(PacketTaskStatus.SYNC_COMPLETED) || status.equals(PacketTaskStatus.SYNC_ALREADY_COMPLETED)) {
remainingPack[1] += 1;
auditManagerService.audit(AuditEvent.PACKET_SYNCED_TO_SERVER, Components.REG_PACKET_LIST);
}
remainingPack[0] -= 1;

Expand Down Expand Up @@ -151,7 +152,7 @@ public void uploadPacketAll(@NonNull List<String> packetIds, @NonNull PacketAuth
CustomToast newToast = new CustomToast(activity);
for (String value : packetIds) {
try {
auditManagerService.audit(AuditEvent.UPLOAD_PACKET, Components.REG_PACKET_LIST);
auditManagerService.audit(AuditEvent.PACKET_UPLOAD, Components.REG_PACKET_LIST);
Integer remaining = packetSize - remainingPack[0];
newToast.setText(String.format("Upload Packet Status : %s/%s Processed", remaining.toString(), packetSize.toString()));
newToast.showToast();
Expand All @@ -167,7 +168,7 @@ public void inProgress(String RID) {
public void onComplete(String RID, PacketTaskStatus status) {
if (status.equals(PacketTaskStatus.UPLOAD_COMPLETED) || status.equals(PacketTaskStatus.UPLOAD_ALREADY_COMPLETED)) {
remainingPack[1] += 1;
auditManagerService.audit(AuditEvent.PACKET_UPLOAD, Components.REGISTRATION);
auditManagerService.audit(AuditEvent.PACKET_UPLOADED, Components.REG_PACKET_LIST);
}
remainingPack[0] -= 1;

Expand All @@ -192,6 +193,7 @@ public void onComplete(String RID, PacketTaskStatus status) {
});
} catch (Exception e) {
Log.e(getClass().getSimpleName(), e.getMessage());
auditManagerService.audit(AuditEvent.PACKET_INTERNAL_ERROR, Components.REG_PACKET_LIST, e.getMessage());
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

e.getMessage() can return null, silently passing null to the audit method.

Exception.getMessage() returns null when the exception was constructed without a message (e.g., new IOException(cause)). Depending on the audit(AuditEvent, Components, String) implementation, this could cause an NPE or emit a meaningless "null" string into the audit log.

🛡️ Proposed null-safe fix
-                auditManagerService.audit(AuditEvent.PACKET_INTERNAL_ERROR, Components.REG_PACKET_LIST, e.getMessage());
+                auditManagerService.audit(AuditEvent.PACKET_INTERNAL_ERROR, Components.REG_PACKET_LIST,
+                        e.getMessage() != null ? e.getMessage() : e.getClass().getSimpleName());

Also, the previously flagged inconsistency on this line (PACKET_INTERNAL_ERROR using Components.REGISTRATION instead of Components.REG_PACKET_LIST) has been corrected in the current code — that past review concern is now resolved. ✅

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

In
`@android/app/src/main/java/io/mosip/registration_client/api_services/PacketAuthenticationApi.java`
at line 196, The audit call using
auditManagerService.audit(AuditEvent.PACKET_INTERNAL_ERROR,
Components.REG_PACKET_LIST, e.getMessage()) may pass a null message when
Exception e has no message; change the third argument to a null-safe string
(e.g., use e.getMessage() if non-null else e.toString() or a fixed fallback like
"Exception occurred") so auditManagerService.audit always receives a non-null,
meaningful message; update the call site in PacketAuthenticationApi where
auditManagerService.audit is invoked and keep the same
AuditEvent.PACKET_INTERNAL_ERROR and Components.REG_PACKET_LIST parameters.

}
}
}
Expand All @@ -214,6 +216,7 @@ public void getAllRegistrationPacket(@NonNull PacketAuthPigeon.Result<List<Strin

@Override
public void getAllCreatedRegistrationPacket(@NonNull PacketAuthPigeon.Result<List<String>> result) {
auditManagerService.audit(AuditEvent.PACKET_RETRIEVE, Components.REGISTRATION);
List<String> packets = new ArrayList();
try {
List<Registration> allRegistration = packetService.getRegistrationsByStatus(PacketClientStatus.CREATED.name(), 40);
Expand All @@ -231,12 +234,17 @@ public void getAllCreatedRegistrationPacket(@NonNull PacketAuthPigeon.Result<Lis
@Override
public void updatePacketStatus(@NonNull String packetId, @Nullable String serverStatus, @NonNull String clientStatus, @NonNull PacketAuthPigeon.Result<Void> result) {
registrationRepository.updateStatus(packetId, serverStatus, clientStatus);
auditManagerService.auditWithArguments(AuditEvent.PACKET_STATUS_UPDATE,
Components.REGISTRATION.getId(), Components.REGISTRATION.getName(), clientStatus);
result.success(null);
}

@Override
public void supervisorReview(@NonNull String packetId, @NonNull String supervisorStatus, @NonNull String supervisorComment, @NonNull PacketAuthPigeon.Result<Void> result) {
auditManagerService.audit(AuditEvent.PACKET_UPDATE, Components.REGISTRATION);
registrationRepository.updateSupervisorReview(packetId, supervisorStatus, supervisorComment);
auditManagerService.auditWithArguments(AuditEvent.PACKET_STATUS_UPDATE,
Components.REGISTRATION.getId(), Components.REGISTRATION.getName(), supervisorStatus);
result.success(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import javax.inject.Inject;
import javax.inject.Singleton;

import io.mosip.registration.clientmanager.constant.AuditEvent;
import io.mosip.registration.clientmanager.constant.Components;
import io.mosip.registration.clientmanager.dto.CenterMachineDto;
import io.mosip.registration.clientmanager.entity.RegistrationCenter;
import io.mosip.registration.clientmanager.entity.UserDetail;
Expand Down Expand Up @@ -46,6 +48,7 @@ public UserDetailsApi(LoginService loginService, RegistrationCenterRepository re

@Override
public void validateUser(@NonNull String username, @NonNull String langCode, @NonNull UserPigeon.Result<UserPigeon.User> result) {
auditManagerService.audit(AuditEvent.USER_STATUS_FETCH, Components.LOGIN);
if (username == null || username.trim().length() == 0) {
UserPigeon.User user = new UserPigeon.User.Builder()
.setUserId(username)
Expand All @@ -65,6 +68,7 @@ public void validateUser(@NonNull String username, @NonNull String langCode, @No
result.success(user);
return;
}
auditManagerService.audit(AuditEvent.VALIDATE_USER_ID, Components.LOGIN);
UserDetail userDetail = loginService.getUserDetailsByUserId(username);
CenterMachineDto centerMachineDto = this.masterDataService.getRegistrationCenterMachineDetails();
boolean centerStatus = true;
Expand Down Expand Up @@ -112,11 +116,13 @@ public void validateUser(@NonNull String username, @NonNull String langCode, @No
}

public String getCenterName(String regCenterId, String langCode) {
auditManagerService.audit(AuditEvent.FETCH_CNTR_NAME, Components.LOGIN);
List<RegistrationCenter> registrationCenterList = new ArrayList<>();
RegistrationCenter registrationCenter;
String regCenter = "";
try {
registrationCenter = registrationCenterRepository.getRegistrationCenterByCenterIdAndLangCode(regCenterId, langCode);
auditManagerService.audit(AuditEvent.FETCH_CNTR_DET, Components.LOGIN);
if(registrationCenter != null) {
regCenter = registrationCenter.getName();
return regCenter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public void inProgress(String RID) {
public void onComplete(String RID, PacketTaskStatus status) {
if (status.equals(PacketTaskStatus.SYNC_COMPLETED) || status.equals(PacketTaskStatus.SYNC_ALREADY_COMPLETED)) {
remainingPack[1] += 1;
auditManagerService.audit(AuditEvent.PACKET_SYNCED_TO_SERVER, Components.REG_PACKET_LIST);
}
remainingPack[0] -= 1;

Expand Down Expand Up @@ -148,7 +149,7 @@ public void uploadRegistrationPackets(Context context) {
try {
syncAndUploadInProgressStatus = true;
Log.d(getClass().getSimpleName(), "Uploading " + value.getPacketId());
auditManagerService.audit(AuditEvent.UPLOAD_PACKET, Components.REG_PACKET_LIST);
auditManagerService.audit(AuditEvent.PACKET_UPLOAD, Components.REG_PACKET_LIST);

Integer remaining = packetSize - remainingPack[0];
newToast.setText(String.format("Upload Packet Status : %s/%s Processed", remaining.toString(), packetSize.toString()));
Expand All @@ -165,6 +166,7 @@ public void inProgress(String RID) {
public void onComplete(String RID, PacketTaskStatus status) {
if (status.equals(PacketTaskStatus.UPLOAD_COMPLETED) || status.equals(PacketTaskStatus.UPLOAD_ALREADY_COMPLETED)) {
remainingPack[1] += 1;
auditManagerService.audit(AuditEvent.PACKET_UPLOADED, Components.REG_PACKET_LIST);
}
remainingPack[0] -= 1;

Expand All @@ -190,6 +192,7 @@ public void onComplete(String RID, PacketTaskStatus status) {
} catch (Exception e) {
syncAndUploadInProgressStatus = false;
Log.e(getClass().getSimpleName(), e.getMessage());
auditManagerService.audit(AuditEvent.PACKET_INTERNAL_ERROR, Components.REG_PACKET_LIST, e.getMessage());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ public MasterDataService provideMasterDataService(ObjectMapper objectMapper, Syn
LanguageRepository languageRepository,
JobManagerService jobManagerService,
FileSignatureDao fileSignatureDao, JobTransactionService jobTransactionService, PermittedLocalConfigRepository permittedLocalConfigRepository,
LocalConfigDAO localConfigDAO) {
LocalConfigDAO localConfigDAO, AuditManagerService auditManagerService) {

return new MasterDataServiceImpl(appContext, objectMapper, syncRestService, clientCryptoManagerService,
machineRepository, reasonListRepository, registrationCenterRepository, documentTypeRepository, applicantValidDocRepository,
templateRepository, dynamicFieldRepository, locationRepository,
globalParamRepository, identitySchemaRepository, blocklistedWordRepository, syncJobDefRepository, userDetailRepository,
certificateManagerService, languageRepository, jobManagerService, fileSignatureDao, jobTransactionService, permittedLocalConfigRepository, localConfigDAO);
certificateManagerService, languageRepository, jobManagerService, fileSignatureDao, jobTransactionService, permittedLocalConfigRepository, localConfigDAO, auditManagerService);

}

Expand Down Expand Up @@ -226,9 +226,10 @@ UserInterfaceHelperService provideUserInterfaceHelperService() {
@Singleton
PacketService providePacketService(RegistrationRepository registrationRepository,
IPacketCryptoService packetCryptoService, SyncRestService syncRestService,
MasterDataService masterDataService, GlobalParamRepository globalParamRepository) {
MasterDataService masterDataService, GlobalParamRepository globalParamRepository,
AuditManagerService auditManagerService) {
return new PacketServiceImpl(appContext, registrationRepository, packetCryptoService, syncRestService,
masterDataService, globalParamRepository);
masterDataService, globalParamRepository, auditManagerService);
}

@Provides
Expand Down Expand Up @@ -322,9 +323,10 @@ PreCheckValidatorService providePreCheckValidatorService(SyncJobDefRepository sy
JobTransactionService jobTransactionService,
LocationValidationService locationValidationService,
MasterDataService masterDataService,
RegistrationCenterRepository registrationCenterRepository) {
RegistrationCenterRepository registrationCenterRepository,
AuditManagerService auditManagerService) {
return new PreCheckValidatorServiceImpl(appContext, syncJobDefRepository, globalParamRepository,
jobManagerService, jobTransactionService, locationValidationService, masterDataService,
registrationCenterRepository);
registrationCenterRepository, auditManagerService);
}
}
Loading