Skip to content

Commit

Permalink
[MOSIP-31982] added the condition to check bean creation (#1251)
Browse files Browse the repository at this point in the history
* MOSIP-32073 design document added (#1223)

Signed-off-by: Neha Farheen <[email protected]>
Co-authored-by: Neha Farheen <[email protected]>
Signed-off-by: Neha Farheen <[email protected]>

* POM changes (#1225)

Signed-off-by: Neha Farheen <[email protected]>
Co-authored-by: Neha Farheen <[email protected]>
Signed-off-by: Neha Farheen <[email protected]>

* updated the image path

Signed-off-by: Neha Farheen <[email protected]>

* MOSIP-31982 changes done for image

Signed-off-by: Neha Farheen <[email protected]>

* MOSIP-31982 changes done for image

Signed-off-by: Neha Farheen <[email protected]>

* MOSIP-31982 added kafka config in otp application

Signed-off-by: Neha Farheen <[email protected]>

* MOSIP-31982 added kafka config in otp application

Signed-off-by: Neha Farheen <[email protected]>

* MOSIP-31982 Updated the pom and push trigger file

Signed-off-by: Neha Farheen <[email protected]>

* test case issue is resolved

Signed-off-by: Neha Farheen <[email protected]>

* test case issue is resolved with facedata

Signed-off-by: Neha Farheen <[email protected]>

* test case issue is resolved with facedata

Signed-off-by: Neha Farheen <[email protected]>

* kafka bean enable and disable

Signed-off-by: Neha Farheen <[email protected]>

* kafka bean enable and disable

Signed-off-by: Neha Farheen <[email protected]>

* Error eventing condition check added

Signed-off-by: Neha Farheen <[email protected]>

---------

Signed-off-by: Neha Farheen <[email protected]>
Co-authored-by: Neha Farheen <[email protected]>
  • Loading branch information
Neha2365 and Neha Farheen authored Apr 22, 2024
1 parent 0d42ffc commit 6e66ad1
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package io.mosip.authentication.otp.service.controller;

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

import java.util.Objects;
import java.util.Optional;

import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

Expand All @@ -14,7 +17,10 @@
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import io.swagger.v3.oas.annotations.tags.Tag;

import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.validation.Errors;
import org.springframework.web.bind.WebDataBinder;
Expand Down Expand Up @@ -94,11 +100,23 @@ public class OTPController {

@Autowired(required = false)
private AuthenticationErrorEventingPublisher authenticationErrorEventingPublisher;

@Value("${"+ AUTHENTICATION_ERROR_EVENTING_ENABLED +":false}")
private boolean isEventingEnabled;

@InitBinder
private void initBinder(WebDataBinder binder) {
binder.setValidator(otpRequestValidator);
}

@PostConstruct
public void init() {
if (isEventingEnabled) {
if (Objects.isNull(authenticationErrorEventingPublisher)) {
throw new BeanCreationException(AuthenticationErrorEventingPublisher.class.getName(), "Failed to create a bean");
}
}
}

/**
* send OtpRequestDTO request to generate OTP and received OtpResponseDTO as
Expand Down Expand Up @@ -160,7 +178,8 @@ public OtpResponseDTO generateOTP(@Valid @RequestBody OtpRequestDTO otpRequestDt
throw authTransactionHelper.createDataValidationException(authTxnBuilder, e, requestWithMetadata);
} catch (IdAuthenticationBusinessException e) {
logger.error(IdAuthCommonConstants.SESSION_ID, e.getClass().toString(), e.getErrorCode(), e.getErrorText());
if (authenticationErrorEventingPublisher != null) {

if (isEventingEnabled) {
if (IdAuthenticationErrorConstants.ID_NOT_AVAILABLE.getErrorCode().equals(e.getErrorCode())) {
authenticationErrorEventingPublisher.notify(otpRequestDto, request.getHeader("signature"),
partner, e, otpRequestDto.getMetadata());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package io.mosip.authentication.service.controller;

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

import java.util.Objects;
import java.util.Optional;

import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.validation.Errors;
import org.springframework.validation.annotation.Validated;
Expand Down Expand Up @@ -92,6 +97,9 @@ public class AuthController {

@Autowired(required = false)
private AuthenticationErrorEventingPublisher authenticationErrorEventingPublisher;

@Value("${"+ AUTHENTICATION_ERROR_EVENTING_ENABLED +":false}")
private boolean isEventingEnabled;


/**
Expand All @@ -102,6 +110,15 @@ public class AuthController {
private void initAuthRequestBinder(WebDataBinder binder) {
binder.setValidator(authRequestValidator);
}

@PostConstruct
public void init() {
if (isEventingEnabled) {
if (Objects.isNull(authenticationErrorEventingPublisher)) {
throw new BeanCreationException(AuthenticationErrorEventingPublisher.class.getName(), "Failed to create a bean");
}
}
}

/**
* authenticateRequest - method to authenticate request.
Expand Down Expand Up @@ -162,7 +179,8 @@ public AuthResponseDTO authenticateIndividual(@Validated @RequestBody AuthReques
} catch (IdAuthenticationBusinessException e) {
mosipLogger.error(IdAuthCommonConstants.SESSION_ID, this.getClass().getSimpleName(),
"authenticateApplication", e.getErrorCode() + " : " + e.getErrorText());
if (authenticationErrorEventingPublisher != null) {

if (isEventingEnabled) {
if (IdAuthenticationErrorConstants.ID_NOT_AVAILABLE.getErrorCode().equals(e.getErrorCode())) {
authenticationErrorEventingPublisher.notify(authrequestdto, request.getHeader("signature"),
partner, e, authrequestdto.getMetadata());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package io.mosip.authentication.service.kyc.controller;

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

import java.util.Map;
import java.util.Objects;
import java.util.Optional;

import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;

import io.mosip.authentication.core.indauth.dto.*;

import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.validation.Errors;
import org.springframework.validation.annotation.Validated;
Expand Down Expand Up @@ -102,6 +108,9 @@ public class KycAuthController {

@Autowired(required = false)
private AuthenticationErrorEventingPublisher authenticationErrorEventingPublisher;

@Value("${"+ AUTHENTICATION_ERROR_EVENTING_ENABLED +":false}")
private boolean isEventingEnabled;

/**
*
Expand Down Expand Up @@ -129,6 +138,15 @@ private void initEKycBinder(WebDataBinder binder) {
private void initKycExchangeBinder(WebDataBinder binder) {
binder.setValidator(kycExchangeValidator);
}

@PostConstruct
public void init() {
if (isEventingEnabled) {
if (Objects.isNull(authenticationErrorEventingPublisher)) {
throw new BeanCreationException(AuthenticationErrorEventingPublisher.class.getName(), "Failed to create a bean");
}
}
}


/**
Expand Down Expand Up @@ -197,7 +215,8 @@ public EKycAuthResponseDTO processKyc(@Validated @RequestBody EkycAuthRequestDTO
} catch (IdAuthenticationBusinessException e) {
mosipLogger.error(IdAuthCommonConstants.SESSION_ID, this.getClass().getSimpleName(), "processEKyc",
e.getErrorTexts().isEmpty() ? "" : e.getErrorText());
if (authenticationErrorEventingPublisher != null) {

if (isEventingEnabled) {
if (IdAuthenticationErrorConstants.ID_NOT_AVAILABLE.getErrorCode().equals(e.getErrorCode())) {
authenticationErrorEventingPublisher.notify(ekycAuthRequestDTO, request.getHeader("signature"),
partner, e, ekycAuthRequestDTO.getMetadata());
Expand Down Expand Up @@ -280,7 +299,8 @@ public KycAuthResponseDTO processKycAuth(@Validated @RequestBody KycAuthRequestD
} catch (IdAuthenticationBusinessException e) {
mosipLogger.error(IdAuthCommonConstants.SESSION_ID, this.getClass().getSimpleName(), "processKycAuth",
e.getErrorTexts().isEmpty() ? "" : e.getErrorText());
if (authenticationErrorEventingPublisher != null) {

if (isEventingEnabled) {
if (IdAuthenticationErrorConstants.ID_NOT_AVAILABLE.getErrorCode().equals(e.getErrorCode())) {
authenticationErrorEventingPublisher.notify(authRequestDTO, request.getHeader("signature"),
partner, e, authRequestDTO.getMetadata());
Expand Down

0 comments on commit 6e66ad1

Please sign in to comment.