mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-16 07:10:48 +00:00
Bug 4914: added permission check for Export-as-XML functionality in
Leaderboards in Backend in XmlExportServlet. Check leaderboard:read and filter by trackedrace:read
This commit is contained in:
1 parent
a6868a7679
commit
78383c64f4
4 files changed
+13
-2
No files matched your search
@@ -19,7 +19,8 @@ Require-Bundle: com.sap.sailing.server,
|
||||
com.sap.sse.replication,
|
||||
org.jdom;bundle-version="1.1.1",
|
||||
com.sap.sailing.server.interface,
|
||||
com.sap.sse.security
|
||||
com.sap.sse.security,
|
||||
org.apache.shiro.core
|
||||
Bundle-ClassPath: .
|
||||
Web-ContextPath: /export
|
||||
Automatic-Module-Name: com.sap.sailing.xmlexport
|
||||
@@ -45,7 +45,7 @@ public abstract class ExportAction {
|
||||
private Leaderboard leaderboard;
|
||||
protected final boolean useProvidedLeaderboard;
|
||||
private String resultingXMLData;
|
||||
private final SecurityService securityService;
|
||||
protected final SecurityService securityService;
|
||||
|
||||
public ExportAction(HttpServletRequest req, HttpServletResponse res, RacingEventService service,
|
||||
final SecurityService securityService) {
|
||||
|
||||
@@ -1033,6 +1033,7 @@ public class LeaderboardData extends ExportAction {
|
||||
|
||||
public void perform() throws Exception {
|
||||
final Leaderboard leaderboard = getLeaderboard();
|
||||
securityService.checkCurrentUserReadPermission(leaderboard);
|
||||
TimePoint timeSpent = MillisecondsTimePoint.now();
|
||||
log.info("Starting XML export of " + leaderboard.getName());
|
||||
Util.Pair<Double, Vector<String>> leaderboardConfidenceAndErrorMessages = checkData(leaderboard);
|
||||
@@ -1052,6 +1053,9 @@ public class LeaderboardData extends ExportAction {
|
||||
for (Fleet fleet : raceColumn.getFleets()) {
|
||||
TrackedRace trackedRace = raceColumn.getTrackedRace(fleet);
|
||||
if (trackedRace != null) {
|
||||
if (!securityService.hasCurrentUserReadPermission(trackedRace)) {
|
||||
continue;
|
||||
}
|
||||
sameDayGroupIndex += getSameDayGroupIndex(raceColumn.getTrackedRace(fleet), raceBefore);
|
||||
}
|
||||
TimePoint timeSpentForRace = MillisecondsTimePoint.now();
|
||||
|
||||
@@ -6,6 +6,8 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.UnauthorizedException;
|
||||
|
||||
import com.sap.sailing.server.gateway.SailingServerHttpServlet;
|
||||
|
||||
public class XmlExportServlet extends SailingServerHttpServlet {
|
||||
@@ -19,7 +21,11 @@ public class XmlExportServlet extends SailingServerHttpServlet {
|
||||
if ("leaderboard".equalsIgnoreCase(action)) {
|
||||
final LeaderboardData leaderboardData = new LeaderboardData(req, res, getService(),
|
||||
getSecurityService());
|
||||
try {
|
||||
leaderboardData.perform();
|
||||
} catch (UnauthorizedException e) {
|
||||
res.sendError(HttpServletResponse.SC_UNAUTHORIZED, e.getMessage());
|
||||
}
|
||||
return;
|
||||
} else if ("foiling".equalsIgnoreCase(action)) {
|
||||
final FoilingData foilingData = new FoilingData(req, res, getService(), getSecurityService());
|
||||
|
||||
Reference in new issue
Block a user