Search in sources :

Example 1 with DB_SCHEMA_COLUMN_NAME_SECRET_NAME

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

the class SecretDAOImpl method isExistingSecret.

@Override
public boolean isExistingSecret(String secretId, int tenantId) throws SecretManagementException {
    NamedJdbcTemplate jdbcTemplate = getNewTemplate();
    String secretName;
    try {
        secretName = jdbcTemplate.fetchSingleRecord(GET_SECRET_NAME_BY_ID, (resultSet, rowNumber) -> resultSet.getString(DB_SCHEMA_COLUMN_NAME_SECRET_NAME), preparedStatement -> {
            preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_ID, secretId);
            preparedStatement.setInt(DB_SCHEMA_COLUMN_NAME_TENANT_ID, tenantId);
        });
        return StringUtils.isNotEmpty(secretName);
    } catch (DataAccessException e) {
        throw handleServerException(ERROR_CODE_GET_SECRET, "id = " + secretId, e);
    }
}
Also used : DB_SCHEMA_COLUMN_NAME_CREATED_TIME(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_CREATED_TIME) DB_SCHEMA_COLUMN_NAME_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_TYPE) StringUtils(org.apache.commons.lang.StringUtils) GET_SECRET_BY_ID(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRET_BY_ID) IdentityDatabaseUtil(org.wso2.carbon.identity.core.util.IdentityDatabaseUtil) UPDATE_SECRET_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.UPDATE_SECRET_TYPE) Date(java.util.Date) GET_SECRET_BY_NAME(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRET_BY_NAME) DB_SCHEMA_COLUMN_NAME_SECRET_NAME(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_SECRET_NAME) SecretUtils.handleServerException(org.wso2.carbon.identity.secret.mgt.core.util.SecretUtils.handleServerException) ERROR_CODE_ADD_SECRET_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_ADD_SECRET_TYPE) UPDATE_SECRET_DESCRIPTION(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.UPDATE_SECRET_DESCRIPTION) ERROR_CODE_UPDATE_SECRET_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_UPDATE_SECRET_TYPE) ERROR_CODE_SECRETS_DOES_NOT_EXISTS(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_SECRETS_DOES_NOT_EXISTS) ERROR_CODE_DELETE_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_DELETE_SECRET) SecretType(org.wso2.carbon.identity.secret.mgt.core.model.SecretType) LambdaExceptionUtils(org.wso2.carbon.identity.core.util.LambdaExceptionUtils) TimeZone(java.util.TimeZone) Timestamp(java.sql.Timestamp) GET_SECRET_NAME_BY_ID(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRET_NAME_BY_ID) UPDATE_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.UPDATE_SECRET) Secret(org.wso2.carbon.identity.secret.mgt.core.model.Secret) DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED) List(java.util.List) ERROR_CODE_UPDATE_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_UPDATE_SECRET) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException) UTC(java.time.ZoneOffset.UTC) LogFactory(org.apache.commons.logging.LogFactory) ERROR_CODE_GET_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_GET_SECRET) SecretManagementException(org.wso2.carbon.identity.secret.mgt.core.exception.SecretManagementException) INSERT_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.INSERT_SECRET) PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext) SQLIntegrityConstraintViolationException(java.sql.SQLIntegrityConstraintViolationException) NamedJdbcTemplate(org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate) DB_SCHEMA_COLUMN_NAME_SECRET_VALUE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_SECRET_VALUE) GET_SECRET_TYPE_BY_NAME(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRET_TYPE_BY_NAME) Calendar(java.util.Calendar) DB_SCHEMA_COLUMN_NAME_NAME(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_NAME) SQLConstants(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants) SecretDAO(org.wso2.carbon.identity.secret.mgt.core.dao.SecretDAO) GET_SECRETS(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRETS) TransactionException(org.wso2.carbon.database.utils.jdbc.exceptions.TransactionException) IdentityTenantUtil(org.wso2.carbon.identity.core.util.IdentityTenantUtil) ERROR_CODE_ADD_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_ADD_SECRET) CryptoException(org.wso2.carbon.core.util.CryptoException) ERROR_CODE_SECRET_ALREADY_EXISTS(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_SECRET_ALREADY_EXISTS) ERROR_CODE_REPLACE_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_REPLACE_SECRET) GET_SECRET_CREATED_TIME_BY_NAME(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRET_CREATED_TIME_BY_NAME) NamedTemplate(org.wso2.carbon.database.utils.jdbc.NamedTemplate) UPDATE_SECRET_VALUE(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.UPDATE_SECRET_VALUE) ERROR_CODE_DELETE_SECRET_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_DELETE_SECRET_TYPE) SecretUtils.handleClientException(org.wso2.carbon.identity.secret.mgt.core.util.SecretUtils.handleClientException) DB_SCHEMA_COLUMN_NAME_ID(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_ID) DB_SCHEMA_COLUMN_NAME_TENANT_ID(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_TENANT_ID) Log(org.apache.commons.logging.Log) DB_SCHEMA_COLUMN_NAME_DESCRIPTION(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_DESCRIPTION) ERROR_CODE_RETRIEVE_SECRET_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_RETRIEVE_SECRET_TYPE) NamedJdbcTemplate(org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Example 2 with DB_SCHEMA_COLUMN_NAME_SECRET_NAME

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

the class SecretDAOImpl method getSecretByName.

@Override
public Secret getSecretByName(String name, SecretType secretType, int tenantId) throws SecretManagementException {
    NamedJdbcTemplate jdbcTemplate = getNewTemplate();
    List<SecretRawDataCollector> secretRawDataCollectors;
    try {
        String query = GET_SECRET_BY_NAME;
        secretRawDataCollectors = jdbcTemplate.executeQuery(query, (resultSet, rowNumber) -> {
            SecretRawDataCollector.SecretRawDataCollectorBuilder secretRawDataCollectorBuilder = new SecretRawDataCollector.SecretRawDataCollectorBuilder().setSecretId(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID)).setTenantId(resultSet.getInt(DB_SCHEMA_COLUMN_NAME_TENANT_ID)).setSecretName(resultSet.getString(DB_SCHEMA_COLUMN_NAME_SECRET_NAME)).setSecretValue(resultSet.getString(DB_SCHEMA_COLUMN_NAME_SECRET_VALUE)).setLastModified(resultSet.getTimestamp(DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED, calendar)).setCreatedTime(resultSet.getTimestamp(DB_SCHEMA_COLUMN_NAME_CREATED_TIME, calendar)).setDescription(resultSet.getString(DB_SCHEMA_COLUMN_NAME_DESCRIPTION)).setSecretType(secretType.getName());
            return secretRawDataCollectorBuilder.build();
        }, preparedStatement -> {
            preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_SECRET_NAME, name);
            preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_TYPE, secretType.getId());
            preparedStatement.setInt(DB_SCHEMA_COLUMN_NAME_TENANT_ID, tenantId);
        });
        return secretRawDataCollectors == null || secretRawDataCollectors.size() == 0 ? null : buildSecretFromRawData(secretRawDataCollectors);
    } catch (DataAccessException | CryptoException e) {
        throw handleServerException(ERROR_CODE_GET_SECRET, name, e);
    }
}
Also used : DB_SCHEMA_COLUMN_NAME_CREATED_TIME(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_CREATED_TIME) DB_SCHEMA_COLUMN_NAME_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_TYPE) StringUtils(org.apache.commons.lang.StringUtils) GET_SECRET_BY_ID(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRET_BY_ID) IdentityDatabaseUtil(org.wso2.carbon.identity.core.util.IdentityDatabaseUtil) UPDATE_SECRET_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.UPDATE_SECRET_TYPE) Date(java.util.Date) GET_SECRET_BY_NAME(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRET_BY_NAME) DB_SCHEMA_COLUMN_NAME_SECRET_NAME(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_SECRET_NAME) SecretUtils.handleServerException(org.wso2.carbon.identity.secret.mgt.core.util.SecretUtils.handleServerException) ERROR_CODE_ADD_SECRET_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_ADD_SECRET_TYPE) UPDATE_SECRET_DESCRIPTION(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.UPDATE_SECRET_DESCRIPTION) ERROR_CODE_UPDATE_SECRET_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_UPDATE_SECRET_TYPE) ERROR_CODE_SECRETS_DOES_NOT_EXISTS(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_SECRETS_DOES_NOT_EXISTS) ERROR_CODE_DELETE_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_DELETE_SECRET) SecretType(org.wso2.carbon.identity.secret.mgt.core.model.SecretType) LambdaExceptionUtils(org.wso2.carbon.identity.core.util.LambdaExceptionUtils) TimeZone(java.util.TimeZone) Timestamp(java.sql.Timestamp) GET_SECRET_NAME_BY_ID(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRET_NAME_BY_ID) UPDATE_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.UPDATE_SECRET) Secret(org.wso2.carbon.identity.secret.mgt.core.model.Secret) DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED) List(java.util.List) ERROR_CODE_UPDATE_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_UPDATE_SECRET) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException) UTC(java.time.ZoneOffset.UTC) LogFactory(org.apache.commons.logging.LogFactory) ERROR_CODE_GET_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_GET_SECRET) SecretManagementException(org.wso2.carbon.identity.secret.mgt.core.exception.SecretManagementException) INSERT_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.INSERT_SECRET) PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext) SQLIntegrityConstraintViolationException(java.sql.SQLIntegrityConstraintViolationException) NamedJdbcTemplate(org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate) DB_SCHEMA_COLUMN_NAME_SECRET_VALUE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_SECRET_VALUE) GET_SECRET_TYPE_BY_NAME(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRET_TYPE_BY_NAME) Calendar(java.util.Calendar) DB_SCHEMA_COLUMN_NAME_NAME(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_NAME) SQLConstants(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants) SecretDAO(org.wso2.carbon.identity.secret.mgt.core.dao.SecretDAO) GET_SECRETS(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRETS) TransactionException(org.wso2.carbon.database.utils.jdbc.exceptions.TransactionException) IdentityTenantUtil(org.wso2.carbon.identity.core.util.IdentityTenantUtil) ERROR_CODE_ADD_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_ADD_SECRET) CryptoException(org.wso2.carbon.core.util.CryptoException) ERROR_CODE_SECRET_ALREADY_EXISTS(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_SECRET_ALREADY_EXISTS) ERROR_CODE_REPLACE_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_REPLACE_SECRET) GET_SECRET_CREATED_TIME_BY_NAME(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRET_CREATED_TIME_BY_NAME) NamedTemplate(org.wso2.carbon.database.utils.jdbc.NamedTemplate) UPDATE_SECRET_VALUE(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.UPDATE_SECRET_VALUE) ERROR_CODE_DELETE_SECRET_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_DELETE_SECRET_TYPE) SecretUtils.handleClientException(org.wso2.carbon.identity.secret.mgt.core.util.SecretUtils.handleClientException) DB_SCHEMA_COLUMN_NAME_ID(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_ID) DB_SCHEMA_COLUMN_NAME_TENANT_ID(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_TENANT_ID) Log(org.apache.commons.logging.Log) DB_SCHEMA_COLUMN_NAME_DESCRIPTION(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_DESCRIPTION) ERROR_CODE_RETRIEVE_SECRET_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_RETRIEVE_SECRET_TYPE) NamedJdbcTemplate(org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate) CryptoException(org.wso2.carbon.core.util.CryptoException) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Example 3 with DB_SCHEMA_COLUMN_NAME_SECRET_NAME

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

