use of org.wso2.carbon.identity.user.export.core.dto.SecurityInformationDTO 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();
}
Aggregations