Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES-558: Merged the changes from ES-842 to release-1.2.1.x #1312

Merged
merged 9 commits into from
Aug 26, 2024
1 change: 1 addition & 0 deletions .github/workflows/push-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
- 1.*
- develop
- MOSIP*
- ES-842

jobs:
build-maven-authentication:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.mosip.authentication.common.service.helper.AuditHelper;
import io.mosip.authentication.common.service.repository.IdentityCacheRepository;
import io.mosip.authentication.common.service.spi.idevent.CredentialStoreService;
import io.mosip.authentication.common.service.websub.impl.RemoveIdStatusEventPublisher;
import io.mosip.authentication.core.constant.AuditEvents;
import io.mosip.authentication.core.constant.AuditModules;
import io.mosip.authentication.core.constant.IdAuthCommonConstants;
Expand Down Expand Up @@ -75,6 +76,9 @@ static interface ConsumerWithBusinessException<T,R> {

@Autowired
private CredentialStoreService credStorService;

@Autowired
private RemoveIdStatusEventPublisher removeIdStatusEventPublisher;

/* (non-Javadoc)
* @see io.mosip.authentication.core.spi.idevent.service.IdChangeEventHandlerService#handleIdEvent(java.util.List)
Expand Down Expand Up @@ -183,9 +187,9 @@ private void handleRemoveId(EventModel eventModel) throws IdAuthenticationBusine
Event event = eventModel.getEvent();
Map<String, Object> additionalData = event.getData();
String idHash = (String) additionalData.get(ID_HASH);
Optional<IdentityEntity> identityEntityOpt = identityCacheRepo.findById(idHash);
if(identityEntityOpt.isPresent()) {
identityCacheRepo.delete(identityEntityOpt.get());
if (idHash != null && !idHash.isEmpty() && identityCacheRepo.existsById(idHash)) {
identityCacheRepo.deleteById(idHash);
removeIdStatusEventPublisher.publishRemoveIdStatusEvent(idHash);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.mosip.authentication.common.service.impl.idevent;

import java.util.Map;

import io.mosip.authentication.common.service.websub.dto.EventInterface;
import lombok.Data;

/**
* Instantiates a new remove id status event.
*
* @author Ritik Jain
*/
@Data
public class RemoveIdStatusEvent implements EventInterface {

/** The id. */
private String id;

/** The timestamp. */
private String timestamp;

/** The data. */
private Map<String, Object> data;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package io.mosip.authentication.common.service.websub.impl;

import static io.mosip.authentication.core.constant.IdAuthConfigKeyConstants.REMOVE_ID_STATUS_TOPIC;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import io.mosip.authentication.common.service.helper.WebSubHelper;
import io.mosip.authentication.common.service.impl.idevent.RemoveIdStatusEvent;
import io.mosip.authentication.core.constant.IdAuthCommonConstants;
import io.mosip.authentication.core.logger.IdaLogger;
import io.mosip.kernel.core.logger.spi.Logger;
import io.mosip.kernel.core.util.DateUtils;

/**
* The Class RemoveIdStatusEventPublisher.
*
* @author Ritik Jain
*/
@Component
public class RemoveIdStatusEventPublisher extends BaseWebSubEventsInitializer {

/** The Constant logger. */
private static final Logger logger = IdaLogger.getLogger(RemoveIdStatusEventPublisher.class);

/** The remove id status topic. */
@Value("${" + REMOVE_ID_STATUS_TOPIC + "}")
private String removeIdStatusTopic;

/** The web sub event publish helper. */
@Autowired
private WebSubHelper webSubHelper;

private static final String ID_HASH = "id_hash";

/**
* Do subscribe.
*/
@Override
protected void doSubscribe() {
// Nothing to do here since we are just publishing event for this topic.
}

/**
* Try register topic remove id status event.
*/
private void tryRegisterTopic() {
try {
logger.debug(IdAuthCommonConstants.SESSION_ID, "tryRegisterTopic", "",
"Trying to register topic: " + removeIdStatusTopic);
webSubHelper.registerTopic(removeIdStatusTopic);
logger.info(IdAuthCommonConstants.SESSION_ID, "tryRegisterTopic", "",
"Registered topic: " + removeIdStatusTopic);
} catch (Exception e) {
logger.info(IdAuthCommonConstants.SESSION_ID, "tryRegisterTopic", e.getClass().toString(),
"Error registering topic: " + removeIdStatusTopic + "\n" + e.getMessage());
}
}

@Override
protected void doRegister() {
logger.info(IdAuthCommonConstants.SESSION_ID, "doRegister", this.getClass().getSimpleName(),
"Registering topic..");
tryRegisterTopic();
}

public void publishRemoveIdStatusEvent(String idHash) {
RemoveIdStatusEvent removeIdStatusEvent = createRemoveIdStatusEvent(idHash);
webSubHelper.publishEvent(removeIdStatusTopic,
webSubHelper.createEventModel(removeIdStatusTopic, removeIdStatusEvent));
}

/**
* Creates the remove id status event.
*
* @param idHash the idHash
* @return the remove id status event
*/
private RemoveIdStatusEvent createRemoveIdStatusEvent(String idHash) {
RemoveIdStatusEvent removeIdStatusEvent = new RemoveIdStatusEvent();
Map<String, Object> dataMap = new HashMap<String, Object>();
dataMap.put(ID_HASH, idHash);
removeIdStatusEvent.setData(dataMap);
removeIdStatusEvent.setTimestamp(DateUtils.formatToISOString(DateUtils.getUTCCurrentDateTime()));
return removeIdStatusEvent;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ private IdAuthConfigKeyConstants() {
public static final String AUTH_ANONYMOUS_PROFILE_TOPIC = "ida-topic-auth-anonymous-profile";
public static final String AUTH_FRAUD_ANALYSIS_TOPIC = "ida-topic-fraud-analysis";
public static final String AUTHENTICATION_ERROR_EVENTING_TOPIC = "ida-topic-authentication-error-eventing";
public static final String REMOVE_ID_STATUS_TOPIC = "ida-topic-remove-id-status";

public static final String IDA_MAX_CREDENTIAL_PULL_WINDOW_DAYS = "ida-max-credential-pull-window-days";
public static final String IDA_MAX_WEBSUB_MSG_PULL_WINDOW_DAYS = "ida-max-websub-messages-pull-window-days";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public boolean validateUin(String uin) {
return idValidator.validateUIN(uin);
else
return false;
} catch (InvalidIDException | IdAuthenticationBusinessException e) {
} catch (InvalidIDException | IdAuthenticationBusinessException | NumberFormatException e) {
return false;
}
}
Expand All @@ -52,7 +52,7 @@ public boolean validateVid(String vid) {
return idValidator.validateVID(vid);
else
return false;
} catch (InvalidIDException | IdAuthenticationBusinessException e) {
} catch (InvalidIDException | IdAuthenticationBusinessException | NumberFormatException e) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import io.mosip.authentication.common.service.websub.impl.MasterDataUpdateEventInitializer;
import io.mosip.authentication.common.service.websub.impl.PartnerCACertEventInitializer;
import io.mosip.authentication.common.service.websub.impl.PartnerServiceEventsInitializer;
import io.mosip.authentication.common.service.websub.impl.RemoveIdStatusEventPublisher;
import io.mosip.authentication.core.util.DemoMatcherUtil;
import io.mosip.authentication.core.util.DemoNormalizer;
import io.mosip.authentication.core.util.IdTypeUtil;
Expand Down Expand Up @@ -129,7 +130,7 @@
CACertificateStore.class, PartnerCACertEventInitializer.class, PartnerCertManagerController.class, RetryConfig.class,
RetryUtil.class, RetryListenerImpl.class, RetryAspect.class, CredentialStoreServiceImpl.class,
CredentialStoreJobExecutionListener.class, HotlistServiceImpl.class, HotlistEventInitializer.class,
AuthTransactionHelper.class, CredentialStoreStatusEventPublisher.class, AuthTypeStatusEventPublisher.class,
AuthTransactionHelper.class, CredentialStoreStatusEventPublisher.class, AuthTypeStatusEventPublisher.class, RemoveIdStatusEventPublisher.class,
AuthTransactionStatusEventPublisher.class, PartnerServiceEventsInitializer.class, CredentialRequestManager.class,
DemoNormalizer.class, DemoMatcherUtil.class, IdAuthFraudAnalysisEventManager.class,
IdAuthFraudAnalysisEventPublisher.class, AuthFiltersValidator.class, SessionKeyDecrytorHelper.class, InternalRestHelperConfig.class, IdaRequestResponsConsumerUtil.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.mosip.authentication.common.service.websub.impl.MasterDataUpdateEventInitializer;
import io.mosip.authentication.common.service.websub.impl.PartnerCACertEventInitializer;
import io.mosip.authentication.common.service.websub.impl.PartnerServiceEventsInitializer;
import io.mosip.authentication.common.service.websub.impl.RemoveIdStatusEventPublisher;

/**
* The Class InternalAuthWebSubInitializer.
Expand Down Expand Up @@ -49,6 +50,10 @@ public class InternalAuthWebSubInitializer extends CacheUpdatingWebsubInitialize
@Autowired
private AuthTransactionStatusEventPublisher authTransactionStatusEventPublisher;

/** The remove id status event publisher. */
@Autowired
private RemoveIdStatusEventPublisher removeIdStatusEventPublisher;

/** The partner service events subscriber. */
@Autowired
private PartnerServiceEventsInitializer partnerServiceEventsInitializer;
Expand Down Expand Up @@ -84,6 +89,7 @@ protected int doRegisterTopics() {
webSubHelper.initRegistrar(credentialStoreStatusEventPublisher);
webSubHelper.initRegistrar(authTypeStatusEventPublisher);
webSubHelper.initRegistrar(authTransactionStatusEventPublisher);
webSubHelper.initRegistrar(removeIdStatusEventPublisher);
if(Objects.nonNull(fraudEventPublisher))
webSubHelper.initRegistrar(fraudEventPublisher);
return HttpStatus.SC_OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
*/
@RunWith(SpringRunner.class)
@WebMvcTest
@ContextConfiguration(classes = { TestContext.class, WebApplicationContext.class })
@ContextConfiguration(classes = { WebApplicationContext.class })
@Import(EnvUtil.class)
@TestPropertySource(locations="classpath:application.properties")
public class KycAuthRequestValidatorTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

@RunWith(SpringRunner.class)
@WebMvcTest
@ContextConfiguration(classes = { TestContext.class, WebApplicationContext.class })
@ContextConfiguration(classes = { WebApplicationContext.class })
@Import(EnvUtil.class)
@TestPropertySource(locations="classpath:application.properties")
public class VciExchangeRequestValidatorTest {
Expand Down
77 changes: 0 additions & 77 deletions authentication/esignet-integration-impl/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading