OWL ITS + 탐지시스템(인터넷 진흥원)
jhjang
2021-10-14 d680ff9fa4298ad3c0cd12f5f9d87f6c51110480
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package kr.wisestone.owl.config.security.service;
 
import kr.wisestone.owl.common.MessageAccessor;
import kr.wisestone.owl.config.security.exception.LoginProcessingException;
import kr.wisestone.owl.constant.MsgConstants;
import kr.wisestone.owl.domain.User;
import kr.wisestone.owl.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.stereotype.Component;
 
@Component("userSecurityService")
public class UserSecurityService implements UserDetailsService {
 
    @Autowired
    protected MessageAccessor messageAccessor;
 
    @Autowired
    private UserService userService;
 
    @Override
    public UserDetails loadUserByUsername(final String login) {
        User user = this.userService.findByAccount(login);
 
        if (user == null) {
            throw new LoginProcessingException(MsgConstants.USER_NOT_EXIST);
        }
 
        if (!User.USER_STATUS_ACTIVE.equals(user.getStatus())) {
            throw new LoginProcessingException(MsgConstants.USER_NOT_USE_ACTIVE_STATUS);
        }
 
        return user;
    }
}