the class SecretDAOImpl method getSecrets.

@Override
public List getSecrets(SecretType secretType, int tenantId) throws SecretManagementException {
    NamedJdbcTemplate jdbcTemplate = getNewTemplate();
    try {
        return jdbcTemplate.executeQuery(GET_SECRETS, (LambdaExceptionUtils.rethrowRowMapper((resultSet, rowNumber) -> {
            String secretId = resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID);
            String secretName = resultSet.getString(DB_SCHEMA_COLUMN_NAME_SECRET_NAME);
            String secretLastModified = resultSet.getString(DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED);
            String secretCreatedTime = resultSet.getString(DB_SCHEMA_COLUMN_NAME_CREATED_TIME);
            String description = resultSet.getString(DB_SCHEMA_COLUMN_NAME_DESCRIPTION);
            Secret secret = new Secret();
            secret.setCreatedTime(secretCreatedTime);
            secret.setSecretId(secretId);
            secret.setSecretName(secretName);
            secret.setLastModified(secretLastModified);
            secret.setTenantDomain(IdentityTenantUtil.getTenantDomain(tenantId));
            secret.setSecretType(secretType.getName());
            secret.setDescription(description);
            return secret;
        })), preparedStatement -> {
            preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_TYPE, secretType.getId());
            preparedStatement.setInt(DB_SCHEMA_COLUMN_NAME_TENANT_ID, tenantId);
        });
    } catch (DataAccessException e) {
        throw handleServerException(ERROR_CODE_SECRETS_DOES_NOT_EXISTS, e);
    }
}
Also used : Secret(org.wso2.carbon.identity.secret.mgt.core.model.Secret) NamedJdbcTemplate(org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Example 4 with DB_SCHEMA_COLUMN_NAME_SECRET_NAME

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

the class SecretDAOImpl method getSecretById.

@Override
public Secret getSecretById(String secretId, int tenantId) throws SecretManagementException {
    NamedJdbcTemplate jdbcTemplate = getNewTemplate();
    List<SecretRawDataCollector> secretRawDataCollectors;
    try {
        String query = GET_SECRET_BY_ID;
        secretRawDataCollectors = jdbcTemplate.executeQuery(query, (resultSet, rowNumber) -> {
            SecretRawDataCollector.SecretRawDataCollectorBuilder secretRawDataCollectorBuilder = new SecretRawDataCollector.SecretRawDataCollectorBuilder().setSecretId(resultSet.getString(DB_SCHEMA_COLUMN_NAME_ID)).setTenantId(resultSet.getInt(DB_SCHEMA_COLUMN_NAME_TENANT_ID)).setSecretName(resultSet.getString(DB_SCHEMA_COLUMN_NAME_SECRET_NAME)).setSecretValue(resultSet.getString(DB_SCHEMA_COLUMN_NAME_SECRET_VALUE)).setLastModified(resultSet.getTimestamp(DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED, calendar)).setCreatedTime(resultSet.getTimestamp(DB_SCHEMA_COLUMN_NAME_CREATED_TIME, calendar)).setSecretType(resultSet.getString(DB_SCHEMA_COLUMN_NAME_NAME)).setDescription(resultSet.getString(DB_SCHEMA_COLUMN_NAME_DESCRIPTION));
            return secretRawDataCollectorBuilder.build();
        }, preparedStatement -> {
            preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_ID, secretId);
            preparedStatement.setInt(DB_SCHEMA_COLUMN_NAME_TENANT_ID, tenantId);
        });
        return secretRawDataCollectors == null || secretRawDataCollectors.size() == 0 ? null : buildSecretFromRawData(secretRawDataCollectors);
    } catch (DataAccessException | CryptoException e) {
        throw handleServerException(ERROR_CODE_GET_SECRET, "id = " + secretId, e);
    }
}
Also used : DB_SCHEMA_COLUMN_NAME_CREATED_TIME(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_CREATED_TIME) DB_SCHEMA_COLUMN_NAME_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_TYPE) StringUtils(org.apache.commons.lang.StringUtils) GET_SECRET_BY_ID(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRET_BY_ID) IdentityDatabaseUtil(org.wso2.carbon.identity.core.util.IdentityDatabaseUtil) UPDATE_SECRET_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.UPDATE_SECRET_TYPE) Date(java.util.Date) GET_SECRET_BY_NAME(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRET_BY_NAME) DB_SCHEMA_COLUMN_NAME_SECRET_NAME(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_SECRET_NAME) SecretUtils.handleServerException(org.wso2.carbon.identity.secret.mgt.core.util.SecretUtils.handleServerException) ERROR_CODE_ADD_SECRET_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_ADD_SECRET_TYPE) UPDATE_SECRET_DESCRIPTION(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.UPDATE_SECRET_DESCRIPTION) ERROR_CODE_UPDATE_SECRET_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_UPDATE_SECRET_TYPE) ERROR_CODE_SECRETS_DOES_NOT_EXISTS(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_SECRETS_DOES_NOT_EXISTS) ERROR_CODE_DELETE_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_DELETE_SECRET) SecretType(org.wso2.carbon.identity.secret.mgt.core.model.SecretType) LambdaExceptionUtils(org.wso2.carbon.identity.core.util.LambdaExceptionUtils) TimeZone(java.util.TimeZone) Timestamp(java.sql.Timestamp) GET_SECRET_NAME_BY_ID(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRET_NAME_BY_ID) UPDATE_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.UPDATE_SECRET) Secret(org.wso2.carbon.identity.secret.mgt.core.model.Secret) DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_LAST_MODIFIED) List(java.util.List) ERROR_CODE_UPDATE_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_UPDATE_SECRET) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException) UTC(java.time.ZoneOffset.UTC) LogFactory(org.apache.commons.logging.LogFactory) ERROR_CODE_GET_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_GET_SECRET) SecretManagementException(org.wso2.carbon.identity.secret.mgt.core.exception.SecretManagementException) INSERT_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.INSERT_SECRET) PrivilegedCarbonContext(org.wso2.carbon.context.PrivilegedCarbonContext) SQLIntegrityConstraintViolationException(java.sql.SQLIntegrityConstraintViolationException) NamedJdbcTemplate(org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate) DB_SCHEMA_COLUMN_NAME_SECRET_VALUE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_SECRET_VALUE) GET_SECRET_TYPE_BY_NAME(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRET_TYPE_BY_NAME) Calendar(java.util.Calendar) DB_SCHEMA_COLUMN_NAME_NAME(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_NAME) SQLConstants(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants) SecretDAO(org.wso2.carbon.identity.secret.mgt.core.dao.SecretDAO) GET_SECRETS(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRETS) TransactionException(org.wso2.carbon.database.utils.jdbc.exceptions.TransactionException) IdentityTenantUtil(org.wso2.carbon.identity.core.util.IdentityTenantUtil) ERROR_CODE_ADD_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_ADD_SECRET) CryptoException(org.wso2.carbon.core.util.CryptoException) ERROR_CODE_SECRET_ALREADY_EXISTS(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_SECRET_ALREADY_EXISTS) ERROR_CODE_REPLACE_SECRET(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_REPLACE_SECRET) GET_SECRET_CREATED_TIME_BY_NAME(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.GET_SECRET_CREATED_TIME_BY_NAME) NamedTemplate(org.wso2.carbon.database.utils.jdbc.NamedTemplate) UPDATE_SECRET_VALUE(org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants.UPDATE_SECRET_VALUE) ERROR_CODE_DELETE_SECRET_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_DELETE_SECRET_TYPE) SecretUtils.handleClientException(org.wso2.carbon.identity.secret.mgt.core.util.SecretUtils.handleClientException) DB_SCHEMA_COLUMN_NAME_ID(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_ID) DB_SCHEMA_COLUMN_NAME_TENANT_ID(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_TENANT_ID) Log(org.apache.commons.logging.Log) DB_SCHEMA_COLUMN_NAME_DESCRIPTION(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.DB_SCHEMA_COLUMN_NAME_DESCRIPTION) ERROR_CODE_RETRIEVE_SECRET_TYPE(org.wso2.carbon.identity.secret.mgt.core.constant.SecretConstants.ErrorMessages.ERROR_CODE_RETRIEVE_SECRET_TYPE) NamedJdbcTemplate(org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate) CryptoException(org.wso2.carbon.core.util.CryptoException) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Example 5 with DB_SCHEMA_COLUMN_NAME_SECRET_NAME

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

