Search in sources :

Example 1 with ERROR_CODE_UPDATE_SECRET

use of org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_UPDATE_SECRET in project carbon-identity-framework by wso2.

the class SecretManagerImpl method updateSecretValue.

@Override
public Secret updateSecretValue(String secretTypeName, String name, String value) throws SecretManagementException {
    validateSecretManagerEnabled();
    Secret secret, updatedSecret;
    secret = getSecret(secretTypeName, name);
    try {
        updatedSecret = this.getSecretDAO().updateSecretValue(secret, encrypt(value));
    } catch (CryptoException e) {
        throw handleServerException(ERROR_CODE_UPDATE_SECRET, value, e);
    }
    if (log.isDebugEnabled()) {
        log.debug(secret.getSecretName() + " secret value updated successfully.");
    }
    return updatedSecret;
}
Also used : Secret(org.wso2.carbon.identity.secret.mgt.core.model.Secret) CryptoException(org.wso2.carbon.core.util.CryptoException)

Example 2 with ERROR_CODE_UPDATE_SECRET

use of org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_UPDATE_SECRET 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)

Example 3 with ERROR_CODE_UPDATE_SECRET

use of org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_UPDATE_SECRET in project carbon-identity-framework by wso2.

the class SecretDAOImpl method updateSecretDescription.

@Override
public Secret updateSecretDescription(Secret secret, String description) throws SecretManagementException {
    Timestamp currentTime = new java.sql.Timestamp(new Date().getTime());
    NamedJdbcTemplate jdbcTemplate = getNewTemplate();
    try {
        jdbcTemplate.executeUpdate(UPDATE_SECRET_DESCRIPTION, preparedStatement -> {
            preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_ID, secret.getSecretId());
            preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_DESCRIPTION, description);
            preparedStatement.setTimeStamp(DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED, currentTime, calendar);
        });
        secret.setLastModified(currentTime.toInstant().toString());
        secret.setDescription(description);
    } catch (DataAccessException e) {
        throw handleServerException(ERROR_CODE_UPDATE_SECRET, "description", 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)2 Date (java.util.Date)2 NamedJdbcTemplate (org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate)2 DataAccessException (org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)2 CryptoException (org.wso2.carbon.core.util.CryptoException)1 Secret (org.wso2.carbon.identity.secret.mgt.core.model.Secret)1