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 :
JavaScript
x
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;
}
Advertisement
Answer
The class GrantedAuthorityImpl has been deprecated – you can use SimpleGrantedAuthority instead:
JavaScript
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;
}