mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-08 19:42:48 +00:00
SEC-1031: Ported change from trunk.
This commit is contained in:
parent
ad4b5c487f
commit
4c3867718e
@ -86,9 +86,9 @@ public class LdapShaPasswordEncoder implements PasswordEncoder {
|
|||||||
sha.update(rawPass.getBytes("UTF-8"));
|
sha.update(rawPass.getBytes("UTF-8"));
|
||||||
} catch (java.security.NoSuchAlgorithmException e) {
|
} catch (java.security.NoSuchAlgorithmException e) {
|
||||||
throw new IllegalStateException("No SHA implementation available!");
|
throw new IllegalStateException("No SHA implementation available!");
|
||||||
} catch (UnsupportedEncodingException ue) {
|
} catch (UnsupportedEncodingException ue) {
|
||||||
throw new IllegalStateException("UTF-8 not supported!");
|
throw new IllegalStateException("UTF-8 not supported!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (salt != null) {
|
if (salt != null) {
|
||||||
Assert.isInstanceOf(byte[].class, salt, "Salt value must be a byte array");
|
Assert.isInstanceOf(byte[].class, salt, "Salt value must be a byte array");
|
||||||
@ -141,11 +141,11 @@ public class LdapShaPasswordEncoder implements PasswordEncoder {
|
|||||||
} else if (!prefix.equals(SHA_PREFIX) && !prefix.equals(SHA_PREFIX_LC)) {
|
} else if (!prefix.equals(SHA_PREFIX) && !prefix.equals(SHA_PREFIX_LC)) {
|
||||||
throw new IllegalArgumentException("Unsupported password prefix '" + prefix + "'");
|
throw new IllegalArgumentException("Unsupported password prefix '" + prefix + "'");
|
||||||
} else {
|
} else {
|
||||||
// Standard SHA
|
// Standard SHA
|
||||||
salt = null;
|
salt = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int startOfHash = prefix.length() + 1;
|
int startOfHash = prefix.length();
|
||||||
|
|
||||||
String encodedRawPass = encodePassword(rawPass, salt).substring(startOfHash);
|
String encodedRawPass = encodePassword(rawPass, salt).substring(startOfHash);
|
||||||
|
|
||||||
@ -157,16 +157,16 @@ public class LdapShaPasswordEncoder implements PasswordEncoder {
|
|||||||
*/
|
*/
|
||||||
private String extractPrefix(String encPass) {
|
private String extractPrefix(String encPass) {
|
||||||
if (!encPass.startsWith("{")) {
|
if (!encPass.startsWith("{")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int secondBrace = encPass.lastIndexOf('}');
|
int secondBrace = encPass.lastIndexOf('}');
|
||||||
|
|
||||||
if (secondBrace < 0) {
|
if (secondBrace < 0) {
|
||||||
throw new IllegalArgumentException("Couldn't find closing brace for SHA prefix");
|
throw new IllegalArgumentException("Couldn't find closing brace for SHA prefix");
|
||||||
}
|
}
|
||||||
|
|
||||||
return encPass.substring(0, secondBrace + 1);
|
return encPass.substring(0, secondBrace + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setForceLowerCasePrefix(boolean forceLowerCasePrefix) {
|
public void setForceLowerCasePrefix(boolean forceLowerCasePrefix) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user