/* (non-Javadoc)
   * @see org.springframework.security.core.userdetails.UserDetailsService#loadUserByUsername(java.lang.String)
   */
  @Override
  public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    User singleResult = null;
    try {
      singleResult = User.findUsersByUsernameEquals(username).getSingleResult();
    } catch (NoResultException e) {
      throw new UsernameNotFoundException("no username found by TypedQuery.getSingleResult", e);
    }

    if (singleResult == null) throw new DataAccessException("error retrieving a User") {};

    OwnUserDetailImplementation user =
        new OwnUserDetailImplementation(
            singleResult,
            username,
            singleResult.getPassword(),
            Collections.singleton(new SimpleGrantedAuthority("ROLE_USER")));
    return user;
  }
 public String getSalt() {
   return user.getRandomSalt();
 }