package com.imap.services.impl;

import com.imap.dao.UserDao;
import com.imap.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Сервис для работы с данными пользователей.
 *
 * @author Boris Finkelshtein <finke.ba@gmail.com>
 */
@Service
public class UserDetailsServiceStub implements UserDetailsService {

	private final UserDao userDao;

	@Autowired
	public UserDetailsServiceStub (final UserDao userDao) {
		this.userDao = userDao;
	}

	@Override
	public UserDetails loadUserByUsername (String username) throws UsernameNotFoundException {

		if ("user".equals(username)) {
			return userDao.getUser (username);
		}
		throw new UsernameNotFoundException ("User with name = " + username + " not found");
	}
}

@@ -59,37 +59,8 @@
 ao;%0A
-import com.imap.domain.User;%0A
 impo
@@ -149,54 +149,42 @@
 ork.
-security.core.authority.SimpleGrantedAuthority
+dao.EmptyResultDataAccessException
 ;%0Aim
@@ -452,60 +452,8 @@
 e;%0A%0A
-import java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 /**%0A
@@ -876,36 +876,11 @@
 %0A%0A%09%09
-if (%22user%22.equals(username))
+try
  %7B%0A%09
@@ -919,17 +919,61 @@
 me);%0A%09%09%7D
-%0A
+ catch (EmptyResultDataAccessException e) %7B%0A%09
 %09%09throw 
@@ -1051,13 +1051,18 @@
 ound%22);%0A
+%09%09%7D%0A%0A
 %09%7D%0A%7D%0A

Change user checking.