提交 200ef570 编写于 作者: zhouweidong's avatar zhouweidong

权限调整

上级 2200c2e0
...@@ -9,13 +9,11 @@ import lombok.AllArgsConstructor; ...@@ -9,13 +9,11 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.Map;
import java.util.HashMap;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Collection; import java.util.*;
import java.util.Set;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
@Data @Data
...@@ -61,7 +59,7 @@ public class AuthenticationUser implements UserDetails ...@@ -61,7 +59,7 @@ public class AuthenticationUser implements UserDetails
private String memo; private String memo;
private Map <String,Object> sessionParams; private Map <String,Object> sessionParams;
@JsonIgnore @JsonIgnore
private Collection<GrantedAuthority> authorities; private Collection<GrantedAuthority> authorities;
private int superuser; private int superuser;
private JSONObject permissionList; private JSONObject permissionList;
...@@ -147,4 +145,15 @@ public class AuthenticationUser implements UserDetails ...@@ -147,4 +145,15 @@ public class AuthenticationUser implements UserDetails
else else
return new HashMap<>(); return new HashMap<>();
} }
public Collection<GrantedAuthority> getAuthorities() {
if(authorities==null && permissionList !=null){
if(permissionList.getJSONArray("authorities")!=null){
authorities=new ArrayList<>();
permissionList.getJSONArray("authorities").
forEach(item->authorities.add(new SimpleGrantedAuthority(String.valueOf(item))));
}
}
return authorities;
}
} }
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册