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