Search in sources :

Example 1 with ReceiptPurposeInput

use of org.wso2.carbon.consent.mgt.core.model.ReceiptPurposeInput in project carbon-identity-framework by wso2.

the class ConsentUtilityService method filterPIIsFromReceipt.

/**
 * If the consent is not given for a PII
 *
 * @param keySet
 * @param receipt
 * @return
 * @throws ConsentUtilityServiceException
 */
public Set<String> filterPIIsFromReceipt(Set<String> keySet, ReceiptInput receipt) throws ConsentUtilityServiceException {
    if (keySet == null || receipt == null) {
        throw new ConsentUtilityServiceException("Key set and receipt should not be null");
    }
    List<ReceiptServiceInput> services = receipt.getServices();
    Set<String> consentedPIIs = new HashSet<>();
    for (ReceiptServiceInput service : services) {
        List<ReceiptPurposeInput> purposes = service.getPurposes();
        for (ReceiptPurposeInput consentPurpose : purposes) {
            List<PIICategoryValidity> piiCategories = consentPurpose.getPiiCategory();
            for (PIICategoryValidity piiCategory : piiCategories) {
                consentedPIIs.add(getPIIName(consentPurpose.getPurposeId(), piiCategory.getId()));
            }
        }
    }
    keySet.retainAll(consentedPIIs);
    return keySet;
}
Also used : ConsentUtilityServiceException(org.wso2.carbon.identity.consent.mgt.exceptions.ConsentUtilityServiceException) ReceiptServiceInput(org.wso2.carbon.consent.mgt.core.model.ReceiptServiceInput) ReceiptPurposeInput(org.wso2.carbon.consent.mgt.core.model.ReceiptPurposeInput) PIICategoryValidity(org.wso2.carbon.consent.mgt.core.model.PIICategoryValidity) HashSet(java.util.HashSet)

Example 2 with ReceiptPurposeInput

use of org.wso2.carbon.consent.mgt.core.model.ReceiptPurposeInput in project carbon-identity-framework by wso2.

the class JITProvisioningPostAuthenticationHandler method getReceiptPurposeInputs.

/**
 * To get the receive purpose inputs from json object from the client side.
 *
 * @param receiptPurpose Relevant receipt purpose.
 * @return receipt purpose input, based on receipt purpose object.
 */
private ReceiptPurposeInput getReceiptPurposeInputs(JSONObject receiptPurpose) {
    ReceiptPurposeInput receiptPurposeInput = new ReceiptPurposeInput();
    receiptPurposeInput.setConsentType(FrameworkConstants.Consent.EXPLICIT_CONSENT_TYPE);
    receiptPurposeInput.setPrimaryPurpose(true);
    receiptPurposeInput.setThirdPartyDisclosure(false);
    receiptPurposeInput.setPurposeId(receiptPurpose.getInt("purposeId"));
    JSONArray purposeCategoryId = receiptPurpose.getJSONArray("purposeCategoryId");
    List<Integer> purposeCategoryIdArray = new ArrayList<>();
    for (int index = 0; index < purposeCategoryId.length(); index++) {
        purposeCategoryIdArray.add(purposeCategoryId.getInt(index));
    }
    receiptPurposeInput.setTermination(FrameworkConstants.Consent.INFINITE_TERMINATION);
    receiptPurposeInput.setPurposeCategoryId(purposeCategoryIdArray);
    receiptPurposeInput.setTermination(FrameworkConstants.Consent.INFINITE_TERMINATION);
    List<PIICategoryValidity> piiCategoryValidities = new ArrayList<>();
    JSONArray piiCategories = (JSONArray) receiptPurpose.get(FrameworkConstants.Consent.PII_CATEGORY);
    for (int categoryIndex = 0; categoryIndex < piiCategories.length(); categoryIndex++) {
        JSONObject piiCategory = (JSONObject) piiCategories.get(categoryIndex);
        PIICategoryValidity piiCategoryValidity = new PIICategoryValidity(piiCategory.getInt("piiCategoryId"), FrameworkConstants.Consent.INFINITE_TERMINATION);
        piiCategoryValidity.setConsented(true);
        piiCategoryValidities.add(piiCategoryValidity);
    }
    receiptPurposeInput.setPiiCategory(piiCategoryValidities);
    return receiptPurposeInput;
}
Also used : JSONObject(org.json.JSONObject) ReceiptPurposeInput(org.wso2.carbon.consent.mgt.core.model.ReceiptPurposeInput) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) PIICategoryValidity(org.wso2.carbon.consent.mgt.core.model.PIICategoryValidity)

Example 3 with ReceiptPurposeInput

use of org.wso2.carbon.consent.mgt.core.model.ReceiptPurposeInput in project carbon-identity-framework by wso2.

the class SSOConsentServiceImpl method getReceiptPurposeInput.

