Search in sources :

Example 1 with UPDATE_SECRET_VALUE

use of org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.UPDATE_SECRET_VALUE in project carbon-identity-framework by wso2.

the class SecretDAOImpl method updateSecretValue.

@Override
public Secret updateSecretValue(Secret secret, String value) throws SecretManagementException {
    Timestamp currentTime = new java.sql.Timestamp(new Date().getTime());
    NamedJdbcTemplate jdbcTemplate = getNewTemplate();
    try {
        jdbcTemplate.executeUpdate(UPDATE_SECRET_VALUE, preparedStatement -> {
            preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_ID, secret.getSecretId());
            preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_SECRET_VALUE, value);
            preparedStatement.setTimeStamp(DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED, currentTime, calendar);
        });
        secret.setLastModified(currentTime.toInstant().toString());
        secret.setSecretValue(value);
    } catch (DataAccessException e) {
        throw handleServerException(ERROR_CODE_UPDATE_SECRET, "value", e);
    }
    return secret;
}
Also used : NamedJdbcTemplate(org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate) Timestamp(java.sql.Timestamp) Date(java.util.Date) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Aggregations

Timestamp (java.sql.Timestamp)1 Date (java.util.Date)1 NamedJdbcTemplate (org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate)1 DataAccessException (org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)1