java GrantedAuthorityImpl() 类的替代方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14035953/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
alternative to GrantedAuthorityImpl() class
提问by Oomph Fortuity
I want the alternative to GrantedAuthorityImpl() class.i want this in spring security implementation. GrantedAuthorityImpl() class is Depricated.hence i want alternative solution to it.
我想要 GrantedAuthorityImpl() 类的替代方案。我希望在 spring 安全实现中使用它。GrantedAuthorityImpl() 类是 Depricated。因此我想要它的替代解决方案。
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;
}
回答by John Farrelly
The class GrantedAuthorityImpl has been deprecated - you can use SimpleGrantedAuthority instead:
类 GrantedAuthorityImpl 已被弃用 - 您可以使用 SimpleGrantedAuthority 代替:
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;
}