コード例 #1
0
 @Override
 @Transactional
 public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
   try {
     SystemUser user = systemUserService.getSystemUserByUsername(username);
     System.out.println("====logged user====" + user.getUsername());
     throwExceptionIfNotFound(user, username);
     return new UserDetailsDTO(user);
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
コード例 #2
0
  public UserDetailsDTO(SystemUser user) {
    this.userID = user.getUserId();
    this.login = user.getUsername();
    this.screenDisplayName = user.getFirstName();
    this.passwordHash = user.getPassword();
    this.enabled = user.getActiveStatus() == 1;

    List<UserRole> userRoleList = new ArrayList<UserRole>();
    if (user.getSystemUserRoleList() != null) {
      for (SystemUserRole systemUserRole : user.getSystemUserRoleList()) {
        userRoleList.add(systemUserRole.getUserRole());
      }
    }

    this.grantedAuthorities.addAll(userRoleList);
  }