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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations