use of org.wso2.carbon.consent.mgt.core.exception.ConsentManagementClientException in project carbon-identity-framework by wso2.
the class SSOConsentServiceImpl method getPiiCategoryValidityForRequestedClaims.
private List<PIICategoryValidity> getPiiCategoryValidityForRequestedClaims(List<ClaimMetaData> requestedClaims, boolean isConsented, String termination) throws SSOConsentServiceException {
List<PIICategoryValidity> piiCategoryIds = new ArrayList<>();
if (CollectionUtils.isEmpty(requestedClaims)) {
return piiCategoryIds;
}
for (ClaimMetaData requestedClaim : requestedClaims) {
if (requestedClaim == null || requestedClaim.getClaimUri() == null) {
continue;
}
PIICategory piiCategory;
try {
piiCategory = getConsentManager().getPIICategoryByName(requestedClaim.getClaimUri());
} catch (ConsentManagementClientException e) {
if (isInvalidPIICategoryError(e)) {
piiCategory = addPIICategoryForClaim(requestedClaim);
} else {
throw new SSOConsentServiceException("Consent PII category error", "Error while retrieving" + " PII category: " + DEFAULT_PURPOSE_CATEGORY, e);
}
} catch (ConsentManagementException e) {
throw new SSOConsentServiceException("Consent PII category error", "Error while retrieving " + "PII category: " + DEFAULT_PURPOSE_CATEGORY, e);
}
PIICategoryValidity piiCategoryValidity = new PIICategoryValidity(piiCategory.getId(), termination);
piiCategoryValidity.setConsented(isConsented);
piiCategoryIds.add(piiCategoryValidity);
}
return piiCategoryIds;
}
Aggregations