SEBSERV-238 use max exp time for Zoom SDK Token generation

(no exam end-time involvement to check if this was the error)
This commit is contained in:
anhefti 2021-11-08 12:54:25 +01:00
parent 3aa46b3241
commit c89a609615

View file

@ -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 {