From 95f62901c22588dc420e47f2b658a2ce97972422 Mon Sep 17 00:00:00 2001 From: girirajsharma Date: Sun, 22 Nov 2015 23:04:45 +0530 Subject: [PATCH 1/2] [KEYCLOAK-2119] OTP Policy form validates both TOTP and HOTP at the same time --- .../theme/base/admin/resources/partials/otp-policy.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/otp-policy.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/otp-policy.html index 1f8890e7d7..eaaf8116b0 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/otp-policy.html +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/otp-policy.html @@ -51,18 +51,18 @@ How far ahead should the server look just in case the token generator and server are out of time sync or counter sync? -
+
- +
What should the initial counter value be?
-
+
- +
How many seconds should an OTP token be valid? Defaults to 30 seconds.
From f6743eff69ac02f9dbdd5939d2e5059632401d2d Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Mon, 23 Nov 2015 12:02:39 +0100 Subject: [PATCH 2/2] KEYCLOAK-2119 OTP Policy form validates both TOTP and HOTP at the same time --- .../keycloak/models/utils/RepresentationToModel.java | 12 ++++++------ .../services/resources/admin/RealmAdminResource.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java b/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java index dde4462b97..3916fd16a7 100755 --- a/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java +++ b/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java @@ -69,12 +69,12 @@ public class RepresentationToModel { private static Logger logger = Logger.getLogger(RepresentationToModel.class); public static OTPPolicy toPolicy(RealmRepresentation rep) { OTPPolicy policy = new OTPPolicy(); - policy.setType(rep.getOtpPolicyType()); - policy.setLookAheadWindow(rep.getOtpPolicyLookAheadWindow()); - policy.setInitialCounter(rep.getOtpPolicyInitialCounter()); - policy.setAlgorithm(rep.getOtpPolicyAlgorithm()); - policy.setDigits(rep.getOtpPolicyDigits()); - policy.setPeriod(rep.getOtpPolicyPeriod()); + if (rep.getOtpPolicyType() != null) policy.setType(rep.getOtpPolicyType()); + if (rep.getOtpPolicyLookAheadWindow() != null) policy.setLookAheadWindow(rep.getOtpPolicyLookAheadWindow()); + if (rep.getOtpPolicyInitialCounter() != null) policy.setInitialCounter(rep.getOtpPolicyInitialCounter()); + if (rep.getOtpPolicyAlgorithm() != null) policy.setAlgorithm(rep.getOtpPolicyAlgorithm()); + if (rep.getOtpPolicyDigits() != null) policy.setDigits(rep.getOtpPolicyDigits()); + if (rep.getOtpPolicyPeriod() != null) policy.setPeriod(rep.getOtpPolicyPeriod()); return policy; } diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java index d874d1e2d5..90eab4a54e 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java @@ -236,7 +236,7 @@ public class RealmAdminResource { } catch (ModelDuplicateException e) { throw e; } catch (Exception e) { - logger.error(e); + logger.error(e.getMessage(), e); return ErrorResponse.error("Failed to update " + rep.getRealm() + " Realm.", Response.Status.INTERNAL_SERVER_ERROR); } }