use of org.wso2.carbon.identity.user.export.core.UserExportException 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.UserExportException in project identity-governance by wso2-extensions.
the class PiInfoApiServiceImpl method getUserById.
@Override
public Response getUserById(String userId) {
String usernameFromRequest = new String(Base64.getUrlDecoder().decode(userId.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8);
String userStoreDomain = UserCoreUtil.extractDomainFromName(usernameFromRequest);
String username = UserCoreUtil.removeDomainFromName(usernameFromRequest);
String tenantDomain = MultitenantUtils.getTenantDomain(username);
username = MultitenantUtils.getTenantAwareUsername(usernameFromRequest);
int tenantId;
try {
tenantId = Utils.getRealmService().getTenantManager().getTenantId(tenantDomain);
} catch (UserStoreException e) {
ErrorDTO errorDTO = new ErrorDTO();
errorDTO.setRef(Utils.getCorrelation());
errorDTO.setMessage("Invalid tenant domain provided in username.");
return Response.status(Response.Status.BAD_REQUEST).entity(errorDTO).build();
} catch (UserExportException e) {
ErrorDTO errorDTO = new ErrorDTO();
errorDTO.setRef(Utils.getCorrelation());
errorDTO.setMessage(e.getMessage());
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorDTO).build();
}
Map userAttributes = null;
try {
userAttributes = Utils.getUserInformationService().getRetainedUserInformation(username, userStoreDomain, tenantId);
} catch (UserExportException e) {
Utils.handleNotFound(e.getMessage(), String.valueOf(Response.Status.NOT_FOUND.getStatusCode()));
}
return Response.ok().status(Response.Status.OK).entity(userAttributes).build();
}
use of org.wso2.carbon.identity.user.export.core.UserExportException 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