Exemplo n.º 1
0
 @Transactional
 public UserDetails loadUserByUsername(String username)
     throws UsernameNotFoundException, DataAccessException {
   User u = userDao.getUserByName(username);
   if (u == null) {
     throw new UsernameNotFoundException("User '" + username + "' was not found");
   }
   //        LOG.debug("admin would be:" + passwordEncoder.encodePassword("admin", new Long(83)));
   return u;
 }
Exemplo n.º 2
0
 @Transactional
 public void deleteUser(long id) {
   User u = userDao.getUserById(id);
   Role adminRole = roleService.getAdminRole();
   int articleCount = articleService.getArticleCountByUser(u);
   int adminCount = userDao.getAdminUserCount();
   LOG.debug("trying to delete user " + u.getUsername());
   LOG.debug("global admin count: " + adminCount);
   LOG.debug("is admin user: "******"number articles associated: " + articleCount);
   if (u.getAuthorities().contains(adminRole) && adminCount == 1) {
     LOG.error("cant delete last admin user");
     return;
   }
   if (articleCount > 0) {
     LOG.error("User still has articles associated");
     return;
   }
   LOG.debug("deleting user " + u.getUsername());
   userDao.deleteUser(u);
 }
Exemplo n.º 3
0
 @Transactional
 public void saveUser(User u) {
   userDao.saveOrUpdate(u);
 }
Exemplo n.º 4
0
 @Transactional
 public List<User> getAllUsers() {
   return userDao.getAllUsers();
 }
Exemplo n.º 5
0
 @Transactional
 public int getUserCount() {
   return userDao.getUserCount();
 }
Exemplo n.º 6
0
 @Transactional
 public void addUser(User u, String pass) {
   userDao.saveOrUpdate(u);
   u.setPassword(passwordEncoder.encodePassword(pass, u.getId()));
   userDao.saveOrUpdate(u);
 }
Exemplo n.º 7
0
 @Transactional
 public User getUserById(long id) {
   return userDao.getUserById(id);
 }