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.
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); } }