Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving Role Authentication #125

Open
wants to merge 1 commit into
base: keycloak-refactor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public String getCurrentTime() {

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/assessments/connection_of_travel", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and (@PermissionService.hasRole('USER') || @PermissionService.hasRole('ADMIN')))")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and @PermissionService.hasRole('USER'))")
public ResponseEntity<List<ConnectionOfTravelAssessment>> findConnectionOfTravelAssessment(
@RequestParam(name = "road_regulator_id", required = false) Integer roadRegulatorID,
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
Expand All @@ -72,16 +72,15 @@ public ResponseEntity<List<ConnectionOfTravelAssessment>> findConnectionOfTravel
} else {
Query query = connectionOfTravelAssessmentRepo.getQuery(intersectionID, startTime, endTime, latest);
long count = connectionOfTravelAssessmentRepo.getQueryResultCount(query);



logger.info("Returning ProcessedMap Response with Size: " + count);
return ResponseEntity.ok(connectionOfTravelAssessmentRepo.find(query));
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/assessments/connection_of_travel/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and (@PermissionService.hasRole('USER') || @PermissionService.hasRole('ADMIN')))")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and @PermissionService.hasRole('USER'))")
public ResponseEntity<Long> countConnectionOfTravelAssessment(
@RequestParam(name = "road_regulator_id", required = false) Integer roadRegulatorID,
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
Expand All @@ -96,20 +95,20 @@ public ResponseEntity<Long> countConnectionOfTravelAssessment(
Query query = connectionOfTravelAssessmentRepo.getQuery(intersectionID, startTime, endTime, false);

long count = 0;
if(fullCount){
if (fullCount) {
count = connectionOfTravelAssessmentRepo.getQueryFullCount(query);
}else{
} else {
count = connectionOfTravelAssessmentRepo.getQueryResultCount(query);
}

logger.info("Found: " + count + " Connection of Travel Assessments");
return ResponseEntity.ok(count);
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/assessments/lane_direction_of_travel", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and (@PermissionService.hasRole('USER') || @PermissionService.hasRole('ADMIN')))")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and @PermissionService.hasRole('USER'))")
public ResponseEntity<List<LaneDirectionOfTravelAssessment>> findLaneDirectionOfTravelAssessment(
@RequestParam(name = "road_regulator_id", required = false) Integer roadRegulatorID,
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
Expand All @@ -133,7 +132,7 @@ public ResponseEntity<List<LaneDirectionOfTravelAssessment>> findLaneDirectionOf

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/assessments/lane_direction_of_travel/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and (@PermissionService.hasRole('USER') || @PermissionService.hasRole('ADMIN')))")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and @PermissionService.hasRole('USER'))")
public ResponseEntity<Long> countLaneDirectionOfTravelAssessment(
@RequestParam(name = "road_regulator_id", required = false) Integer roadRegulatorID,
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
Expand All @@ -148,9 +147,9 @@ public ResponseEntity<Long> countLaneDirectionOfTravelAssessment(
Query query = laneDirectionOfTravelAssessmentRepo.getQuery(intersectionID, startTime, endTime, false);

long count = 0;
if(fullCount){
if (fullCount) {
count = laneDirectionOfTravelAssessmentRepo.getQueryFullCount(query);
}else{
} else {
count = laneDirectionOfTravelAssessmentRepo.getQueryResultCount(query);
}

Expand All @@ -162,7 +161,7 @@ public ResponseEntity<Long> countLaneDirectionOfTravelAssessment(

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/assessments/signal_state_assessment", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and (@PermissionService.hasRole('USER') || @PermissionService.hasRole('ADMIN')))")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and @PermissionService.hasRole('USER'))")
public ResponseEntity<List<StopLineStopAssessment>> findSignalStateAssessment(
@RequestParam(name = "road_regulator_id", required = false) Integer roadRegulatorID,
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
Expand All @@ -176,7 +175,7 @@ public ResponseEntity<List<StopLineStopAssessment>> findSignalStateAssessment(
list.add(MockAssessmentGenerator.getStopLineStopAssessment());
return ResponseEntity.ok(list);
} else {

Query query = stopLineStopAssessmentRepo.getQuery(intersectionID, startTime, endTime, latest);
long count = stopLineStopAssessmentRepo.getQueryResultCount(query);
logger.info("Returning SignalStateAssessment Response with Size: " + count);
Expand All @@ -186,7 +185,7 @@ public ResponseEntity<List<StopLineStopAssessment>> findSignalStateAssessment(

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/assessments/signal_state_assessment/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and (@PermissionService.hasRole('USER') || @PermissionService.hasRole('ADMIN')))")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and @PermissionService.hasRole('USER'))")
public ResponseEntity<Long> countSignalStateAssessment(
@RequestParam(name = "road_regulator_id", required = false) Integer roadRegulatorID,
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
Expand All @@ -198,25 +197,24 @@ public ResponseEntity<Long> countSignalStateAssessment(
if (testData) {
return ResponseEntity.ok(1L);
} else {

Query query = stopLineStopAssessmentRepo.getQuery(intersectionID, startTime, endTime, false);

long count = 0;
if(fullCount){
if (fullCount) {
count = stopLineStopAssessmentRepo.getQueryFullCount(query);
}else{
} else {
count = stopLineStopAssessmentRepo.getQueryResultCount(query);
}


logger.info("Found: " + count + " Lane Direction of Travel Assessments");
return ResponseEntity.ok(count);
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/assessments/signal_state_event_assessment", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and (@PermissionService.hasRole('USER') || @PermissionService.hasRole('ADMIN')))")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and @PermissionService.hasRole('USER'))")
public ResponseEntity<List<StopLinePassageAssessment>> findSignalStateEventAssessment(
@RequestParam(name = "road_regulator_id", required = false) Integer roadRegulatorID,
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
Expand All @@ -239,7 +237,7 @@ public ResponseEntity<List<StopLinePassageAssessment>> findSignalStateEventAsses

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/assessments/signal_state_event_assessment/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and (@PermissionService.hasRole('USER') || @PermissionService.hasRole('ADMIN')))")
@PreAuthorize("@PermissionService.isSuperUser() || (@PermissionService.hasIntersection(#intersectionID) and @PermissionService.hasRole('USER'))")
public ResponseEntity<Long> countSignalStateEventAssessment(
@RequestParam(name = "road_regulator_id", required = false) Integer roadRegulatorID,
@RequestParam(name = "intersection_id", required = false) Integer intersectionID,
Expand All @@ -253,9 +251,9 @@ public ResponseEntity<Long> countSignalStateEventAssessment(
} else {
Query query = signalStateEventAssessmentRepo.getQuery(intersectionID, startTime, endTime, false);
long count = 0;
if(fullCount){
if (fullCount) {
count = signalStateEventAssessmentRepo.getQueryFullCount(query);
}else{
} else {
count = signalStateEventAssessmentRepo.getQueryResultCount(query);
}
logger.info("Found: " + count + " Signal State Event Assessments");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public String getCurrentTime() {

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/bsm/json", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("@PermissionService.isSuperUser() || @PermissionService.hasRole('USER') || @PermissionService.hasRole('ADMIN')")
@PreAuthorize("@PermissionService.isSuperUser() || @PermissionService.hasRole('USER')")
public ResponseEntity<List<OdeBsmData>> findBSMs(
@RequestParam(name = "origin_ip", required = false) String originIp,
@RequestParam(name = "vehicle_id", required = false) String vehicleId,
Expand All @@ -53,15 +53,16 @@ public ResponseEntity<List<OdeBsmData>> findBSMs(
if (testData) {
return ResponseEntity.ok(MockBsmGenerator.getJsonBsms());
} else {
List<OdeBsmData> geoData = odeBsmJsonRepo.findOdeBsmDataGeo(originIp, vehicleId, startTime, endTime, longitude, latitude, distanceInMeters);
List<OdeBsmData> geoData = odeBsmJsonRepo.findOdeBsmDataGeo(originIp, vehicleId, startTime, endTime,
longitude, latitude, distanceInMeters);
logger.info("Found " + geoData.size() + " BSMs");
return ResponseEntity.ok(geoData);
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/bsm/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("@PermissionService.isSuperUser() || @PermissionService.hasRole('USER') || @PermissionService.hasRole('ADMIN')")
@PreAuthorize("@PermissionService.isSuperUser() || @PermissionService.hasRole('USER')")
public ResponseEntity<Long> countBSMs(
@RequestParam(name = "origin_ip", required = false) String originIp,
@RequestParam(name = "vehicle_id", required = false) String vehicleId,
Expand All @@ -75,7 +76,8 @@ public ResponseEntity<Long> countBSMs(
if (testData) {
return ResponseEntity.ok(10L);
} else {
long counts = odeBsmJsonRepo.countOdeBsmDataGeo(originIp, vehicleId, startTime, endTime, longitude, latitude, distanceInMeters);
long counts = odeBsmJsonRepo.countOdeBsmDataGeo(originIp, vehicleId, startTime, endTime, longitude,
latitude, distanceInMeters);
logger.info("Found " + counts + " BSMs");
return ResponseEntity.ok(counts);
}
Expand Down
Loading
Loading