use of org.wso2.carbon.identity.user.export.core.dto.UserInformationDTO in project identity-governance by wso2-extensions.
the class BasicUserInformationProvider method getRetainedUserInformation.
@Override
public UserInformationDTO getRetainedUserInformation(String username, String userStoreDomain, int tenantId) throws UserExportException {
Claim[] userClaimValues;
try {
userClaimValues = getUserStoreManager(tenantId, userStoreDomain).getUserClaimValues(username, null);
} catch (UserStoreException e) {
throw new UserExportException("Error while retrieving the user information.", e);
}
if (userClaimValues != null) {
Map<String, String> attributes = Arrays.stream(userClaimValues).collect(Collectors.toMap(Claim::getClaimUri, Claim::getValue));
List<String> challengeQuestionUris = getChallengeQuestionUris(attributes);
if (challengeQuestionUris.size() > 0) {
for (String challengeQuestionUri : challengeQuestionUris) {
attributes.remove(challengeQuestionUri);
}
}
attributes.remove(CHALLENGE_QUESTION_URIS_CLAIM);
return new UserInformationDTO(attributes);
} else {
return new UserInformationDTO();
}
}
use of org.wso2.carbon.identity.user.export.core.dto.UserInformationDTO 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.identity.user.export.core.dto.UserInformationDTO in project identity-governance by wso2-extensions.
the class MockUserInformationService method getRetainedUserInformation.
@Override
public Map<String, Object> getRetainedUserInformation(String username, String userStoreDomain, int tenantId) throws UserExportException {
Map<String, String> attributes = new HashMap<>();
attributes.put("http://wso2.org/claims/username", "username1");
attributes.put("http://wso2.org/claims/givenname", "lastname1");
attributes.put("http://wso2.org/claims/lastname", "lastname1");
UserInformationDTO basicUserInformationDTO = new UserInformationDTO(attributes);
Map<String, Object> info = new HashMap<>();
info.put("basic", basicUserInformationDTO.getData());
return info;
}
Aggregations