/** * Helper method that creates an Authentication object for the given user, * populating GrantedAuthority instances. * * @param user * @return */ protected Authentication createAuthenticationForUser(User user) { if (user != null) { String role = user.getRole().toString(); List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(); authorities.add(new GrantedAuthorityImpl("ROLE_" + role)); return new UsernamePasswordAuthenticationToken(user, user.getPassword(), authorities); } else { LOGGER.error(USER_NOT_FOUND_MSG); return null; } }
user = userService.get(us); LOGGER.info("US: " + us );//+ " PW: " + PwEncoder.encode(pw) + " -- " + user.getPassword()); if (user.getPassword() == null || !PwEncoder.isPasswordValid(user.getPassword(),pw)) { throw new BadCredentialsException(UNAUTHORIZED_MSG);
if (!PwEncoder.isPasswordValid(user.getPassword(),password)) { if (LOGGER.isInfoEnabled()) LOGGER.info("Bad pw for user " + username );
/** * @param list * @param includeAttributes * @return List<User> */ private List<User> configUserList(List<User> list, boolean includeAttributes) { List<User> uList = new ArrayList<User>(list.size()); for (User user : list) { User u = new User(); u.setGroups(user.getGroups()); u.setId(user.getId()); u.setName(user.getName()); u.setEnabled(user.isEnabled()); u.setPassword(user.getPassword()); u.setRole(user.getRole()); if (includeAttributes) { u.setAttribute(user.getAttribute()); } uList.add(u); } return uList; }