3

我想知道从 acl_entry 表中的权限检索到的 sid(“currentSid”)是否是主体或权限的。

for (int j = 0; j < acl.getEntries().size(); j++) {
    String currentPermissionPattern = acl.getEntries().get(j).getPermission().getPattern();
    String currentSid = acl.getEntries().get(j).getSid().toString();       
}

我目前将 currentSid 存储为字符串。假设我将它存储为 Sid,我怎么知道这个 Sid 是属于用户还是角色。

4

1 回答 1

1

你可以这样做:

if (acl.getEntries().get(j).getSid() instanceof GrantedAuthoritySid) {
    GrantedAuthoritySid sid = (GrantedAuthoritySid) acl.getEntries().get(j).getSid();
    // it's role
} else {
    PrincipalSid sid = (PrincipalSid) acl.getEntries().get(j).getSid();
    // it's user
}
于 2014-03-26T11:48:18.257 回答