Tomcat isUserInRole
12:47
tomcat 有提供 realm 給予Role-based 的系統
在 share/org/apache/catalina/connector/HttpRequestBase.java
之中
public boolean isUserInRole(String role) { // Have we got an authenticated principal at all?
if (userPrincipal == null)
return (false); // Identify the Realm we will use for checking role assignmenets
if (context == null)
return (false);
Realm realm = context.getRealm();
if (realm == null)
return (false); // Check for a role alias defined in a <security-role-ref> element
if (wrapper != null) {
String realRole = wrapper.findSecurityReference(role);
if ((realRole != null) &&
realm.hasRole(userPrincipal, realRole))
return (true);
} // Check for a role defined directly as a <security-role>
return (realm.hasRole(userPrincipal, role)); }採用了 Principal 取得使用者資訊...
因為專案需要 似乎 spec 所提出的還不夠
- getRemoteUser
- isUserInRole
- getUserPrinciple
我應該會新增一個
來解決我的需求吧