Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

alternative to GrantedAuthorityImpl() class

I want an alternative to GrantedAuthorityImpl() class. I want this in spring security implementation. GrantedAuthorityImpl() class is deprecated. Hence I want an alternative solution to it. My code :

public Collection<GrantedAuthority> getAuthorities(Integer access) {     List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>(2);          if (access.compareTo(1) == 0) {         authList.add(new GrantedAuthorityImpl("ROLE_ADMIN"));     }     else{         authList.add(new GrantedAuthorityImpl("ROLE_USER"));     }     return authList; } 
like image 388
Oomph Fortuity Avatar asked Dec 26 '12 04:12

Oomph Fortuity


1 Answers

The class GrantedAuthorityImpl has been deprecated - you can use SimpleGrantedAuthority instead:

public Collection<GrantedAuthority> getAuthorities(Integer access) {     List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>(2);      if (access.compareTo(1) == 0) {         authList.add(new SimpleGrantedAuthority("ROLE_ADMIN"));     }     else{         authList.add(new SimpleGrantedAuthority("ROLE_USER"));     }     return authList; } 
like image 67
John Farrelly Avatar answered Oct 06 '22 00:10

John Farrelly