use of org.wso2.carbon.identity.mgt.dto.UserRecoveryDataDO 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);
}
use of org.wso2.carbon.identity.mgt.dto.UserRecoveryDataDO 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);
}
use of org.wso2.carbon.identity.mgt.dto.UserRecoveryDataDO in project carbon-identity-framework by wso2.
the class UserIdentityManagementUtil method removePrimaryQuestions.
/**
* Remove primary security questions
*
* @param tenantId
* @throws IdentityException
*/
public static void removePrimaryQuestions(String[] primarySecurityQuestion, int tenantId) throws IdentityException {
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);
}
}
use of org.wso2.carbon.identity.mgt.dto.UserRecoveryDataDO 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);
}
use of org.wso2.carbon.identity.mgt.dto.UserRecoveryDataDO in project carbon-identity-framework by wso2.
the class JDBCUserRecoveryDataStore method store.
/**
* Stores identity data set.
*
* @throws IdentityException
*/
@Override
@Deprecated
public void store(UserRecoveryDataDO[] recoveryDataDOs) throws IdentityException {
Connection connection = IdentityDatabaseUtil.getDBConnection();
PreparedStatement prepStmt = null;
try {
prepStmt = connection.prepareStatement(SQLQuery.STORE_META_DATA);
for (UserRecoveryDataDO dataDO : recoveryDataDOs) {
prepStmt.setString(1, dataDO.getUserName().toLowerCase());
prepStmt.setInt(2, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
prepStmt.setString(3, dataDO.getCode().toLowerCase());
prepStmt.setString(4, dataDO.getSecret());
prepStmt.setString(5, dataDO.getExpireTime());
prepStmt.addBatch();
}
prepStmt.executeBatch();
IdentityDatabaseUtil.commitTransaction(connection);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(connection);
throw IdentityException.error("Error while storing user identity data", e);
} finally {
IdentityDatabaseUtil.closeStatement(prepStmt);
IdentityDatabaseUtil.closeConnection(connection);
}
}
Aggregations