Search in sources :

Example 1 with JDBCUserRecoveryDataStore

use of org.wso2.carbon.identity.mgt.store.JDBCUserRecoveryDataStore in project carbon-identity-framework by wso2.

the class UserIdentityManagementUtil method invalidateUserIdentityMetadata.

/**
 * Invalidates the identity metadata
 *
 * @param userName
 * @param tenantId
 * @param metadataType
 * @param metadata
 * @throws IdentityException
 */
public static void invalidateUserIdentityMetadata(String userName, int tenantId, String metadataType, String metadata) throws IdentityException {
    JDBCUserRecoveryDataStore store = new JDBCUserRecoveryDataStore();
    UserRecoveryDataDO metadataDO = new UserRecoveryDataDO(userName, tenantId, metadataType, metadata);
    store.invalidate(metadataDO);
}
Also used : UserRecoveryDataDO(org.wso2.carbon.identity.mgt.dto.UserRecoveryDataDO) JDBCUserRecoveryDataStore(org.wso2.carbon.identity.mgt.store.JDBCUserRecoveryDataStore)

Example 2 with JDBCUserRecoveryDataStore

use of org.wso2.carbon.identity.mgt.store.JDBCUserRecoveryDataStore in project carbon-identity-framework by wso2.

the class UserIdentityManagementUtil method getPrimaryQuestions.

/**
 * Returns an array of primary security questions
 *
 * @param tenantId
 * @return
 * @throws IdentityException
 */
public static String[] getPrimaryQuestions(int tenantId) throws IdentityException {
    JDBCUserRecoveryDataStore store = new JDBCUserRecoveryDataStore();
    UserRecoveryDataDO[] metadata = store.load("TENANT", tenantId);
    if (metadata.length < 1) {
        return new String[0];
    }
    List<String> validSecurityQuestions = new ArrayList<String>();
    String[] questionsList = new String[validSecurityQuestions.size()];
    return validSecurityQuestions.toArray(questionsList);
}
Also used : UserRecoveryDataDO(org.wso2.carbon.identity.mgt.dto.UserRecoveryDataDO) JDBCUserRecoveryDataStore(org.wso2.carbon.identity.mgt.store.JDBCUserRecoveryDataStore) ArrayList(java.util.ArrayList)

Example 3 with JDBCUserRecoveryDataStore

use of org.wso2.carbon.identity.mgt.store.JDBCUserRecoveryDataStore in project carbon-identity-framework by wso2.

the class UserIdentityManagementUtil method storeUserIdentityMetadata.

/**
 * Stores new metadata
 *
 * @param metadata
 * @throws IdentityException
 */
public static void storeUserIdentityMetadata(UserRecoveryDataDO metadata) throws IdentityException {
    JDBCUserRecoveryDataStore store = new JDBCUserRecoveryDataStore();
    metadata.setValid(true);
    store.store(metadata);
}
Also used : JDBCUserRecoveryDataStore(org.wso2.carbon.identity.mgt.store.JDBCUserRecoveryDataStore)

Example 4 with JDBCUserRecoveryDataStore

use of org.wso2.carbon.identity.mgt.store.JDBCUserRecoveryDataStore in project carbon-identity-framework by wso2.

the class UserIdentityManagementUtil method addPrimaryQuestions.

/**
 * Add or update primary security questions
 *
 * @param primarySecurityQuestion
 * @param tenantId
 * @throws IdentityException
 */
public static void addPrimaryQuestions(String[] primarySecurityQuestion, int tenantId) throws IdentityException {
    JDBCUserRecoveryDataStore store = new JDBCUserRecoveryDataStore();
    UserRecoveryDataDO[] metadata = new UserRecoveryDataDO[primarySecurityQuestion.length];
    int i = 0;
    for (String secQuestion : primarySecurityQuestion) {
        if (!secQuestion.contains(UserCoreConstants.ClaimTypeURIs.CHALLENGE_QUESTION_URI)) {
            throw IdentityException.error("One or more security questions does not contain the namespace " + UserCoreConstants.ClaimTypeURIs.CHALLENGE_QUESTION_URI);
        }
        metadata[i++] = new UserRecoveryDataDO("TENANT", tenantId, UserRecoveryDataDO.METADATA_PRIMARAY_SECURITY_QUESTION, secQuestion);
    }
    store.store(metadata);
}
Also used : UserRecoveryDataDO(org.wso2.carbon.identity.mgt.dto.UserRecoveryDataDO) JDBCUserRecoveryDataStore(org.wso2.carbon.identity.mgt.store.JDBCUserRecoveryDataStore)

Aggregations

JDBCUserRecoveryDataStore (org.wso2.carbon.identity.mgt.store.JDBCUserRecoveryDataStore)4 UserRecoveryDataDO (org.wso2.carbon.identity.mgt.dto.UserRecoveryDataDO)3 ArrayList (java.util.ArrayList)1