public UserDetail loadDetail(Authentication auth) {
List<User> users = entityDao.get(User.class, "name", auth.getName());
if (users.isEmpty()) {
return null;
} else {
User user = users.get(0);
List<Group> groups = user.getGroups();
List<GrantedAuthorityBean> authorities = CollectUtils.newArrayList(groups.size());
Group defaultGroup = null;
for (Group g : groups) {
authorities.add(new GrantedAuthorityBean(g.getName()));
if (groupProfileService.hasProfile(g)) {
defaultGroup = g;
}
}
String categoryName = (null == defaultGroup) ? "default" : defaultGroup.getName();
return new UserToken(user.getId(), user.getName(), user.getFullname(), user.getPassword(),
categoryName, user.isEnabled(), user.isAccountExpired(), user.isPasswordExpired(), false,
authorities);
}
}