Skip to content

Commit

Permalink
#384 string ###-AUTH-USER-SIGN-### get translated to sign of logged i…
Browse files Browse the repository at this point in the history
…n user in sql statements of reports
  • Loading branch information
KlausRicharz committed Jul 19, 2024
1 parent 1d9dd93 commit a929a2b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/org/tb/reporting/service/ReportingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Service;
import org.tb.auth.AuthService;
import org.tb.auth.AuthorizedUser;
import org.tb.reporting.domain.ReportDefinition;
import org.tb.reporting.domain.ReportDefinition_;
import org.tb.reporting.domain.ReportResult;
Expand All @@ -34,6 +35,7 @@ public class ReportingService {
private final ReportDefinitionRepository reportDefinitionRepository;
private final DataSource dataSource;
private final AuthService authService;
private final AuthorizedUser authorizedUser;

public List<ReportDefinition> getReportDefinitions() {
return IteratorUtils.toList(
Expand Down Expand Up @@ -82,7 +84,9 @@ public ReportResult execute(Long reportDefinitionId, Map<String, Object> paramet
throw new IllegalArgumentException("No report definition found for " + reportDefinitionId);
}

final var rowset = new NamedParameterJdbcTemplate(dataSource).queryForRowSet(reportDefinition.get().getSql(), parameters);
String sql = reportDefinition.get().getSql();
sql = sql.replace("###-AUTH-USER-SIGN-###", authorizedUser.getSign()); // ensure the sign is filled in as requested
final var rowset = new NamedParameterJdbcTemplate(dataSource).queryForRowSet(sql, parameters);
var result = new ReportResult();

// get and create headers
Expand Down

0 comments on commit a929a2b

Please sign in to comment.