Search in sources :

Example 21 with UserChallengesDTO

use of org.wso2.carbon.identity.mgt.dto.UserChallengesDTO in project carbon-identity-framework by wso2.

the class UserIdentityManagementService method getChallengeQuestionsForUser.

/**
 * get challenges of user
 *
 * @return array of challenges  if null, return empty array
 * @throws IdentityException if fails
 */
public UserChallengesDTO[] getChallengeQuestionsForUser(String userName, String confirmation) throws IdentityMgtServiceException {
    UserDTO userDTO = null;
    try {
        userDTO = Utils.processUserId(userName);
    } catch (IdentityException e) {
        throw new IdentityMgtServiceException("Invalid user name.", e);
    }
    RecoveryProcessor processor = IdentityMgtServiceComponent.getRecoveryProcessor();
    VerificationBean bean = processor.verifyConfirmationKey(confirmation);
    if (bean.isVerified()) {
        try {
            processor.createConfirmationCode(userDTO, confirmation);
        } catch (IdentityException e) {
            log.error("Error in creating confirmation code.", e);
        }
        return processor.getQuestionProcessor().getChallengeQuestionsOfUser(userDTO.getUserId(), userDTO.getTenantId(), false);
    }
    return new UserChallengesDTO[0];
}
Also used : VerificationBean(org.wso2.carbon.identity.mgt.beans.VerificationBean) IdentityMgtServiceException(org.wso2.carbon.identity.mgt.IdentityMgtServiceException) UserChallengesDTO(org.wso2.carbon.identity.mgt.dto.UserChallengesDTO) UserDTO(org.wso2.carbon.identity.mgt.dto.UserDTO) RecoveryProcessor(org.wso2.carbon.identity.mgt.RecoveryProcessor) IdentityException(org.wso2.carbon.identity.base.IdentityException)

Example 22 with UserChallengesDTO

use of org.wso2.carbon.identity.mgt.dto.UserChallengesDTO in project carbon-identity-framework by wso2.

the class UserIdentityManagementUtil method handleChallengesError.

private static UserChallengesDTO handleChallengesError(String error, Exception e) {
    UserChallengesDTO bean = new UserChallengesDTO();
    if (error != null) {
        bean.setError(error);
        log.error(error, e);
    } else {
        bean.setError(e.getMessage());
        log.error(e);
    }
    return bean;
}
Also used : UserChallengesDTO(org.wso2.carbon.identity.mgt.dto.UserChallengesDTO)

Example 23 with UserChallengesDTO

use of org.wso2.carbon.identity.mgt.dto.UserChallengesDTO in project product-is by wso2.

the class UserInformationRecoveryServiceTestCase method testGetUserChallengeQuestion.

@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = "wso2.is", description = "Check get user challenge question", dependsOnMethods = "testGetUserChallengeQuestionIds")
public void testGetUserChallengeQuestion() throws Exception {
    UserChallengesDTO bean = infoRecoveryClient.getUserChallengeQuestion("user11", confKey, "");
    Assert.assertNotNull(bean, "Getting challenge question has failed with null return");
}
Also used : UserChallengesDTO(org.wso2.carbon.identity.mgt.stub.dto.UserChallengesDTO) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment) Test(org.testng.annotations.Test) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest)

Aggregations

UserChallengesDTO (org.wso2.carbon.identity.mgt.dto.UserChallengesDTO)17 IdentityException (org.wso2.carbon.identity.base.IdentityException)16 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)8 UserStoreException (org.wso2.carbon.user.core.UserStoreException)8 ArrayList (java.util.ArrayList)6 ChallengeQuestionProcessor (org.wso2.carbon.identity.mgt.ChallengeQuestionProcessor)6 IdentityMgtServiceException (org.wso2.carbon.identity.mgt.IdentityMgtServiceException)6 RecoveryProcessor (org.wso2.carbon.identity.mgt.RecoveryProcessor)6 VerificationBean (org.wso2.carbon.identity.mgt.beans.VerificationBean)6 UserDTO (org.wso2.carbon.identity.mgt.dto.UserDTO)6 HashMap (java.util.HashMap)4 PrivilegedCarbonContext (org.wso2.carbon.context.PrivilegedCarbonContext)4 Map (java.util.Map)3 UserChallengesDTO (org.wso2.carbon.identity.mgt.stub.dto.UserChallengesDTO)3 Test (org.testng.annotations.Test)2 SetEnvironment (org.wso2.carbon.automation.engine.annotations.SetEnvironment)2 ChallengeQuestionDTO (org.wso2.carbon.identity.mgt.dto.ChallengeQuestionDTO)2 AuthorizationManager (org.wso2.carbon.user.api.AuthorizationManager)2 UserStoreException (org.wso2.carbon.user.api.UserStoreException)2 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)2