コード例 #1
0
  /** This Method is used by container based authentication (web client) */
  @Override
  public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    if ((username == null) || username.equals("")) {
      throw new AuthenticationCredentialsNotFoundException("No username provided in auth request");
    }

    try {
      User user = userRepo.findByUsername(username);
      if (user == null) {
        throw new UsernameNotFoundException("No user with name " + username + " found");
      }
      return new MultiTenantUserDetails(
          user.getUsername(),
          user.getPassword(),
          getAuthorities(user),
          user.getTenant().getTenantId());
    } catch (NoResultException e) {
      throw new UsernameNotFoundException("No user with name " + username + " found");
    }
  }