Search in sources :

Example 41 with ChallengeQuestion

use of org.wso2.carbon.identity.recovery.stub.model.ChallengeQuestion in project identity-api-server by wso2.

the class ServerChallengeService method deleteQuestion.

/**
 * Delete specific challenge question of a given set.
 *
 * @param challengeSetId challenge question set id
 * @param questionId     challenge question to delete
 * @param locale
 * @return
 */
public boolean deleteQuestion(String challengeSetId, String questionId, String locale) {
    if (StringUtils.isEmpty(locale)) {
        locale = StringUtils.EMPTY;
    }
    try {
        if (isChallengeSetExists(challengeSetId, ContextLoader.getTenantDomainFromContext())) {
            ChallengeQuestion[] toDelete = { new ChallengeQuestion(challengeSetId, questionId, StringUtils.EMPTY, locale) };
            getChallengeQuestionManager().deleteChallengeQuestions(toDelete, ContextLoader.getTenantDomainFromContext());
        }
    } catch (IdentityRecoveryException e) {
        throw handleIdentityRecoveryException(e, ChallengeConstant.ErrorMessage.ERROR_CODE_ERROR_DELETING_CHALLENGE);
    }
    return true;
}
Also used : IdentityRecoveryException(org.wso2.carbon.identity.recovery.IdentityRecoveryException) ChallengeQuestion(org.wso2.carbon.identity.recovery.model.ChallengeQuestion)

Aggregations

ChallengeQuestion (org.wso2.carbon.identity.recovery.model.ChallengeQuestion)26 ArrayList (java.util.ArrayList)14 Test (org.testng.annotations.Test)8 IdentityRecoveryException (org.wso2.carbon.identity.recovery.IdentityRecoveryException)8 UserChallengeAnswer (org.wso2.carbon.identity.recovery.model.UserChallengeAnswer)7 ChallengeQuestion (org.wso2.carbon.identity.recovery.stub.model.ChallengeQuestion)6 UserStoreException (org.wso2.carbon.user.api.UserStoreException)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 IdentityRecoveryClientException (org.wso2.carbon.identity.recovery.IdentityRecoveryClientException)5 IdentityException (org.wso2.carbon.identity.base.IdentityException)3 ChallengeQuestionManager (org.wso2.carbon.identity.recovery.ChallengeQuestionManager)3 ChallengeQuestionResponse (org.wso2.carbon.identity.recovery.bean.ChallengeQuestionResponse)3 UserRecoveryData (org.wso2.carbon.identity.recovery.model.UserRecoveryData)3 UserRecoveryDataStore (org.wso2.carbon.identity.recovery.store.UserRecoveryDataStore)3 ChallengeQuestionDTO (org.wso2.carbon.identity.rest.api.server.challenge.v1.dto.ChallengeQuestionDTO)3 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)3 Gson (com.google.gson.Gson)2 GsonBuilder (com.google.gson.GsonBuilder)2 Map (java.util.Map)2