the class SecretDAOImpl method deleteSecretByName.

@Override
public void deleteSecretByName(String name, String secretTypeId, int tenantId) throws SecretManagementException {
    NamedJdbcTemplate jdbcTemplate = getNewTemplate();
    try {
        jdbcTemplate.executeUpdate(SQLConstants.DELETE_SECRET, preparedStatement -> {
            preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_SECRET_NAME, name);
            preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_TYPE, secretTypeId);
            preparedStatement.setInt(DB_SCHEMA_COLUMN_NAME_TENANT_ID, tenantId);
        });
    } catch (DataAccessException e) {
        throw handleServerException(ERROR_CODE_DELETE_SECRET, e);
    }
}
Also used : NamedJdbcTemplate(org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Aggregations

NamedJdbcTemplate (org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate)6 DataAccessException (org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)5 Timestamp (java.sql.Timestamp)4 Date (java.util.Date)4 TransactionException (org.wso2.carbon.database.utils.jdbc.exceptions.TransactionException)4 SQLIntegrityConstraintViolationException (java.sql.SQLIntegrityConstraintViolationException)3 UTC (java.time.ZoneOffset.UTC)3 Calendar (java.util.Calendar)3 List (java.util.List)3 TimeZone (java.util.TimeZone)3 StringUtils (org.apache.commons.lang.StringUtils)3 Log (org.apache.commons.logging.Log)3 LogFactory (org.apache.commons.logging.LogFactory)3 PrivilegedCarbonContext (org.wso2.carbon.context.PrivilegedCarbonContext)3 CryptoException (org.wso2.carbon.core.util.CryptoException)3 NamedTemplate (org.wso2.carbon.database.utils.jdbc.NamedTemplate)3 IdentityDatabaseUtil (org.wso2.carbon.identity.core.util.IdentityDatabaseUtil)3 IdentityTenantUtil (org.wso2.carbon.identity.core.util.IdentityTenantUtil)3 LambdaExceptionUtils (org.wso2.carbon.identity.core.util.LambdaExceptionUtils)3 SQLConstants (org.wso2.carbon.identity.secret.mgt.core.constant.SQLConstants)3