diff --git a/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java b/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java index 480e1b43b682..796163f0c19d 100644 --- a/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java +++ b/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java @@ -839,10 +839,8 @@ public Details newInstance(StaplerRequest2 req, JSONObject formData) throws Form throw new FormException("Please confirm the password by typing it twice", "user.password2"); } - if (FIPS140.useCompliantAlgorithms()) { - if (pwd.length()< FIPS_PASSWORD_LENGTH) { - throw new FormException(Messages.HudsonPrivateSecurityRealm_CreateAccount_FIPS_PasswordLengthInvalid(), "user.password1"); - } + if (FIPS140.useCompliantAlgorithms() && pwd.length()< FIPS_PASSWORD_LENGTH) { + throw new FormException(Messages.HudsonPrivateSecurityRealm_CreateAccount_FIPS_PasswordLengthInvalid(), "user.password1"); } // will be null if it wasn't encrypted diff --git a/test/src/test/java/hudson/security/HudsonPrivateSecurityRealmFIPSTest.java b/test/src/test/java/hudson/security/HudsonPrivateSecurityRealmFIPSTest.java index a05a0ca76bce..3a69da803cab 100644 --- a/test/src/test/java/hudson/security/HudsonPrivateSecurityRealmFIPSTest.java +++ b/test/src/test/java/hudson/security/HudsonPrivateSecurityRealmFIPSTest.java @@ -25,8 +25,12 @@ package hudson.security; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertThrows; + import hudson.logging.LogRecorder; import hudson.logging.LogRecorderManager; import hudson.model.User;