0

I'm trying to implement LDAP authentication with Spring Security 4 and Java config. What is the equivalent of this XML in Java config:

    <ldap-authentication-provider>
         <password-compare hash="{ssha}"/>
    </ldap-authentication-provider>

1 Answer 1

1
@Configuration
@EnableWebSecurity
public class PasswordCompareLdapConfig extends WebSecurityConfigurerAdapter {
    protected void registerAuthentication(
            AuthenticationManagerBuilder auth) throws Exception {
        auth
            .ldapAuthentication()
                .passwordCompare()
                    .passwordEncoder(new BaseDigestPasswordEncoder()) 
                    .passwordAttribute("userPassword"); 
    }
}
Sign up to request clarification or add additional context in comments.

3 Comments

"Cannot instantiate the type BaseDigestPasswordEncoder"
I think it is new ShaPasswordEncoder() and have to set setEncodeHashAsBase64(true) for ShaPasswordEncoder.I'll check to see if it works.
You are probably right. I just pasted a sample annotation config..feel free to update the answer of it works for u

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.