spring security 4.0 中GrantedAuthorityImpl 类的替换方法

摘要: 今天想把以前用spring security3.0 做的权限管理系统升级到 spring security 4.0, 但在升级过程中出现了一个错误,提示 GrantedAuthorityImpl  这个类 找不到了。  这个类在spring security 3.0  中应该就已经是过时的 了,当时没注意。 以下是替换方法

今天想把以前用spring security3.0 做的权限管理系统升级到 spring security 4.0, 但在升级过程中出现了一个错误,提示 GrantedAuthorityImpl 这个类 找不到了。 这个类在spring security 3.0 中应该就已经是过时的 了,当时没注意。 以下是替换方法.

原来的代码

public Collection getAuthorities(Integer access) {
    List authList = new ArrayList(2);

    if (access.compareTo(1) == 0) {
        authList.add(new GrantedAuthorityImpl("ROLE_ADMIN"));
    }
    else{
        authList.add(new GrantedAuthorityImpl("ROLE_USER"));
    }
    return authList;
}


在 spring-security 4.0 中的代码如下:
public Collection getAuthorities(Integer access) {
    List authList = new ArrayList(2);

    if (access.compareTo(1) == 0) {
        authList.add(new SimpleGrantedAuthority("ROLE_ADMIN"));
    }
    else{
        authList.add(new SimpleGrantedAuthority("ROLE_USER"));
    }
    return authList;
}

上一篇: mysql 5.7.9 无法启动问题解决
下一篇: 微信公众号,企业号发红包的实现.
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章或者资源来源于互联网, 有时候很难判断是否侵权, 若有侵权, 请联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布无版权争议的 文章/资源.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号