Skip to content

Commit

Permalink
MOSIP:37899 - APi review comment changes (#1053)
Browse files Browse the repository at this point in the history
Signed-off-by: sudeep <[email protected]>
  • Loading branch information
Sudeep7353 authored Dec 20, 2024
1 parent 1baf1d5 commit e2ed1a1
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -411,18 +411,6 @@ public ResponseWrapperV2<List<ApiKeyResponseDto>> 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<List<ActivePolicyDto>> getAuthPartnersPolicies(@PathVariable("partnerId") String partnerId) {
return partnerService.getAuthPartnersPolicies(partnerId);
}

@ResponseFilter
@PostMapping("/search")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostpartnerssearch())")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ public class AuthorizedRolesDto {

private List<String> getpolicyrequests;

private List<String> getauthpartnerspolicies;

private List<String> getapikeysforauthpartners;

private List<String> getoauthclients;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,4 @@ public interface PartnerService {

ResponseWrapperV2<List<PartnerDtoV4>> getPartnersV4(String status, Boolean policyGroupAvailable, String partnerType);

ResponseWrapperV2<List<ActivePolicyDto>> getAuthPartnersPolicies(String PartnerId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1900,79 +1897,6 @@ public ResponseWrapperV2<List<PartnerDtoV4>> getPartnersV4(String status, Boolea
return responseWrapper;
}

@Override
public ResponseWrapperV2<List<ActivePolicyDto>> getAuthPartnersPolicies(String partnerId) {
ResponseWrapperV2<List<ActivePolicyDto>> responseWrapper = new ResponseWrapperV2<>();
try {
String userId = getUserId();
List<Partner> 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<Partner> 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<PartnerPolicyRequest> partnerPolicyRequestList = partner.getPartnerPolicyRequests();
List<ActivePolicyDto> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit e2ed1a1

Please sign in to comment.