Skip to content

Commit

Permalink
Added audits during software upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
HimajaDhanyamraju2 committed Aug 23, 2022
1 parent cf32a34 commit ab67633
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import io.mosip.registration.update.SoftwareUpdateHandler;
import io.mosip.registration.util.restclient.AuthTokenUtilService;
import io.mosip.registration.util.restclient.ServiceDelegateUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.stereotype.Component;
Expand All @@ -35,7 +37,11 @@
import io.mosip.kernel.core.exception.ExceptionUtils;
import io.mosip.kernel.core.logger.spi.Logger;
import io.mosip.kernel.core.util.DateUtils;
import io.mosip.registration.audit.AuditManagerService;
import io.mosip.registration.config.AppConfig;
import io.mosip.registration.constants.AuditEvent;
import io.mosip.registration.constants.AuditReferenceIdTypes;
import io.mosip.registration.constants.Components;
import io.mosip.registration.constants.RegistrationConstants;
import io.mosip.registration.context.SessionContext;
import io.mosip.registration.controller.auth.LoginController;
Expand All @@ -62,6 +68,9 @@ public class ClientApplication extends Application {
private static String applicationStartTime;
private static boolean syncCompleted = false;

@Autowired
private AuditManagerService auditFactory;

@Override
public void init() throws Exception {
try { //Do heavy lifting here
Expand Down Expand Up @@ -166,6 +175,9 @@ private void upgradeLocalDatabase() {
}

if(responseDTO.getSuccessResponseDTO() != null) {
auditFactory.audit(AuditEvent.CLIENT_DB_UPGRADE_SCRIPTS, Components.CLIENT_UPGRADE,
RegistrationConstants.APPLICATION_NAME, AuditReferenceIdTypes.APPLICATION_ID.getReferenceTypeId());

notifyPreloader(new ClientPreLoaderNotification(responseDTO.getSuccessResponseDTO().getMessage()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,12 @@ public enum AuditEvent {
REG_BLOCKLISTED_WORD_ACCEPTED("REG-EVT-102", USER_EVENT.getCode(), "REG_BLOCKLISTED_WORD_ACCEPTED",
"Demographic Details : A blocklisted word has been accepted in Registration"),
REG_BLOCKLISTED_WORD_REJECTED("REG-EVT-103", USER_EVENT.getCode(), "REG_BLOCKLISTED_WORD_REJECTED",
"Demographic Details : A blocklisted word has been rejected in Registration");
"Demographic Details : A blocklisted word has been rejected in Registration"),

CLIENT_UPGRADE_JARS_DOWNLOADED("REG-UPG-001", USER_EVENT.getCode(), "CLIENT_UPGRADE_JARS_DOWNLOADED",
"Client Upgrade: Successfully downloaded all the upgrade jars"),
CLIENT_DB_UPGRADE_SCRIPTS("REG-UPG-001", USER_EVENT.getCode(), "CLIENT_DB_UPGRADE_SCRIPTS",
"Client Upgrade: SQL scripts execution success");

/**
* The constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public enum Components {
MDM_CAPTURE_FAIELD("REG-MOD-148","capture failed"),
MDM_CAPTURE_SUCESS("REG-MOD-149","capture successfull"),
MDM_NO_DEVICE_AVAILABLE("REG-MOD-150","no device found"),
MDM_DEVICE_FOUND("REG-MOD-151","Device found");
MDM_DEVICE_FOUND("REG-MOD-151","Device found"),

CLIENT_UPGRADE("REG-MOD-152", "Client Upgrade");

/**
* The constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.HashMap;
Expand All @@ -26,7 +25,6 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
Expand All @@ -38,7 +36,11 @@
import io.mosip.kernel.core.util.DateUtils;
import io.mosip.kernel.core.util.FileUtils;
import io.mosip.kernel.logger.logback.util.MetricTag;
import io.mosip.registration.audit.AuditManagerService;
import io.mosip.registration.config.AppConfig;
import io.mosip.registration.constants.AuditEvent;
import io.mosip.registration.constants.AuditReferenceIdTypes;
import io.mosip.registration.constants.Components;
import io.mosip.registration.constants.LoggerConstants;
import io.mosip.registration.constants.RegistrationConstants;
import io.mosip.registration.context.ApplicationContext;
Expand Down Expand Up @@ -99,9 +101,9 @@ public class SoftwareUpdateHandler extends BaseService {

@Autowired
private GlobalParamService globalParamService;

@Autowired
private Environment environment;
private AuditManagerService auditFactory;


public ResponseDTO updateDerbyDB() {
Expand Down Expand Up @@ -276,6 +278,9 @@ private void update() throws Exception {
}
}

auditFactory.audit(AuditEvent.CLIENT_UPGRADE_JARS_DOWNLOADED, Components.CLIENT_UPGRADE,
RegistrationConstants.APPLICATION_NAME, AuditReferenceIdTypes.APPLICATION_ID.getReferenceTypeId());

setServerManifest(null);
setLatestVersion(null);

Expand Down

0 comments on commit ab67633

Please sign in to comment.