Skip to content

Instantly share code, notes, and snippets.

@mh-github
Created August 13, 2012 11:54
Show Gist options
  • Save mh-github/3339960 to your computer and use it in GitHub Desktop.
Save mh-github/3339960 to your computer and use it in GitHub Desktop.
@Entity
public class User implements Serializable, UserDetails {
// Spring Security props
private transient Collection<GrantedAuthority> authorities;
public void setUserAuthorities(Collection<Role> roles) {
List<GrantedAuthority> listOfAuthorities = new ArrayList<GrantedAuthority>();
for (Role role : roles) {
listOfAuthorities.add(new GrantedAuthorityImpl(role.getRole()));
}
this.authorities = (Collection<GrantedAuthority>) listOfAuthorities;
}
.....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment