diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/constant/PartnerConstants.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/constant/PartnerConstants.java index ee6322ccc9..09ff136796 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/constant/PartnerConstants.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/constant/PartnerConstants.java @@ -39,4 +39,6 @@ public final class PartnerConstants { public static final String ASC = "asc"; public static final String DESC = "desc"; + + public static final String PARTNER_ADMIN = "PARTNER_ADMIN"; } 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 668d02adec..0c2dbc60c7 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 @@ -859,7 +859,8 @@ protected T getCertificateFromKeyMgr(PartnerCertDownloadRequestDto certDownl } } T responseObject = null; - if (isPartnerBelongsToTheUser) { + boolean isAdmin = partnerHelper.isPartnerAdmin(authUserDetails().getAuthorities().toString()); + if (isPartnerBelongsToTheUser || isAdmin) { Optional partnerFromDb = partnerRepository.findById(certDownloadRequestDto.getPartnerId()); if (partnerFromDb.isEmpty()) { LOGGER.error("Partner not exists with id {}", certDownloadRequestDto.getPartnerId()); diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/util/PartnerHelper.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/util/PartnerHelper.java index def8764f1e..9342a493d2 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/util/PartnerHelper.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/util/PartnerHelper.java @@ -160,4 +160,11 @@ public Sort getSortingRequest (String fieldName, String sortType) { } return sortingRequest; } + + public boolean isPartnerAdmin(String roles) { + if (roles.contains(PartnerConstants.PARTNER_ADMIN)) { + return true; + } + return false; + } }