title: Why is user.getRole() set as the GrantedAuthority in this Spring 3.0 authentication example?
body: <p>I'm trying to understand Spring 3.0 authentication. </p>
  
  <p>In the code below, why is <code>user.getRole()</code> set as the <code>GrantedAuthority</code>?</p>
  
  <pre><code>public final UserDetails loadUserByUsername(final String username)
  {
      final List&lt;GrantedAuthority&gt; authorities = new ArrayList&lt;GrantedAuthority&gt;();
      UserAccount user = (UserAccount) memcacheService.get(username);
  
      if (user == null)
      {
          final Query query = entityManager.createQuery("SELECT u FROM UserAccount u WHERE username = :username");
          query.setParameter(USERNAME, username);
  
          try
          {
              user = (UserAccount) query.getSingleResult();
  
              memcacheService.put(username, user, Expiration.byDeltaSeconds(DEFAULT_EXPIRATION));
          }
          catch (NoResultException e)
          {
              return null;
          }
      }
  
      authorities.add(new GrantedAuthorityImpl(user.getRole()));
  
      return new EnhancedUser(user.getUsername(), user.getEmail(), user.getDisplayName(), user.getPassword(), user
          .getSalt(), user.isEnabled(), user.isAccountNonExpired(), user.isCredentialsNonExpired(), user.isAccountNonLocked(),
          authorities);
  }
  </code></pre>