From c89a6096152dac3801ccc7c22b174711219e49a2 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 8 Nov 2021 12:54:25 +0100 Subject: [PATCH] SEBSERV-238 use max exp time for Zoom SDK Token generation (no exam end-time involvement to check if this was the error) --- .../proctoring/ZoomProctoringService.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ZoomProctoringService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ZoomProctoringService.java index 9ec6cb89..f4c8c9fc 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ZoomProctoringService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ZoomProctoringService.java @@ -744,12 +744,15 @@ public class ZoomProctoringService implements ExamProctoringService { } private long forExam(final ProctoringServiceSettings examProctoring) { - if (examProctoring.examId == null) { - throw new IllegalStateException("Missing exam identifier from ExamProctoring data"); - } - long expTime = Utils.toSeconds(System.currentTimeMillis() + Constants.DAY_IN_MILLIS); - if (this.examSessionService.isExamRunning(examProctoring.examId)) { + // NOTE: following is the original code that includes the exam end time but seems to make trouble for OLAT + final long nowInSeconds = Utils.getSecondsNow(); + final long nowPlus30MinInSeconds = nowInSeconds + Utils.toSeconds(30 * Constants.MINUTE_IN_MILLIS); + final long nowPlusOneDayInSeconds = nowInSeconds + Utils.toSeconds(Constants.DAY_IN_MILLIS); + final long nowPlusTwoDayInSeconds = nowInSeconds + Utils.toSeconds(2 * Constants.DAY_IN_MILLIS); + + long expTime = nowPlusOneDayInSeconds; + if (examProctoring.examId == null && this.examSessionService.isExamRunning(examProctoring.examId)) { final Exam exam = this.examSessionService.getRunningExam(examProctoring.examId) .getOrThrow(); if (exam.endTime != null) { @@ -758,10 +761,16 @@ public class ZoomProctoringService implements ExamProctoringService { } // refer to https://marketplace.zoom.us/docs/sdk/native-sdks/auth // "exp": 0, //JWT expiration date (Min:1800 seconds greater than iat value, Max: 48 hours greater than iat value) in epoch format. - if (expTime - Utils.getSecondsNow() > Utils.toSeconds(2 * Constants.DAY_IN_MILLIS)) { - expTime = Utils.toSeconds(System.currentTimeMillis() + Constants.DAY_IN_MILLIS); + if (expTime > nowPlusTwoDayInSeconds) { + expTime = nowPlusTwoDayInSeconds - 10; // Do not set to max because it is not well defined if max is included or not + } else if (expTime < nowPlus30MinInSeconds) { + expTime = nowPlusOneDayInSeconds; } - return expTime; + + log.debug("**** SDK Token exp time with exam-end-time inclusion would be: {}", expTime); + + // NOTE: Set this to the maximum according to https://marketplace.zoom.us/docs/sdk/native-sdks/auth + return nowPlusTwoDayInSeconds - 10; // Do not set to max because it is not well defined if max is included or not; } private final static class ZoomRestTemplate {