From 494c6a08ec8cecbec7c56468707419f216048f1f Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 15 Jul 2021 13:42:14 +0200 Subject: [PATCH] SEBSERV-216 fixed --- .../java/ch/ethz/seb/sebserver/gbl/util/Result.java | 1 - .../ethz/seb/sebserver/gui/content/QuizLookupList.java | 2 +- .../service/examconfig/impl/PasswordFieldBuilder.java | 5 ++++- .../servicelayer/dao/impl/SEBClientConfigDAOImpl.java | 10 ++++++++-- .../sebconfig/impl/ExamConfigXMLParser.java | 5 ++++- .../sebconfig/impl/converter/StringConverter.java | 5 ++++- .../impl/indicator/PingIntervalClientIndicator.java | 2 +- 7 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Result.java b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Result.java index e2f1fd39..be328b3f 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Result.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Result.java @@ -383,7 +383,6 @@ public final class Result { @Override public String toString() { throw new RuntimeException("Result.toString is probably called by mistake !!!"); - //return "Result [value=" + this.value + ", error=" + this.error + "]"; } public interface TryCatchSupplier { diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/QuizLookupList.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/QuizLookupList.java index e9ae8497..500b87f8 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/QuizLookupList.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/QuizLookupList.java @@ -277,7 +277,7 @@ public class QuizLookupList implements TemplateComposer { .map(key -> Long.valueOf(key.modelId)) .collect(Collectors.toList()); - if (existingImports != null && !existingImports.contains(institutionId)) { + if (existingImports != null && !existingImports.isEmpty() && !existingImports.contains(institutionId)) { return TEXT_KEY_CONFIRM_EXISTING; } else { return null; diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/PasswordFieldBuilder.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/PasswordFieldBuilder.java index 1d3d44e9..3c806ae6 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/PasswordFieldBuilder.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/PasswordFieldBuilder.java @@ -169,7 +169,10 @@ public class PasswordFieldBuilder implements InputFieldBuilder { public String getValue() { final CharSequence pwd = this.control.getValue(); if (StringUtils.isNotBlank(pwd)) { - return this.cryptor.encrypt(pwd).toString(); + return this.cryptor + .encrypt(pwd) + .getOrThrow() + .toString(); } return StringUtils.EMPTY; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/SEBClientConfigDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/SEBClientConfigDAOImpl.java index 73e0956b..8175572e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/SEBClientConfigDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/SEBClientConfigDAOImpl.java @@ -577,7 +577,10 @@ public class SEBClientConfigDAOImpl implements SEBClientConfigDAO { EntityType.SEB_CLIENT_CONFIGURATION, configId, SEBClientConfig.ATTR_FALLBACK_PASSWORD, - this.clientCredentialService.encrypt(sebClientConfig.fallbackPassword).toString()); + this.clientCredentialService + .encrypt(sebClientConfig.fallbackPassword) + .getOrThrow() + .toString()); } else { this.additionalAttributesDAO.delete( EntityType.SEB_CLIENT_CONFIGURATION, @@ -590,7 +593,10 @@ public class SEBClientConfigDAOImpl implements SEBClientConfigDAO { EntityType.SEB_CLIENT_CONFIGURATION, configId, SEBClientConfig.ATTR_QUIT_PASSWORD, - this.clientCredentialService.encrypt(sebClientConfig.quitPassword).toString()); + this.clientCredentialService + .encrypt(sebClientConfig.quitPassword) + .getOrThrow() + .toString()); } else { this.additionalAttributesDAO.delete( EntityType.SEB_CLIENT_CONFIGURATION, diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigXMLParser.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigXMLParser.java index 46a84455..197eadd4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigXMLParser.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/ExamConfigXMLParser.java @@ -517,7 +517,10 @@ public class ExamConfigXMLParser extends DefaultHandler { attribute.id, listIndex, StringUtils.isNotBlank(value) - ? this.cryptor.encrypt(value + Constants.IMPORTED_PASSWORD_MARKER).toString() + ? this.cryptor + .encrypt(value + Constants.IMPORTED_PASSWORD_MARKER) + .getOrThrow() + .toString() : value); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/StringConverter.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/StringConverter.java index eabac5f7..594f30c9 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/StringConverter.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/sebconfig/impl/converter/StringConverter.java @@ -133,7 +133,10 @@ public class StringConverter implements AttributeValueConverter { // decrypt internally encrypted password and hash it for export // NOTE: see special case description in ExamConfigXMLParser.createConfigurationValue - final String plainText = this.clientCredentialService.decrypt(value).toString(); + final String plainText = this.clientCredentialService + .decrypt(value) + .getOrThrow() + .toString(); if (plainText.endsWith(Constants.IMPORTED_PASSWORD_MARKER)) { return plainText.replace(Constants.IMPORTED_PASSWORD_MARKER, StringUtils.EMPTY); } else { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/PingIntervalClientIndicator.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/PingIntervalClientIndicator.java index 3fee7c42..2ce20a79 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/PingIntervalClientIndicator.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/PingIntervalClientIndicator.java @@ -134,7 +134,7 @@ public final class PingIntervalClientIndicator extends AbstractPingIndicator { .getLastPing(super.pingRecord.getId()); if (!lastPing.hasError()) { - return lastPing.get(); + return Math.max(this.currentValue, lastPing.get().doubleValue()); } else { log.error("Failed to get last ping from persistent: {}", lastPing.getError().getMessage()); }