use of org.wso2.carbon.identity.mgt.ChallengeQuestionProcessor in project carbon-identity-framework by wso2.
the class UserInformationRecoveryService method getAllChallengeQuestions.
/**
* Get all challenge questions
*
* @return array of questions
* @throws IdentityMgtServiceException if fails
*/
public ChallengeQuestionDTO[] getAllChallengeQuestions() throws IdentityMgtServiceException {
ChallengeQuestionProcessor processor = IdentityMgtServiceComponent.getRecoveryProcessor().getQuestionProcessor();
List<ChallengeQuestionDTO> questionDTOs = null;
try {
questionDTOs = processor.getAllChallengeQuestions();
} catch (IdentityException e) {
log.error("Error while loading user challenges", e);
throw new IdentityMgtServiceException("Error while loading user challenges");
}
return questionDTOs.toArray(new ChallengeQuestionDTO[questionDTOs.size()]);
}
use of org.wso2.carbon.identity.mgt.ChallengeQuestionProcessor in project carbon-identity-framework by wso2.
the class UserIdentityManagementAdminService method getChallengeQuestionsOfUser.
/**
* get challenges of user
*
* @param userName bean class that contains user and tenant Information
* @return array of challenges if null, return empty array
* @throws org.wso2.carbon.identity.mgt.IdentityMgtServiceException if fails
*/
public UserChallengesDTO[] getChallengeQuestionsOfUser(String userName) throws IdentityMgtServiceException {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
String loggedInName = CarbonContext.getThreadLocalCarbonContext().getUsername();
if (userName != null && !userName.equals(loggedInName)) {
AuthorizationManager authzManager = null;
try {
authzManager = IdentityMgtServiceComponent.getRealmService().getTenantUserRealm(tenantId).getAuthorizationManager();
} catch (UserStoreException e) {
throw new IdentityMgtServiceException("Error occurred while retrieving AuthorizationManager for tenant " + tenantDomain, e);
}
boolean isAuthorized = false;
try {
isAuthorized = authzManager.isUserAuthorized(loggedInName, "/permission/admin/manage/identity/identitymgt/view", CarbonConstants.UI_PERMISSION_ACTION);
} catch (UserStoreException e) {
throw new IdentityMgtServiceException("Error occurred while checking access level for " + "user " + userName + " in tenant " + tenantDomain, e);
}
if (!isAuthorized) {
throw new IdentityMgtServiceException("Unauthorized access!! Possible violation of confidentiality. " + "User " + loggedInName + " trying to get challenge questions for user " + userName);
}
} else if (userName == null) {
userName = loggedInName;
}
ChallengeQuestionProcessor processor = IdentityMgtServiceComponent.getRecoveryProcessor().getQuestionProcessor();
return processor.getChallengeQuestionsOfUser(userName, tenantId, true);
}
use of org.wso2.carbon.identity.mgt.ChallengeQuestionProcessor in project carbon-identity-framework by wso2.
the class UserIdentityManagementAdminService method getAllChallengeQuestions.
/**
* get all challenge questions
*
* @return array of questions
* @throws IdentityMgtServiceException if fails
*/
public ChallengeQuestionDTO[] getAllChallengeQuestions() throws IdentityMgtServiceException {
ChallengeQuestionProcessor processor = IdentityMgtServiceComponent.getRecoveryProcessor().getQuestionProcessor();
List<ChallengeQuestionDTO> questionDTOs = null;
try {
questionDTOs = processor.getAllChallengeQuestions();
} catch (IdentityException e) {
String errorMessage = "Error while loading user challenge questions";
log.error(errorMessage, e);
throw new IdentityMgtServiceException(errorMessage);
}
return questionDTOs.toArray(new ChallengeQuestionDTO[questionDTOs.size()]);
}
Aggregations