Search in sources :

Example 1 with ConsentManagementClientException

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;
}
Also used : PIICategory(org.wso2.carbon.consent.mgt.core.model.PIICategory) ConsentManagementException(org.wso2.carbon.consent.mgt.core.exception.ConsentManagementException) ArrayList(java.util.ArrayList) SSOConsentServiceException(org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.consent.exception.SSOConsentServiceException) PIICategoryValidity(org.wso2.carbon.consent.mgt.core.model.PIICategoryValidity) ConsentManagementClientException(org.wso2.carbon.consent.mgt.core.exception.ConsentManagementClientException)

Aggregations

ArrayList (java.util.ArrayList)1 ConsentManagementClientException (org.wso2.carbon.consent.mgt.core.exception.ConsentManagementClientException)1 ConsentManagementException (org.wso2.carbon.consent.mgt.core.exception.ConsentManagementException)1 PIICategory (org.wso2.carbon.consent.mgt.core.model.PIICategory)1 PIICategoryValidity (org.wso2.carbon.consent.mgt.core.model.PIICategoryValidity)1 SSOConsentServiceException (org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.consent.exception.SSOConsentServiceException)1