code: public Collection<GrantedAuthority> getAuthorities() {
          Set<GrantedAuthority> authorities = new HashSet<GrantedAuthority>();
          for (Role role : Role.ROLE_USER.getRoleHierarchy()) {
              authorities.add(new SimpleGrantedAuthority(role.name()));
          }
  
          if (accountRights != null) {
              for (AccountRights rights : accountRights) {
                  Set<Role> roles = rights.getRoles();
                  if (roles != null) {
                      for (Role role : roles) {
                          authorities.add(role.authority());
                      }
                  }
              }
          }
  
          if (isRoot()) {
              authorities.add(new SimpleGrantedAuthority(Role.ROLE_ROOT.name()));
          }
          return authorities;
      }
docs: Returns the set of all possible roles a user can play This method is
  implemented as part of the UserDetails interface (
  <code>UserDetails</code>).
  
  @return