if(!StringUtils.hasLength(username)) { throw new BadCredentialsException(messages.getMessage( "LdapAuthenticationProvider.emptyUsername", "Empty Username")); }
    protected UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {        if (logger.isDebugEnabled()) {            logger.debug("Retrieving user " + username);        }        String password = (String)authentication.getCredentials();        Assert.notNull(password, "Null password was supplied in authentication token");        LdapUserInfo ldapUser = authenticator.authenticate(username, password);        return createUserDetails(username, password, ldapUser.getDn(), ldapUser.getAttributes());    }