use of org.wso2.carbon.identity.user.export.core.UserExportException in project identity-governance by wso2-extensions.
the class MeApiServiceImpl method getMe.
@Override
public Response getMe() {
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
String userStoreDomain = UserCoreUtil.extractDomainFromName(username);
username = UserCoreUtil.removeDomainFromName(username);
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
Map userAttributes;
try {
userAttributes = Utils.getUserInformationService().getRetainedUserInformation(username, userStoreDomain, tenantId);
} catch (UserExportException e) {
ErrorDTO errorDTO = new ErrorDTO();
errorDTO.setRef(Utils.getCorrelation());
errorDTO.setMessage(e.getMessage());
return Response.serverError().entity(errorDTO).build();
}
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 BasicUserInformationProvider method getUserStoreManager.
protected UserStoreManager getUserStoreManager(int tenantId, String userStoreDomain) throws UserExportException {
UserStoreManager userStoreManager;
try {
String tenantDomain = realmService.getTenantManager().getDomain(tenantId);
userStoreManager = getUserRealm(tenantDomain).getUserStoreManager().getSecondaryUserStoreManager(userStoreDomain);
} catch (UserStoreException e) {
throw new UserExportException("Error while retrieving the user store manager.", e);
}
if (log.isDebugEnabled()) {
log.debug("Retrieved user store manager for tenant id: " + tenantId);
}
return userStoreManager;
}
use of org.wso2.carbon.identity.user.export.core.UserExportException in project identity-governance by wso2-extensions.
the class SecurityInformationProvider method getRetainedUserInformation.
@Override
public UserInformationDTO getRetainedUserInformation(String username, String userStoreDomain, int tenantId) throws UserExportException {
String challengeQuestionClaimValue = null;
UserStoreManager userStoreManager;
try {
userStoreManager = getUserStoreManager(tenantId, userStoreDomain);
Claim[] userClaims = userStoreManager.getUserClaimValues(username, null);
for (Claim claim : userClaims) {
if (CHALLENGE_QUESTION_URIS_CLAIM.equals(claim.getClaimUri())) {
challengeQuestionClaimValue = userStoreManager.getUserClaimValue(username, CHALLENGE_QUESTION_URIS_CLAIM, null);
}
}
} catch (UserStoreException e) {
throw new UserExportException("Error while retrieving the user information.", e);
}
if (challengeQuestionClaimValue != null) {
List<String> challengeQuestionUris = getChallengeQuestionUris(challengeQuestionClaimValue);
SecurityInformationDTO securityInformationDTO = new SecurityInformationDTO();
if (challengeQuestionUris.size() > 0) {
Map<String, String> challengeQuestions;
try {
challengeQuestions = userStoreManager.getUserClaimValues(username, challengeQuestionUris.toArray(new String[challengeQuestionUris.size()]), null);
} catch (UserStoreException e) {
throw new UserExportException("Error while retrieving the user information.", e);
}
String challengeQuestionSeparator = challengeQuestionSeparator();
for (Map.Entry<String, String> challengeQuestion : challengeQuestions.entrySet()) {
String[] challengeQuestionsParts = challengeQuestion.getValue().split(challengeQuestionSeparator);
securityInformationDTO.addChallengeQuestion(challengeQuestionsParts[0]);
}
}
return new UserInformationDTO(securityInformationDTO);
} else {
if (log.isDebugEnabled()) {
log.debug("Challenge question claim is not available in the tenant: " + tenantId);
}
}
return new UserInformationDTO();
}
use of org.wso2.carbon.identity.user.export.core.UserExportException in project identity-governance by wso2-extensions.
the class UserInformationServiceImpl method getRetainedUserInformation.
@Override
public Map<String, Object> getRetainedUserInformation(String username, String userStoreDomain, int tenantId) throws UserExportException {
Map<String, Object> userInformation = new HashMap<>();
for (UserInformationProvider userInformationProvider : userInformationProviders) {
if (userInformationProvider.isEnabled()) {
UserInformationDTO retainedUserInformation = userInformationProvider.getRetainedUserInformation(username, userStoreDomain, tenantId);
if (retainedUserInformation != null && retainedUserInformation.isInformationAvailable()) {
String type = userInformationProvider.getType();
userInformation.put(type, retainedUserInformation.getData());
}
}
}
return userInformation;
}
use of org.wso2.carbon.identity.user.export.core.UserExportException 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();
}
}
Aggregations