基于用户角色/权限使用 GWT 和 Spring Security 创建条件 UI 的最佳实践是什么?
我知道您不能依赖客户端安全性。我将在服务器端进行安全检查。条件 UI 实际上只是为了外观。
最佳答案
您将需要一个服务来从服务器(有)到客户端(没有)获取用户角色列表。在回调的 onSuccess 方法中,您将拥有类似于以下的代码:
if (roles.contains("role1")) {
GWT.runAsync(new RunAsyncCallback() {
public void onFailure(Throwable caught) {
Window.alert("Code download failed");
}
public void onSuccess() {
// code here if the user has role1
}
});
}
if (roles.contains("role2")) {
GWT.runAsync(new RunAsyncCallback() {
public void onFailure(Throwable caught) {
Window.alert("Code download failed");
}
public void onSuccess() {
// code here if the user has role2
}
});
}
// and so on
关于java - 使用 GWT 和 Spring Security 的条件 UI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11477325/