View Javadoc
1   package org.woehlke.bloodmoney.user.impl;
2   
3   import lombok.extern.slf4j.Slf4j;
4   import org.springframework.beans.factory.annotation.Autowired;
5   import org.springframework.security.core.userdetails.UserDetails;
6   import org.springframework.security.core.userdetails.UsernameNotFoundException;
7   import org.springframework.stereotype.Service;
8   import org.springframework.transaction.annotation.Propagation;
9   import org.springframework.transaction.annotation.Transactional;
10  import org.woehlke.bloodmoney.config.BloodMoneyProperties;
11  import org.woehlke.bloodmoney.user.UserAccountDetailsBean;
12  import org.woehlke.bloodmoney.user.BloodMoneyUserAccountDetailsService;
13  
14  @Slf4j
15  @Service
16  @Transactional(propagation = Propagation.REQUIRED, readOnly = true)
17  public class BloodMoneyUserAccountDetailsServiceImpl implements BloodMoneyUserAccountDetailsService {
18  
19      @Autowired
20      private BloodMoneyProperties bloodMoneyProperties;
21  
22      @Override
23      public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
24          if(username.compareTo(bloodMoneyProperties.getUserConfig().getUserEmail())==0){
25              return new UserAccountDetailsBean(bloodMoneyProperties.getUserConfig().getUserEmail(), bloodMoneyProperties.getUserConfig().getUserPassword());
26          } else {
27              throw new UsernameNotFoundException("Usernam unknown: "+username);
28          }
29      }
30  }