From e2ed1a1dbb9b467a19bfd581c8b96a3fd738e5c5 Mon Sep 17 00:00:00 2001 From: Sudeep7353 <103890430+Sudeep7353@users.noreply.github.com> Date: Fri, 20 Dec 2024 18:00:06 +0530 Subject: [PATCH] MOSIP:37899 - APi review comment changes (#1053) Signed-off-by: sudeep --- .../controller/PartnerServiceController.java | 12 --- .../pms/partner/dto/ActivePolicyDto.java | 14 ---- .../pms/partner/dto/AuthorizedRolesDto.java | 2 - .../pms/partner/service/PartnerService.java | 1 - .../service/impl/PartnerServiceImpl.java | 76 ------------------- .../src/main/resources/bootstrap.properties | 2 - .../src/test/resources/application.properties | 2 - 7 files changed, 109 deletions(-) delete mode 100644 partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/ActivePolicyDto.java diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/controller/PartnerServiceController.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/controller/PartnerServiceController.java index 63c9d09a5d..cec8df3b09 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/controller/PartnerServiceController.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/controller/PartnerServiceController.java @@ -411,18 +411,6 @@ public ResponseWrapperV2> getAuthPartnerApiKeys() { return partnerService.getAuthPartnerApiKeys(); } - @PreAuthorize("hasAnyRole(@authorizedRoles.getGetauthpartnerspolicies())") - @GetMapping(value = "/{partnerId}/policies") - @Operation(summary = "Get all approved auth partner policies", description = "Fetch all approved auth partner policies") - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "OK"), - @ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))), - @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))) - }) - public ResponseWrapperV2> getAuthPartnersPolicies(@PathVariable("partnerId") String partnerId) { - return partnerService.getAuthPartnersPolicies(partnerId); - } - @ResponseFilter @PostMapping("/search") @PreAuthorize("hasAnyRole(@authorizedRoles.getPostpartnerssearch())") diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/ActivePolicyDto.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/ActivePolicyDto.java deleted file mode 100644 index 56f4b62c53..0000000000 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/ActivePolicyDto.java +++ /dev/null @@ -1,14 +0,0 @@ -package io.mosip.pms.partner.dto; - -import lombok.Data; -import lombok.Getter; -import lombok.Setter; - -@Data -@Getter -@Setter -public class ActivePolicyDto { - private String policyName; - private String policyId; - private String policyDescription; -} \ No newline at end of file diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/AuthorizedRolesDto.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/AuthorizedRolesDto.java index 34fd878fe2..418a53afac 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/AuthorizedRolesDto.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/dto/AuthorizedRolesDto.java @@ -157,8 +157,6 @@ public class AuthorizedRolesDto { private List getpolicyrequests; - private List getauthpartnerspolicies; - private List getapikeysforauthpartners; private List getoauthclients; diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/PartnerService.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/PartnerService.java index 5a52ffd794..c8eda04471 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/PartnerService.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/PartnerService.java @@ -240,5 +240,4 @@ public interface PartnerService { ResponseWrapperV2> getPartnersV4(String status, Boolean policyGroupAvailable, String partnerType); - ResponseWrapperV2> getAuthPartnersPolicies(String PartnerId); } diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java index 8ad2d71740..559c777759 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java @@ -261,9 +261,6 @@ public class PartnerServiceImpl implements PartnerService { @Value("${mosip.pms.api.id.partners.v4.get}") private String getPartnersV4Id; - @Value("${mosip.pms.api.id.auth.partners.policies.get}") - private String getAuthPartnersPoliciesId; - @Autowired AuditUtil auditUtil; @@ -1900,79 +1897,6 @@ public ResponseWrapperV2> getPartnersV4(String status, Boolea return responseWrapper; } - @Override - public ResponseWrapperV2> getAuthPartnersPolicies(String partnerId) { - ResponseWrapperV2> responseWrapper = new ResponseWrapperV2<>(); - try { - String userId = getUserId(); - List partnerList = partnerRepository.findByUserId(userId); - if (partnerList.isEmpty()) { - LOGGER.info("sessionId", "idType", "id", "User id does not exists."); - throw new PartnerServiceException(ErrorCode.USER_ID_NOT_EXISTS.getErrorCode(), - ErrorCode.USER_ID_NOT_EXISTS.getErrorMessage()); - } - - //validate whether partner Id exists - Optional optionalPartner = partnerRepository.findById(partnerId); - if (optionalPartner.isEmpty()) { - LOGGER.info("sessionId", "idType", "id", "User id does not exists."); - throw new PartnerServiceException(ErrorCode.PARTNER_DOES_NOT_EXIST_ERROR.getErrorCode(), - ErrorCode.PARTNER_DOES_NOT_EXIST_ERROR.getErrorMessage()); - } - Partner partner = optionalPartner.get(); - //check if partner Id belongs to user - boolean partnerBelongsToUser = false; - for (Partner partnerData : partnerList) { - if (partnerData.getUserId().equals(partner.getUserId())) { - partnerBelongsToUser = true; - break; - } - } - if (!partnerBelongsToUser) { - LOGGER.info("sessionId", "idType", "id", "Partner is not associated with user."); - throw new PartnerServiceException(ErrorCode.PARTNER_ID_NOT_ASSOCIATED_WITH_USER.getErrorCode(), - ErrorCode.PARTNER_ID_NOT_ASSOCIATED_WITH_USER.getErrorMessage()); - } - partnerHelper.validateIfPartnerIsApprovedAuthPartner(partner); - partnerHelper.validatePolicyGroupId(partner, userId); - PolicyGroup policyGroup = partnerHelper.validatePolicyGroup(partner); - List partnerPolicyRequestList = partner.getPartnerPolicyRequests(); - List activePolicyDtoList = new ArrayList<>(); - if (!partnerPolicyRequestList.isEmpty()) { - for (PartnerPolicyRequest partnerPolicyRequest : partnerPolicyRequestList) { - if (partnerPolicyRequest.getStatusCode().equals(APPROVED)) { - AuthPolicy policyDetails = authPolicyRepository.findActivePoliciesByPolicyGroupId(policyGroup.getId(), partnerPolicyRequest.getPolicyId()); - if (Objects.nonNull(policyDetails)) { - ActivePolicyDto activePolicyDto = new ActivePolicyDto(); - activePolicyDto.setPolicyId(policyDetails.getId()); - activePolicyDto.setPolicyDescription(policyDetails.getDescr()); - activePolicyDto.setPolicyName(policyDetails.getName()); - activePolicyDtoList.add(activePolicyDto); - } else { - LOGGER.info("No matching policy not found for policy group ID :" + policyGroup.getId() + "and Policy ID :" + partnerPolicyRequest.getPolicyId()); - throw new PartnerServiceException(ErrorCode.MATCHING_POLICY_NOT_FOUND.getErrorCode(), - ErrorCode.MATCHING_POLICY_NOT_FOUND.getErrorMessage()); - } - } - } - } - responseWrapper.setResponse(activePolicyDtoList); - } catch (PartnerServiceException ex) { - LOGGER.info("sessionId", "idType", "id", "In getAuthPartnersPolicies method of PartnerServiceImpl - " + ex.getMessage()); - responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(ex.getErrorCode(), ex.getErrorText())); - } catch (Exception ex) { - LOGGER.debug("sessionId", "idType", "id", ex.getStackTrace()); - LOGGER.error("sessionId", "idType", "id", - "In getAuthPartnersPolicies method of PartnerServiceImpl - " + ex.getMessage()); - String errorCode = ErrorCode.PARTNER_POLICIES_FETCH_ERROR.getErrorCode(); - String errorMessage = ErrorCode.PARTNER_POLICIES_FETCH_ERROR.getErrorMessage(); - responseWrapper.setErrors(MultiPartnerUtil.setErrorResponse(errorCode, errorMessage)); - } - responseWrapper.setId(getAuthPartnersPoliciesId); - responseWrapper.setVersion(VERSION); - return responseWrapper; - } - /** * validates the loggedInUser authorization * @param loggedInUserId diff --git a/partner/partner-management-service/src/main/resources/bootstrap.properties b/partner/partner-management-service/src/main/resources/bootstrap.properties index daa1d94dd0..4c20749e4d 100644 --- a/partner/partner-management-service/src/main/resources/bootstrap.properties +++ b/partner/partner-management-service/src/main/resources/bootstrap.properties @@ -74,7 +74,6 @@ pmp.download.ca.certificate.get.rest.uri=${mosip.kernel.keymanager.url}/v1/keyma mosip.role.pms.getpartnercertificates=AUTH_PARTNER,ABIS_PARTNER,SDK_PARTNER,DEVICE_PROVIDER,FTM_PROVIDER,CREDENTIAL_PARTNER,PARTNER_ADMIN,ONLINE_VERIFICATION_PARTNER mosip.role.pms.getpolicyrequests=AUTH_PARTNER,ABIS_PARTNER,SDK_PARTNER,CREDENTIAL_PARTNER,PARTNER_ADMIN,ONLINE_VERIFICATION_PARTNER -mosip.role.pms.getauthpartnerspolicies=AUTH_PARTNER,PARTNER_ADMIN mosip.role.pms.getapikeysforauthpartners=AUTH_PARTNER,PARTNER_ADMIN mosip.role.pms.getoauthclients=AUTH_PARTNER,PARTNER_ADMIN mosip.role.pms.userconsent=AUTH_PARTNER,ABIS_PARTNER,SDK_PARTNER,DEVICE_PROVIDER,FTM_PROVIDER,CREDENTIAL_PARTNER,PARTNER_ADMIN,ONLINE_VERIFICATION_PARTNER @@ -118,7 +117,6 @@ mosip.pms.pagination.items.per.page=8 mosip.pms.api.id.oauth.clients.get=mosip.pms.oauth.clients.get mosip.pms.api.id.partner.certificates.get=mosip.pms.partner.certificates.get mosip.pms.api.id.policy.requests.get=mosip.pms.policy.requests.get -mosip.pms.api.id.auth.partners.policies.get=mosip.pms.auth.partners.policies.get mosip.pms.api.id.approved.partner.ids.with.policy.groups.get=mosip.pms.approved.partner.ids.with.policy.groups.get mosip.pms.api.id.configs.get=mosip.pms.configs.get mosip.pms.api.id.auth.partner.api.keys.get=mosip.pms.auth.partner.api.keys.get diff --git a/partner/partner-management-service/src/test/resources/application.properties b/partner/partner-management-service/src/test/resources/application.properties index dd73c60d7c..4382df29fb 100644 --- a/partner/partner-management-service/src/test/resources/application.properties +++ b/partner/partner-management-service/src/test/resources/application.properties @@ -308,7 +308,6 @@ mosip.role.pms.getmisplicensekey=PARTNERMANAGER,PARTNER_ADMIN mosip.role.pms.postmispfiltervalues=MISP_PARTNER,MISP,PARTNERMANAGER,PARTNER_ADMIN mosip.role.pms.getpartnercertificates=AUTH_PARTNER,ABIS_PARTNER,SDK_PARTNER,DEVICE_PROVIDER,FTM_PROVIDER,CREDENTIAL_PARTNER,PARTNER_ADMIN,ONLINE_VERIFICATION_PARTNER mosip.role.pms.getpolicyrequests=AUTH_PARTNER,ABIS_PARTNER,SDK_PARTNER,CREDENTIAL_PARTNER,PARTNER_ADMIN,ONLINE_VERIFICATION_PARTNER -mosip.role.pms.getauthpartnerspolicies=AUTH_PARTNER,PARTNER_ADMIN mosip.role.pms.getapikeysforauthpartners=AUTH_PARTNER,PARTNER_ADMIN mosip.role.pms.getoauthclients=AUTH_PARTNER,PARTNER_ADMIN mosip.role.pms.userconsent=AUTH_PARTNER,ABIS_PARTNER,SDK_PARTNER,DEVICE_PROVIDER,FTM_PROVIDER,CREDENTIAL_PARTNER,PARTNER_ADMIN,ONLINE_VERIFICATION_PARTNER @@ -334,7 +333,6 @@ mosip.role.pms.getallcacertificates=PARTNER_ADMIN mosip.pms.api.id.oauth.clients.get=mosip.pms.oauth.clients.get mosip.pms.api.id.partner.certificates.get=mosip.pms.partner.certificates.get mosip.pms.api.id.policy.requests.get=mosip.pms.policy.requests.get -mosip.pms.api.id.auth.partners.policies.get=mosip.pms.auth.partners.policies.get mosip.pms.api.id.approved.partner.ids.with.policy.groups.get=mosip.pms.approved.partner.ids.with.policy.groups.get mosip.pms.api.id.configs.get=mosip.pms.configs.get mosip.pms.api.id.auth.partner.api.keys.get=mosip.pms.auth.partner.api.keys.get