Spring security SSHA512加密并与spring 5匹配

Spring security SSHA512加密并与spring 5匹配,spring-security,password-encryption,sha512,password-hash,ssha,Spring Security,Password Encryption,Sha512,Password Hash,Ssha,我正在使用现有LDAP实现spring安全性,其中密码是SSHA512编码的。不推荐使用的LdapShaEncoder仅支持{SHA}和{SSHA} 有人能帮我实现一个JavaSSHA512编码器和SpringSecurity吗。或者有没有图书馆可以做这项工作 import org.springframework.security.crypto.password.LdapShaPasswordEncoder; import org.springframework.security.crypto.

我正在使用现有LDAP实现spring安全性,其中密码是SSHA512编码的。不推荐使用的LdapShaEncoder仅支持{SHA}和{SSHA}

有人能帮我实现一个JavaSSHA512编码器和SpringSecurity吗。或者有没有图书馆可以做这项工作

import org.springframework.security.crypto.password.LdapShaPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

@Bean
public PasswordEncoder passwordEncoder() {
    return new LdapShaPasswordEncoder();
}
例外情况:

java.lang.IllegalArgumentException: Unsupported password prefix '{SSHA512}'
    at org.springframework.security.crypto.password.LdapShaPasswordEncoder.matches(LdapShaPasswordEncoder.java:173) ~[spring-security-core-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.security.crypto.password.LdapShaPasswordEncoder.matches(LdapShaPasswordEncoder.java:158) ~[spring-security-core-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.security.authentication.dao.DaoAuthenticationProvider.additionalAuthenticationChecks(DaoAuthenticationProvider.java:90) ~[spring-security-core-5.1.3.RELEASE.jar:5.1.3.RELEASE]
    at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:166) ~[spring-security-core-5.1.3.RELEASE.jar:5.1.3.RELEASE]
请看这里:
我基本上只是在MessageDigest.getInstance()中用SHA-512交换了SHA,并调整了前缀和长度常量。

非常感谢@lathspell。你救了我一天。我必须修改你的代码,因为我必须同时支持SSHA和SHA-512。干得好,谢谢