Search in sources :

Example 31 with VerificationBean

use of org.wso2.carbon.identity.mgt.beans.VerificationBean 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 32 with VerificationBean

use of org.wso2.carbon.identity.mgt.beans.VerificationBean in project product-is by wso2.

the class UserInformationRecoveryServiceTestCase method testRegisterUserWithInvalidTenant.

@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = "wso2.is", description = "Check user registration validation with Invalid Tenant", dependsOnMethods = "testRegisterUser")
public void testRegisterUserWithInvalidTenant() throws Exception {
    UserIdentityClaimDTO[] claims = new UserIdentityClaimDTO[2];
    UserIdentityClaimDTO claimEmail = new UserIdentityClaimDTO();
    claimEmail.setClaimUri("http://wso2.org/claims/emailaddress");
    claimEmail.setClaimValue("user2@wso2.com");
    UserIdentityClaimDTO claimLastName = new UserIdentityClaimDTO();
    claimLastName.setClaimUri("http://wso2.org/claims/givenname");
    claimLastName.setClaimValue("user2");
    claims[0] = claimEmail;
    claims[1] = claimLastName;
    VerificationBean bean = infoRecoveryClient.registerUser(null, "passWord1@", claims, "default", "tenant");
    Assert.assertNotNull(bean.getError(), "The expected error message is null with null return");
}
Also used : VerificationBean(org.wso2.carbon.identity.mgt.stub.beans.VerificationBean) UserIdentityClaimDTO(org.wso2.carbon.identity.mgt.stub.dto.UserIdentityClaimDTO) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment) Test(org.testng.annotations.Test) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest)

Example 33 with VerificationBean

use of org.wso2.carbon.identity.mgt.beans.VerificationBean in project product-is by wso2.

the class UserInformationRecoveryServiceTestCase method testVerifyUserChallengeAnswer.

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

Example 34 with VerificationBean

use of org.wso2.carbon.identity.mgt.beans.VerificationBean in project product-is by wso2.

the class UserInformationRecoveryServiceTestCase method testVerifyConfirmationCode.

@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = "wso2.is", description = "Check verify confirmation code", dependsOnMethods = "testSendRecoveryNotification")
public void testVerifyConfirmationCode() throws Exception {
    VerificationBean bean = infoRecoveryClient.verifyConfirmationCode("user11", confKey, null);
    Assert.assertNotNull(bean, "Verify confirmation code has failed with null return");
// Assert.assertNotNull(bean.getKey(), "Verify User has failed with null key return");
// confKey = bean.getKey();
// NotificationDataDTO dataDto = bean.getNotificationData();
}
Also used : VerificationBean(org.wso2.carbon.identity.mgt.stub.beans.VerificationBean) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment) Test(org.testng.annotations.Test) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest)

Example 35 with VerificationBean

use of org.wso2.carbon.identity.mgt.beans.VerificationBean in project product-is by wso2.

the class UserInformationRecoveryServiceTestCase method testRegisterUserWithEmptyPassword.

@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = "wso2.is", description = "Check user registration validation with empty password", dependsOnMethods = "testRegisterUser")
public void testRegisterUserWithEmptyPassword() throws Exception {
    UserIdentityClaimDTO[] claims = new UserIdentityClaimDTO[2];
    UserIdentityClaimDTO claimEmail = new UserIdentityClaimDTO();
    claimEmail.setClaimUri("http://wso2.org/claims/emailaddress");
    claimEmail.setClaimValue("user2@wso2.com");
    UserIdentityClaimDTO claimLastName = new UserIdentityClaimDTO();
    claimLastName.setClaimUri("http://wso2.org/claims/givenname");
    claimLastName.setClaimValue("user2");
    claims[0] = claimEmail;
    claims[1] = claimLastName;
    VerificationBean bean = infoRecoveryClient.registerUser("user3", null, claims, "default", null);
    Assert.assertNotNull(bean.getError(), "The expected error message is null with null return");
}
Also used : VerificationBean(org.wso2.carbon.identity.mgt.stub.beans.VerificationBean) UserIdentityClaimDTO(org.wso2.carbon.identity.mgt.stub.dto.UserIdentityClaimDTO) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment) Test(org.testng.annotations.Test) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest)

Aggregations

VerificationBean (org.wso2.carbon.identity.mgt.beans.VerificationBean)23 IdentityException (org.wso2.carbon.identity.base.IdentityException)21 RecoveryProcessor (org.wso2.carbon.identity.mgt.RecoveryProcessor)17 UserDTO (org.wso2.carbon.identity.mgt.dto.UserDTO)17 Test (org.testng.annotations.Test)14 SetEnvironment (org.wso2.carbon.automation.engine.annotations.SetEnvironment)14 VerificationBean (org.wso2.carbon.identity.mgt.stub.beans.VerificationBean)14 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)14 PrivilegedCarbonContext (org.wso2.carbon.context.PrivilegedCarbonContext)12 IdentityMgtServiceException (org.wso2.carbon.identity.mgt.IdentityMgtServiceException)11 UserStoreException (org.wso2.carbon.user.api.UserStoreException)10 UserIdentityClaimDTO (org.wso2.carbon.identity.mgt.stub.dto.UserIdentityClaimDTO)7 NotificationDataDTO (org.wso2.carbon.identity.mgt.dto.NotificationDataDTO)5 UserRecoveryDTO (org.wso2.carbon.identity.mgt.dto.UserRecoveryDTO)5 UserChallengesDTO (org.wso2.carbon.identity.mgt.dto.UserChallengesDTO)4 UserRecoveryDataDO (org.wso2.carbon.identity.mgt.dto.UserRecoveryDataDO)4 ChallengeQuestionProcessor (org.wso2.carbon.identity.mgt.ChallengeQuestionProcessor)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 IdentityEventListenerConfig (org.wso2.carbon.identity.core.model.IdentityEventListenerConfig)2 IdentityMgtConfig (org.wso2.carbon.identity.mgt.IdentityMgtConfig)2