MiG MiG - 6 months ago 29
Java Question

Spring LDAP security keep reseting

II have a Spring - Security login that - after I put my user/pass, enters here:

@Override
public UserDetails mapUserFromContext(final DirContextOperations ctx,
final String username,
final Collection<? extends GrantedAuthority> authorities) {
LOGGER.debug("mapUserFromContext(username={})...", username);

for (GrantedAuthority authority : authorities) {
LOGGER.info("user: {} >> role: {}", username, authority.getAuthority());
}

LOGGER.debug("DONE >> mapUserFromContext(username={}).", username);


EFormUserDetails eFormUserDetails = new EFormUserDetails();
eFormUserDetails.setAuthorities(authorities);
eFormUserDetails.setPassword("");
eFormUserDetails.setUsername(username);
eFormUserDetails.setAccountNonExpired(true);
eFormUserDetails.setAccountNonLocked(true);
eFormUserDetails.setCredentialsNonExpired(true);
eFormUserDetails.setEnabled(true);
eFormUserDetails.setJudet(securityUtils.getLoggedInUserJudet(authorities, username));
LOGGER.debug("3.mapUserFromContext(after securityUtils.getLoggedInUserJudet).");

return eFormUserDetails;
}


I get "3.mapUserFromContext(after securityUtils.getLoggedInUserJudet)." in my logger but the login window reset asking me again the user/pass. Where to put a logger to see what happens after it returns eFormUserDetails?

I must say that on my dev env. it works ok, the problem appears on production, where they have an proxy and an secure certified address for my app.

Thanks!

Answer

Try putting a debug in

protected Authentication createSuccessfulAuthentication(UsernamePasswordAuthenticationToken authentication,
            UserDetails user){

}

method of AbstractLdapAuthenticationProvider as here only successful authentication object is created after successful login.