private ReceiptPurposeInput getReceiptPurposeInput(String consentType, String termination, Purpose purpose, List<PIICategoryValidity> piiCategoryIds, List<Integer> purposeCategoryIds) {
    ReceiptPurposeInput purposeInput = new ReceiptPurposeInput();
    purposeInput.setPrimaryPurpose(true);
    purposeInput.setTermination(termination);
    purposeInput.setConsentType(consentType);
    purposeInput.setThirdPartyDisclosure(false);
    purposeInput.setPurposeId(purpose.getId());
    purposeInput.setPurposeCategoryId(purposeCategoryIds);
    purposeInput.setPiiCategory(piiCategoryIds);
    return purposeInput;
}
Also used : ReceiptPurposeInput(org.wso2.carbon.consent.mgt.core.model.ReceiptPurposeInput)

Example 4 with ReceiptPurposeInput

use of org.wso2.carbon.consent.mgt.core.model.ReceiptPurposeInput in project carbon-identity-framework by wso2.

the class SSOConsentServiceImpl method getReceiptServiceInput.

private ReceiptServiceInput getReceiptServiceInput(ServiceProvider serviceProvider, String spTenantDomain, List<ReceiptPurposeInput> purposeInputs) {
    ReceiptServiceInput serviceInput = new ReceiptServiceInput();
    serviceInput.setPurposes(purposeInputs);
    serviceInput.setTenantDomain(spTenantDomain);
    if (serviceProvider == null) {
        return serviceInput;
    }
    String spName = serviceProvider.getApplicationName();
    String spDescription;
    spDescription = serviceProvider.getDescription();
    if (StringUtils.isBlank(spDescription)) {
        spDescription = spName;
    }
    serviceInput.setService(spName);
    serviceInput.setSpDisplayName(spName);
    serviceInput.setSpDescription(spDescription);
    return serviceInput;
}
Also used : ReceiptServiceInput(org.wso2.carbon.consent.mgt.core.model.ReceiptServiceInput)

Example 5 with ReceiptPurposeInput

use of org.wso2.carbon.consent.mgt.core.model.ReceiptPurposeInput in project carbon-identity-framework by wso2.

the class SSOConsentServiceImpl method buildReceiptInput.

private ReceiptInput buildReceiptInput(String subject, ServiceProvider serviceProvider, String spTenantDomain, List<ClaimMetaData> claimsWithConsent, List<ClaimMetaData> claimsDeniedConsent) throws SSOConsentServiceException {
    String collectionMethod = "Web Form - Sign-in";
    String jurisdiction = "NONE";
    String language = "us_EN";
    String consentType = "EXPLICIT";
    String termination = CONSENT_VALIDITY_TYPE_VALID_UNTIL + CONSENT_VALIDITY_TYPE_SEPARATOR + CONSENT_VALIDITY_TYPE_VALID_UNTIL_INDEFINITE;
    String policyUrl = "NONE";
    Purpose purpose = getDefaultPurpose();
    PurposeCategory purposeCategory = getDefaultPurposeCategory();
    List<PIICategoryValidity> piiCategoryIds = getPiiCategoryValidityForClaims(claimsWithConsent, claimsDeniedConsent, termination);
    List<ReceiptServiceInput> serviceInputs = new ArrayList<>();
    List<ReceiptPurposeInput> purposeInputs = new ArrayList<>();
    List<Integer> purposeCategoryIds = new ArrayList<>();
    Map<String, String> properties = new HashMap<>();
    purposeCategoryIds.add(purposeCategory.getId());
    ReceiptPurposeInput purposeInput = getReceiptPurposeInput(consentType, termination, purpose, piiCategoryIds, purposeCategoryIds);
    purposeInputs.add(purposeInput);
    ReceiptServiceInput serviceInput = getReceiptServiceInput(serviceProvider, spTenantDomain, purposeInputs);
    serviceInputs.add(serviceInput);
    return getReceiptInput(subject, collectionMethod, jurisdiction, language, policyUrl, serviceInputs, properties);
}
Also used : ReceiptServiceInput(org.wso2.carbon.consent.mgt.core.model.ReceiptServiceInput) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ConsentPurpose(org.wso2.carbon.consent.mgt.core.model.ConsentPurpose) Purpose(org.wso2.carbon.consent.mgt.core.model.Purpose) ReceiptPurposeInput(org.wso2.carbon.consent.mgt.core.model.ReceiptPurposeInput) PIICategoryValidity(org.wso2.carbon.consent.mgt.core.model.PIICategoryValidity) PurposeCategory(org.wso2.carbon.consent.mgt.core.model.PurposeCategory)

Aggregations

ReceiptPurposeInput (org.wso2.carbon.consent.mgt.core.model.ReceiptPurposeInput)6 ReceiptServiceInput (org.wso2.carbon.consent.mgt.core.model.ReceiptServiceInput)5 PIICategoryValidity (org.wso2.carbon.consent.mgt.core.model.PIICategoryValidity)4 ArrayList (java.util.ArrayList)3 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 Purpose (org.wso2.carbon.consent.mgt.core.model.Purpose)2 ConsentUtilityServiceException (org.wso2.carbon.identity.consent.mgt.exceptions.ConsentUtilityServiceException)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ConsentPurpose (org.wso2.carbon.consent.mgt.core.model.ConsentPurpose)1 PurposeCategory (org.wso2.carbon.consent.mgt.core.model.PurposeCategory)1