39

GrantedAuthorityImpl() クラスの代替が必要です。春のセキュリティ実装でこれが欲しい。GrantedAuthorityImpl() クラスは非推奨です。したがって、私はそれに対する代替ソリューションが必要です。私のコード:

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;
}
4

1 に答える 1

79

クラス 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;
}
于 2012-12-26T09:08:11.777 に答える