Search in sources :

Example 1 with GET_SECRETS

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

Aggregations

NamedJdbcTemplate (org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate)1 DataAccessException (org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)1 Secret (org.wso2.carbon.identity.secret.mgt.core.model.Secret)1