use of org.wso2.carbon.consent.mgt.core.model.Receipt in project identity-governance by wso2-extensions.
the class UserSelfRegistrationManager method filterClaimsFromReceipt.
private void filterClaimsFromReceipt(ReceiptInput receiptInput, Map<String, String> claims) throws IdentityRecoveryServerException {
ConsentUtilityService consentUtilityService = IdentityRecoveryServiceDataHolder.getInstance().getConsentUtilityService();
try {
Set<String> filteredKeys = consentUtilityService.filterPIIsFromReceipt(claims.keySet(), receiptInput);
claims.keySet().retainAll(filteredKeys);
} catch (ConsentUtilityServiceException e) {
throw new IdentityRecoveryServerException("Receipt validation failed against purposes", e);
}
}
use of org.wso2.carbon.consent.mgt.core.model.Receipt in project identity-governance by wso2-extensions.
the class ConsentInformationProvider method getRetainedUserInformation.
@Override
public UserInformationDTO getRetainedUserInformation(String username, String userStoreDomain, int tenantId) throws UserExportException {
try {
List<ConsentReceiptDTO> receipts = new ArrayList<>();
int limit = 100;
int offset = 0;
String tenantDomain = realmService.getTenantManager().getDomain(tenantId);
List<ReceiptListResponse> receiptListResponses;
do {
receiptListResponses = consentManager.searchReceipts(limit, offset, UserCoreUtil.addDomainToName(username, userStoreDomain), tenantDomain, null, ConsentConstants.ACTIVE_STATE);
for (ReceiptListResponse receiptListResponse : receiptListResponses) {
String receiptId = receiptListResponse.getConsentReceiptId();
Receipt receipt = consentManager.getReceipt(receiptId);
receipts.add(Utils.getConsentReceiptDTO(receipt));
}
offset += limit;
} while (receiptListResponses != null && receiptListResponses.size() != 0);
if (receipts.size() > 0) {
return new UserInformationDTO(receipts);
}
} catch (UserStoreException e) {
throw new UserExportException("Error while retrieving tenant domain from tenant id: " + tenantId, e);
} catch (ConsentManagementException e) {
throw new UserExportException("Error while retrieving consent receipts for user: " + UserCoreUtil.addDomainToName(username, userStoreDomain) + " in tenant id: " + tenantId, e);
}
return new UserInformationDTO();
}
use of org.wso2.carbon.consent.mgt.core.model.Receipt in project product-is by wso2.
the class SelfSignUpConsentTest method getConsent.
private String getConsent(String username, String password, String receiptId) {
log.info("Retrieving consent for username " + username + ". reciptId : " + receiptId);
RestClient restClient = new RestClient();
Resource resource = restClient.resource(consentEndpoint + "/receipts/" + receiptId);
log.info("Calling to receipt endpoint :" + consentEndpoint + "/receipts/" + receiptId);
User user = new User();
user.setUserName(username);
user.setPassword(password);
String response = resource.contentType(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, getBasicAuthHeader(user)).get(String.class);
return response;
}
use of org.wso2.carbon.consent.mgt.core.model.Receipt in project product-is by wso2.
the class SelfSignUpConsentTest method getPurposes.
@Test(alwaysRun = true, groups = "wso2.is", description = "Test for a valid user", dependsOnMethods = "selfSignUpWithConsents")
public void getPurposes() throws Exception {
updateResidentIDPProperty(tenantResidentIDP, ENABLE_SELF_REGISTRATION_PROP_KEY, "true", false);
updateResidentIDPProperty(tenantResidentIDP, DISABLE_ACC_LOCK_ON_SELF_REG_PROP_KEY, "false", false);
String consents = getConsents(EBONY + "@" + secondaryTenantDomain, PASSWORD);
log.info("Consents for user " + EBONY + " :" + consents);
Assert.assertNotNull(consents);
JSONArray purposesJson = new JSONArray(consents);
String receiptID = ((JSONObject) purposesJson.get(0)).getString("consentReceiptID");
String receipt = getConsent(EBONY + "@" + secondaryTenantDomain, PASSWORD, receiptID);
JSONObject receiptJson = new JSONObject(receipt);
Assert.assertEquals(receiptJson.getString("collectionMethod"), "Web Form - Self Registration");
}
Aggregations