Skip to content

Commit

Permalink
IM-457 Add klab_Authorization to EnginePublicController
Browse files Browse the repository at this point in the history
  • Loading branch information
kristinaBc3 committed Nov 23, 2024
1 parent 7fe7364 commit fd80fa6
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ public TicketResponse.Ticket contextRequest(@RequestBody ContextRequest request,
@RequestMapping(value = OBSERVE_IN_CONTEXT, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public TicketResponse.Ticket observationRequest(@RequestBody ObservationRequest request,
@RequestHeader(name = "Klab_Authorization") String session, @PathVariable String context) {
@RequestHeader(name = "Klab_Authorization") String klabAuth, @RequestHeader(name = "Authorization") String auth, @PathVariable String context) {

String session = klabAuth == null ? klabAuth : auth;
Session s = Authentication.INSTANCE.getIdentity(session, Session.class);

if (s == null) {
Expand Down Expand Up @@ -145,9 +146,10 @@ public TicketResponse.Ticket observationRequest(@RequestBody ObservationRequest

@RequestMapping(value = SUBMIT_ESTIMATE, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public TicketResponse.Ticket submitEstimate(@RequestHeader(name = "Klab_Authorization") String session,
public TicketResponse.Ticket submitEstimate(@RequestHeader(name = "Klab_Authorization") String klabAuth, @RequestHeader(name = "Authorization") String auth,
@PathVariable String estimate) {

String session = klabAuth == null ? klabAuth : auth;
Session s = Authentication.INSTANCE.getIdentity(session, Session.class);
if (s == null) {
// FIXME not illegitimate in case of server failure or restart with persistent
Expand All @@ -169,18 +171,19 @@ public TicketResponse.Ticket submitEstimate(@RequestHeader(name = "Klab_Authoriz
return contextRequest(est.contextRequest, session, session);
}

return observationRequest(est.observationRequest, session, est.observationRequest.getContextId());
return observationRequest(est.observationRequest, session, session, est.observationRequest.getContextId());
}

@RequestMapping(value = EXPORT_DATA, method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE,
MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_PDF_VALUE, MediaType.IMAGE_PNG_VALUE, "text/csv", "image/tiff",
"application/vnd.ms-excel", "application/octet-stream",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"})
public void exportData(@PathVariable String export, @RequestHeader(name = "Klab_Authorization") String session,
public void exportData(@PathVariable String export, @RequestHeader(name = "Klab_Authorization") String klabAuth, @RequestHeader(name = "Authorization") String auth,
@PathVariable String observation, @RequestHeader(name = "Accept") String format,
@RequestParam(required = false) String view, @RequestParam(required = false) String viewport,
@RequestParam(required = false) String locator, HttpServletResponse response) throws IOException {

String session = klabAuth == null ? klabAuth : auth;
Session s = Authentication.INSTANCE.getIdentity(session, Session.class);
if (s == null) {
throw new KlabIllegalStateException("observe in context: invalid session ID");
Expand Down Expand Up @@ -388,9 +391,10 @@ private void outputImage(IObservation obs, HttpServletResponse response, Export

@RequestMapping(value = TICKET_INFO, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public TicketResponse.Ticket getTicketInfo(@RequestHeader(name = "Klab_Authorization") String session,
public TicketResponse.Ticket getTicketInfo(@RequestHeader(name = "Klab_Authorization") String klabAuth, @RequestHeader(name = "Authorization") String auth,
@PathVariable String ticket) {

String session = klabAuth == null ? klabAuth : auth;
Session s = Authentication.INSTANCE.getIdentity(session, Session.class);
if (s == null) {
// FIXME not illegitimate in case of server failure or restart with persistent
Expand Down

0 comments on commit fd80fa6

Please sign in to comment.