Search in sources :

Example 1 with PurposeCategory

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;
}
Also used : ConsentManagementException(org.wso2.carbon.consent.mgt.core.exception.ConsentManagementException) SSOConsentServiceException(org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.consent.exception.SSOConsentServiceException) PurposeCategory(org.wso2.carbon.consent.mgt.core.model.PurposeCategory)

Example 2 with 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);
}
Also used : ReceiptServiceInput(org.wso2.carbon.consent.mgt.core.model.ReceiptServiceInput) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ConsentPurpose(org.wso2.carbon.consent.mgt.core.model.ConsentPurpose) Purpose(org.wso2.carbon.consent.mgt.core.model.Purpose) ReceiptPurposeInput(org.wso2.carbon.consent.mgt.core.model.ReceiptPurposeInput) PIICategoryValidity(org.wso2.carbon.consent.mgt.core.model.PIICategoryValidity) PurposeCategory(org.wso2.carbon.consent.mgt.core.model.PurposeCategory)

Example 3 with PurposeCategory

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();
    }
}
Also used : ConsentManagementException(org.wso2.carbon.consent.mgt.core.exception.ConsentManagementException) PurposeCategory(org.wso2.carbon.consent.mgt.core.model.PurposeCategory) StratosException(org.wso2.carbon.stratos.common.exception.StratosException)

Example 4 with PurposeCategory

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");
}
Also used : User(org.wso2.carbon.automation.engine.context.beans.User) JSONObject(org.json.JSONObject) RestClient(org.apache.wink.client.RestClient) Resource(org.apache.wink.client.Resource)

Example 5 with PurposeCategory

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"));
}
Also used : JSONObject(org.json.simple.JSONObject) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

PurposeCategory (org.wso2.carbon.consent.mgt.core.model.PurposeCategory)3 ConsentManagementException (org.wso2.carbon.consent.mgt.core.exception.ConsentManagementException)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Resource (org.apache.wink.client.Resource)1 RestClient (org.apache.wink.client.RestClient)1 JSONObject (org.json.JSONObject)1 JSONObject (org.json.simple.JSONObject)1 Test (org.testng.annotations.Test)1 User (org.wso2.carbon.automation.engine.context.beans.User)1 ConsentPurpose (org.wso2.carbon.consent.mgt.core.model.ConsentPurpose)1 PIICategoryValidity (org.wso2.carbon.consent.mgt.core.model.PIICategoryValidity)1 Purpose (org.wso2.carbon.consent.mgt.core.model.Purpose)1 ReceiptPurposeInput (org.wso2.carbon.consent.mgt.core.model.ReceiptPurposeInput)1 ReceiptServiceInput (org.wso2.carbon.consent.mgt.core.model.ReceiptServiceInput)1 SSOConsentServiceException (org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.consent.exception.SSOConsentServiceException)1 StratosException (org.wso2.carbon.stratos.common.exception.StratosException)1 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)1