use of org.wso2.carbon.consent.mgt.core.model.PurposeCategory in project carbon-identity-framework by wso2.
the class SSOConsentServiceImpl method addDefaultPurposeCategory.
private PurposeCategory addDefaultPurposeCategory() throws SSOConsentServiceException {
PurposeCategory purposeCategory;
PurposeCategory defaultPurposeCategory = new PurposeCategory(DEFAULT_PURPOSE_CATEGORY, "For core functionalities of the product");
try {
purposeCategory = getConsentManager().addPurposeCategory(defaultPurposeCategory);
} catch (ConsentManagementException e) {
throw new SSOConsentServiceException("Consent purpose category error", "Error while adding" + " purpose category: " + DEFAULT_PURPOSE_CATEGORY, e);
}
return purposeCategory;
}
use of org.wso2.carbon.consent.mgt.core.model.PurposeCategory 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);
}
use of org.wso2.carbon.consent.mgt.core.model.PurposeCategory in project carbon-identity-framework by wso2.
the class TenantConsentMgtListener method addDefaultPurposeCategory.
protected void addDefaultPurposeCategory(TenantInfoBean tenantInfoBean) throws StratosException {
FrameworkUtils.startTenantFlow(tenantInfoBean.getTenantDomain());
try {
PurposeCategory purposeCategory;
PurposeCategory defaultPurposeCategory = new PurposeCategory(DEFAULT_PURPOSE_CATEGORY, "Core " + "functionality");
try {
purposeCategory = IdentityConsentDataHolder.getInstance().getConsentManager().addPurposeCategory(defaultPurposeCategory);
if (log.isDebugEnabled()) {
log.debug(String.format("Added default purpose category for tenant: %s. Default purpose category " + "id: %d", tenantInfoBean.getTenantDomain(), purposeCategory.getId()));
}
} catch (ConsentManagementException e) {
throw new StratosException("Error while adding default purpose category for tenant:" + tenantInfoBean.getTenantDomain(), e);
}
} finally {
FrameworkUtils.endTenantFlow();
}
}
use of org.wso2.carbon.consent.mgt.core.model.PurposeCategory in project product-is by wso2.
the class SelfSignUpConsentTest method addPurposeCategory.
private String addPurposeCategory(String name, String description) throws JSONException {
RestClient restClient = new RestClient();
Resource piiCatResource = restClient.resource(consentEndpoint + "/" + "purpose-categories");
String addPurposeCatString = "{\"purposeCategory\": " + "\"" + name + "\"" + ", \"description\": " + "\"" + description + "\"}";
User user = new User();
user.setUserName(tenantAdminUserName);
user.setPassword(ADMIN);
String content = piiCatResource.contentType(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, getBasicAuthHeader(user)).post(String.class, addPurposeCatString);
JSONObject purpose = new JSONObject(content);
return purpose.getString("purposeCategoryId");
}
use of org.wso2.carbon.consent.mgt.core.model.PurposeCategory in project product-is by wso2.
the class ConsentMgtTestCase method testAddPurposeCategory.
@Test(alwaysRun = true, groups = "wso2.is", description = "Add Purpose Category test", dependsOnMethods = { "testAddPIICategory" })
public void testAddPurposeCategory() {
String name = "Financial";
String description = "Financial Purpose";
JSONObject response = addPurposeCategory(name, description);
Assert.assertEquals(name, response.get("purposeCategory"));
Assert.assertEquals(description, response.get("description"));
}
Aggregations