use of org.wso2.carbon.consent.mgt.core.ConsentManager in project identity-governance by wso2-extensions.
the class UserSelfRegistrationManager method validateAndFilterFromReceipt.
private void validateAndFilterFromReceipt(String consent, Map<String, String> claimsMap) throws IdentityRecoveryServerException {
if (StringUtils.isEmpty(consent)) {
return;
}
ConsentManager consentManager = IdentityRecoveryServiceDataHolder.getInstance().getConsentManager();
try {
List<Purpose> purposes = consentManager.listPurposes(PURPOSE_GROUP_SELF_REGISTER, PURPOSE_GROUP_TYPE_SYSTEM, 0, 0);
Gson gson = new Gson();
ReceiptInput receiptInput = gson.fromJson(consent, ReceiptInput.class);
validateUserConsent(receiptInput, purposes);
filterClaimsFromReceipt(receiptInput, claimsMap);
} catch (ConsentManagementException e) {
throw new IdentityRecoveryServerException("Error while retrieving System purposes for self registration", e);
}
}
use of org.wso2.carbon.consent.mgt.core.ConsentManager in project carbon-identity-framework by wso2.
the class ConsentDeletionAppMgtListener method doPostDeleteApplication.
/**
* When an application is deleted, it will delete all relevant receipts issued againsed that application.
*
* @param applicationName Name of the application which is getting deleted.
* @param tenantDomain Tenant domain of the application.
* @param userName Username of the person who does the deletion.
* @return true.
* @throws IdentityApplicationManagementException IdentityApplicationManagementException.
*/
@Override
public boolean doPostDeleteApplication(String applicationName, String tenantDomain, String userName) throws IdentityApplicationManagementException {
ConsentManager consentManager = IdentityConsentDataHolder.getInstance().getConsentManager();
if (log.isDebugEnabled()) {
log.debug(String.format("Deleting consents on deletion of application: %s, in tenant domain: %s.", applicationName, tenantDomain));
}
try {
List<ReceiptListResponse> receiptListResponses = consentManager.searchReceipts(consentSearchLimit, 0, "*", tenantDomain, applicationName, null, null);
if (log.isDebugEnabled()) {
log.debug(String.format("%d number of consents found for application %s", receiptListResponses.size(), applicationName));
}
receiptListResponses.forEach(rethrowConsumer(receiptListResponse -> {
if (log.isDebugEnabled()) {
log.debug(String.format("Deleting receipt with id : %s, issued for user: ", receiptListResponse.getConsentReceiptId(), receiptListResponse.getPiiPrincipalId()));
}
consentManager.deleteReceipt(receiptListResponse.getConsentReceiptId());
}));
} catch (ConsentManagementException e) {
throw new IdentityApplicationManagementException("Error while deleting user consents for application " + applicationName, e);
}
return true;
}
use of org.wso2.carbon.consent.mgt.core.ConsentManager in project carbon-identity-framework by wso2.
the class ConsentUtilityService method getPIIName.
private String getPIIName(int purposeId, int pIIId) throws ConsentUtilityServiceException {
ConsentManager consentManager = IdentityConsentDataHolder.getInstance().getConsentManager();
try {
Purpose purpose = consentManager.getPurpose(purposeId);
List<PurposePIICategory> purposePIICategories = purpose.getPurposePIICategories();
for (PurposePIICategory purposePIICategory : purposePIICategories) {
if (purposePIICategory.getId() == pIIId) {
return purposePIICategory.getName();
}
}
} catch (ConsentManagementException e) {
throw new ConsentUtilityServiceException("Error while retrieving purpose with id:" + purposeId, e);
}
throw new ConsentUtilityServiceException("No PII can be found within given id: " + pIIId + "for purpose :" + purposeId);
}
Aggregations