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

MOSIP-37601 : Deactivate FTM Chip details #1007

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -541,8 +541,13 @@ public ResponseWrapperV2<FtmDetailResponseDto> deactivateFtm(String ftmId) {
validateFtmChipDetail(ftmChipDetail);

FTPChipDetail ftm = ftmChipDetail.get();
Partner partnerDetails = getAssociatedPartner(partnerList, ftm, userId);
checkIfPartnerIsNotActive(partnerDetails);

boolean isAdmin = partnerHelper.isPartnerAdmin(authUserDetails().getAuthorities().toString());
if(!isAdmin){
Partner partnerDetails = getAssociatedPartner(partnerList, ftm, userId);
checkIfPartnerIsNotActive(partnerDetails);
}

if (!ftm.getApprovalStatus().equals(APPROVED)) {
LOGGER.error("Unable to deactivate FTM with id {}", ftm.getFtpChipDetailId());
throw new PartnerServiceException(ErrorCode.FTM_NOT_APPROVED.getErrorCode(),
Expand Down Expand Up @@ -596,8 +601,12 @@ public ResponseWrapperV2<OriginalCertDownloadResponseDto> getOriginalFtmCertific
validateFtmChipDetail(ftmChipDetail);

FTPChipDetail ftm = ftmChipDetail.get();
Partner partnerDetails = getAssociatedPartner(partnerList, ftm, userId);
checkIfPartnerIsNotActive(partnerDetails);

boolean isAdmin = partnerHelper.isPartnerAdmin(authUserDetails().getAuthorities().toString());
if(!isAdmin){
Partner partnerDetails = getAssociatedPartner(partnerList, ftm, userId);
checkIfPartnerIsNotActive(partnerDetails);
}

if (!(ftm.getApprovalStatus().equals(PENDING_APPROVAL) || ftm.getApprovalStatus().equals(APPROVED))) {
LOGGER.error("Unable to download original FTM certificate with id {}", ftm.getFtpChipDetailId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,13 +702,17 @@ public String updateAPIKeyStatus(String partnerId, String policyId, APIkeyStatus
throw new PartnerManagerServiceException(ErrorCode.PARTNER_POLICY_LABEL_NOT_EXISTS.getErrorCode(),
ErrorCode.PARTNER_POLICY_LABEL_NOT_EXISTS.getErrorMessage());
}
// check if Partner is Active or not.
if (policyByLabel.getPartner() != null && !policyByLabel.getPartner().getIsActive()) {
LOGGER.error("Partner is not Active, hence status of API key cannot be updated, for partner: " + partnerId);
auditUtil.setAuditRequestDto(PartnerManageEnum.ACTIVATE_DEACTIVATE_API_PARTNERS_FAILED, partnerId,
"partnerId");
throw new PartnerManagerServiceException(ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorCode(),
ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorMessage());
//check if logged in user is admin
boolean isAdmin = partnerHelper.isPartnerAdmin(authUserDetails().getAuthorities().toString());
if (!isAdmin){
// check if Partner is Active or not.
if (policyByLabel.getPartner() != null && !policyByLabel.getPartner().getIsActive()) {
LOGGER.error("Partner is not Active, hence status of API key cannot be updated, for partner: " + partnerId);
auditUtil.setAuditRequestDto(PartnerManageEnum.ACTIVATE_DEACTIVATE_API_PARTNERS_FAILED, partnerId,
"partnerId");
throw new PartnerManagerServiceException(ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorCode(),
ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorMessage());
}
}
// check if API key has been already deactivated
if (!policyByLabel.getIsActive() && request.getStatus().equalsIgnoreCase(PartnerConstants.DEACTIVE)) {
Expand Down
Loading