use of org.wso2.carbon.consent.mgt.core.model.ReceiptServiceInput 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.ReceiptServiceInput in project carbon-identity-framework by wso2.
the class JITProvisioningPostAuthenticationHandler method setIDPData.
/**
* Set the IDP releated data in the receipt service input.
*
* @param tenantDomain Tenant domain.
* @param receiptServiceInput Relevant receipt service input which the
* @throws PostAuthenticationFailedException Post Authentication Failed Exception.
*/
private void setIDPData(String tenantDomain, ReceiptServiceInput receiptServiceInput) throws PostAuthenticationFailedException {
String resideIdpDescription = "Resident IDP";
IdentityProviderManager idpManager = IdentityProviderManager.getInstance();
IdentityProvider residentIdP = null;
try {
residentIdP = idpManager.getResidentIdP(tenantDomain);
} catch (IdentityProviderManagementException e) {
handleExceptions(String.format(ErrorMessages.ERROR_WHILE_SETTING_IDP_DATA.getMessage(), tenantDomain), ErrorMessages.ERROR_WHILE_SETTING_IDP_DATA.getCode(), e);
}
if (residentIdP == null) {
throw new PostAuthenticationFailedException(ErrorMessages.ERROR_WHILE_SETTING_IDP_DATA_IDP_IS_NULL.getCode(), String.format(ErrorMessages.ERROR_WHILE_SETTING_IDP_DATA_IDP_IS_NULL.getMessage(), tenantDomain));
}
if (StringUtils.isEmpty(receiptServiceInput.getService())) {
if (log.isDebugEnabled()) {
log.debug("No service name found. Hence adding resident IDP home realm ID");
}
receiptServiceInput.setService(residentIdP.getHomeRealmId());
}
if (StringUtils.isEmpty(receiptServiceInput.getTenantDomain())) {
receiptServiceInput.setTenantDomain(tenantDomain);
}
if (StringUtils.isEmpty(receiptServiceInput.getSpDescription())) {
if (StringUtils.isNotEmpty(residentIdP.getIdentityProviderDescription())) {
receiptServiceInput.setSpDescription(residentIdP.getIdentityProviderDescription());
} else {
receiptServiceInput.setSpDescription(resideIdpDescription);
}
}
if (StringUtils.isEmpty(receiptServiceInput.getSpDisplayName())) {
if (StringUtils.isNotEmpty(residentIdP.getDisplayName())) {
receiptServiceInput.setSpDisplayName(residentIdP.getDisplayName());
} else {
receiptServiceInput.setSpDisplayName(resideIdpDescription);
}
}
}
use of org.wso2.carbon.consent.mgt.core.model.ReceiptServiceInput in project carbon-identity-framework by wso2.
the class JITProvisioningPostAuthenticationHandler method addConsent.
/**
* Persist the consents received from the user, while user creation.
*
* @param receiptInput Relevant receipt input representing consent data.
* @param tenantDomain Relevant tenant domain.
* @throws PostAuthenticationFailedException Post Authentication Failed Exception.
*/
private void addConsent(ReceiptInput receiptInput, String tenantDomain) throws PostAuthenticationFailedException {
ConsentManager consentManager = FrameworkServiceDataHolder.getInstance().getConsentManager();
if (receiptInput.getServices().size() == 0) {
throw new PostAuthenticationFailedException(ErrorMessages.ERROR_WHILE_ADDING_CONSENT.getCode(), String.format(ErrorMessages.ERROR_WHILE_ADDING_CONSENT.getMessage(), tenantDomain));
}
// There should be one receipt
ReceiptServiceInput receiptServiceInput = receiptInput.getServices().get(0);
receiptServiceInput.setTenantDomain(tenantDomain);
try {
setIDPData(tenantDomain, receiptServiceInput);
receiptInput.setTenantDomain(tenantDomain);
consentManager.addConsent(receiptInput);
} catch (ConsentManagementException e) {
handleExceptions(String.format(ErrorMessages.ERROR_WHILE_ADDING_CONSENT.getMessage(), tenantDomain), ErrorMessages.ERROR_WHILE_ADDING_CONSENT.getCode(), e);
}
}
use of org.wso2.carbon.consent.mgt.core.model.ReceiptServiceInput 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.ReceiptServiceInput in project identity-governance by wso2-extensions.
the class UserSelfRegistrationManager method setIDPData.
private void setIDPData(String tenantDomain, ReceiptServiceInput receiptServiceInput) throws IdentityProviderManagementException {
IdentityProviderManager idpManager = IdentityProviderManager.getInstance();
IdentityProvider residentIdP = idpManager.getResidentIdP(tenantDomain);
if (StringUtils.isEmpty(receiptServiceInput.getService())) {
if (log.isDebugEnabled()) {
log.debug("No service name found. Hence adding resident IDP home realm ID");
}
receiptServiceInput.setService(residentIdP.getHomeRealmId());
}
if (StringUtils.isEmpty(receiptServiceInput.getTenantDomain())) {
receiptServiceInput.setTenantDomain(tenantDomain);
}
if (StringUtils.isEmpty(receiptServiceInput.getSpDescription())) {
if (StringUtils.isNotEmpty(residentIdP.getIdentityProviderDescription())) {
receiptServiceInput.setSpDescription(residentIdP.getIdentityProviderDescription());
} else {
receiptServiceInput.setSpDescription(IdentityRecoveryConstants.Consent.RESIDENT_IDP);
}
}
if (StringUtils.isEmpty(receiptServiceInput.getSpDisplayName())) {
if (StringUtils.isNotEmpty(residentIdP.getDisplayName())) {
receiptServiceInput.setSpDisplayName(residentIdP.getDisplayName());
} else {
receiptServiceInput.setSpDisplayName(IdentityRecoveryConstants.Consent.RESIDENT_IDP);
}
}
}
Aggregations