我正在尝试使用Spring Security 4和Java配置实现LDAP身份验证。 Java配置中这个XML的等价物是什么:
public enum PcapLinkType {
DLT_NULL(0),
DLT_EN3MB(2),
DLT_AX25(3),
/*snip, 200 more enums, not always consecutive.*/
// DLT_UNKNOWN(-1); // <--- NO LONGER NEEDED
private final int value;
private PcapLinkType(int value) { this.value = value; }
private static final Map<Integer, PcapLinkType> map;
static {
map = Arrays.stream(values())
.collect(Collectors.toMap(e -> e.value, e -> e));
}
public static Optional<PcapLinkType> fromInt(int value) {
return Optional.ofNullable(map.get(value));
}
}
答案 0 :(得分:1)
@Configuration
@EnableWebSecurity
public class PasswordCompareLdapConfig extends WebSecurityConfigurerAdapter {
protected void registerAuthentication(
AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.passwordCompare()
.passwordEncoder(new BaseDigestPasswordEncoder())
.passwordAttribute("userPassword");
}
}