Package com.dream.service.impl

Source Code of com.dream.service.impl.UserServiceImpl

package com.dream.service.impl;

import com.dream.dao.UserDao;
import com.dream.domain.user.User;
import com.dream.dto.user.registration.RegistrationDTO;
import com.dream.service.UserService;
import org.springframework.security.authentication.encoding.PasswordEncoder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

/**
* Created by IntelliJ IDEA.
* User: Gang Zhong
* Date: 13-3-15
* Time: 上午1:31
*/
public class UserServiceImpl implements UserService {
    private UserDao userDao;
    private PasswordEncoder passwordEncoder;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        return userDao.findUserByUsername(username);
    }

    @Override
    public void createUser(RegistrationDTO registrationDTO) {
        User user = registrationDTO.toNewUser(passwordEncoder);
        userDao.saveOrUpdate(user);
    }

    @Override
    public boolean emailExist(String email) {
        int count = userDao.findEmailCount(email);
        return count > 0;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
        this.passwordEncoder = passwordEncoder;
    }
}
TOP

Related Classes of com.dream.service.impl.UserServiceImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.