簡體   English   中英

Servlet上下文中的WebSphere管理角色檢查

[英]WebSphere administrative role checking within servlet context

我只是試圖檢查給定用戶在Java servlet中是否具有給定的WebSphere管理角色。

成語:

HttpServletRequest#isUserInRole

...適用於非管理角色, 以及 文檔頁面中定義的iscadmins管理角色。

但是,調用isUserInRole時,以上頁面中的所有其他角色(似乎與iscadmins有所不同,因為首字母大寫)。

我嘗試與主要的管理用戶(基於文件,使用配置文件創建)以及其他我明確添加了管理角色的用戶進行檢查。

在所有情況下,只有iscadmin角色檢查在分配后返回true。

如果有關系,請使用標准的WAS 8.5.5。

我想知道在這種情況下我是否對安全性和范圍有一些誤解。

注意

我嘗試了不同的組合來檢查具有首字母大寫的角色名稱:按原樣,小寫字母,大寫字母等。借助Admin Security Manager角色,甚至更具創造力...

經過數小時的頭痛和無記錄的API搜索之后,我想我已經找到了想要的東西。

一般警告

我找不到關於此的任何文檔,甚至找不到javadocs。 我不能誠實地說這是否是推薦的方法。

也就是說,下面的方法對我有用(通過從登錄的用戶分配和刪除Admin安全管理器角色進行測試,然后重新加載servlet並進行調試)。

同樣,關於為什么這些角色無法通過HttpServletRequest#isUserInRole慣用法可見的問題仍然存在。

代碼配方

// relevant imports
import com.ibm.websphere.management.authorizer.AdminAuthorizer;
import com.ibm.websphere.management.authorizer.AdminAuthorizerFactory;
import static com.ibm.ws.security.util.Constants.*;

// you'll need the com.ibm.ws.admin.core.jar plugin in your classpath for this
AdminAuthorizer aa = AdminAuthorizerFactory.getAdminAuthorizer();

// all admin roles are there as constants, 
// save for "iscadmins", which you can retrieve with
// the HttpServletRequest#isUserInRole idiom anyway
String role = com.ibm.ws.security.util.Constants.ADMINSECURITY_ROLE;

// that's it!
boolean test = aa.isCallerInRole(role);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM