use of org.wso2.carbon.consent.mgt.core.model.PIICategoryValidity 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.PIICategoryValidity 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.PIICategoryValidity 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.PIICategoryValidity 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;
}
use of org.wso2.carbon.consent.mgt.core.model.PIICategoryValidity in project identity-governance by wso2-extensions.
the class Utils method getConsentReceiptDTO.
/**
* This API is used to get ConsentReceiptDTO response.
*
* @param receipt Receipt instance.
* @return ConsentReceiptDTO.
*/
public static ConsentReceiptDTO getConsentReceiptDTO(Receipt receipt) {
ConsentReceiptDTO consentReceiptDTO = new ConsentReceiptDTO();
consentReceiptDTO.setCollectionMethod(receipt.getCollectionMethod());
consentReceiptDTO.setConsentReceiptID(receipt.getConsentReceiptId());
consentReceiptDTO.setJurisdiction(receipt.getJurisdiction());
consentReceiptDTO.setConsentTimestamp(receipt.getConsentTimestamp());
consentReceiptDTO.setLanguage(receipt.getLanguage());
consentReceiptDTO.setPiiPrincipalId(receipt.getPiiPrincipalId());
consentReceiptDTO.setPolicyUrl(receipt.getPolicyUrl());
consentReceiptDTO.setSensitive(receipt.isSensitive());
consentReceiptDTO.setTenantDomain(receipt.getTenantDomain());
consentReceiptDTO.setVersion(receipt.getVersion());
consentReceiptDTO.setState(receipt.getState());
consentReceiptDTO.setServices(receipt.getServices().stream().map(receiptService -> {
ServiceDTO serviceDTO = new ServiceDTO();
serviceDTO.setService(receiptService.getService());
serviceDTO.setTenantDomain(receiptService.getTenantDomain());
serviceDTO.setPurposes(receiptService.getPurposes().stream().map(consentPurpose -> {
PurposeDTO purposeDTO = new PurposeDTO();
purposeDTO.setConsentType(consentPurpose.getConsentType());
purposeDTO.setPiiCategory(consentPurpose.getPiiCategory().stream().map(piiCategoryValidity -> {
PiiCategoryDTO piiCategoryDTO = new PiiCategoryDTO();
piiCategoryDTO.setPiiCategory(piiCategoryValidity.getName());
piiCategoryDTO.setValidity(piiCategoryValidity.getValidity());
return piiCategoryDTO;
}).collect(Collectors.toList()));
purposeDTO.setPrimaryPurpose(consentPurpose.isPrimaryPurpose());
purposeDTO.setPurpose(consentPurpose.getPurpose());
purposeDTO.setPurposeCategory(consentPurpose.getPurposeCategory());
purposeDTO.setTermination(consentPurpose.getTermination());
purposeDTO.setThirdPartyDisclosure(consentPurpose.isThirdPartyDisclosure());
purposeDTO.setThirdPartyName(consentPurpose.getThirdPartyName());
return purposeDTO;
}).collect(Collectors.toList()));
return serviceDTO;
}).collect(Collectors.toList()));
consentReceiptDTO.setSpiCat(receipt.getSpiCat());
consentReceiptDTO.setPiiControllers(receipt.getPiiControllers().stream().map(piiController -> {
PiiControllerDTO piiControllerDTO = new PiiControllerDTO();
AddressDTO addressDTO = new AddressDTO();
consentReceiptDTO.setPublicKey(receipt.getPublicKey());
addressDTO.setAddressCountry(piiController.getAddress().getAddressCountry());
addressDTO.setAddressLocality(piiController.getAddress().getAddressLocality());
addressDTO.setAddressRegion(piiController.getAddress().getAddressRegion());
addressDTO.setPostalCode(piiController.getAddress().getPostalCode());
addressDTO.setPostOfficeBoxNumber(piiController.getAddress().getPostOfficeBoxNumber());
addressDTO.setStreetAddress(piiController.getAddress().getStreetAddress());
piiControllerDTO.setAddress(addressDTO);
piiControllerDTO.setContact(piiController.getContact());
piiControllerDTO.setEmail(piiController.getEmail());
piiControllerDTO.setPhone(piiController.getPhone());
piiControllerDTO.setPiiController(piiController.getPiiController());
piiControllerDTO.setPiiControllerUrl(piiController.getPiiControllerUrl());
piiControllerDTO.setOnBehalf(piiController.isOnBehalf());
return piiControllerDTO;
}).collect(Collectors.toList()));
return consentReceiptDTO;
}
Aggregations