public interface Acl
implements Owner
| java.security.acl.Acl |
代表访问控制列表(ACL)的接口。 访问控制列表是一种用于保护资源访问的数据结构。
ACL可以被认为是具有多个ACL条目的数据结构。 接口类型为AclEntry的每个ACL条目都包含一组与特定主体关联的权限。 (主事人代表个人用户或集团等实体)。 此外,每个ACL条目都被指定为正数或负数。 如果是肯定的,则权限将被授予关联的委托人。 如果否定,权限将被拒绝。
每个ACL中的ACL条目遵守以下规则:
java.security.acl package provides the interfaces to the ACL and related data structures (ACL entries, groups, permissions, etc.), and the
sun.security.acl classes provide a default implementation of the interfaces. For example,
java.security.acl.Acl provides the interface to an ACL and the
sun.security.acl.AclImpl class provides the default implementation of the interface.
java.security.acl.Acl接口扩展了java.security.acl.Owner接口。 所有者接口用于维护每个ACL的所有者列表。 只有所有者才可以修改ACL。 例如,只有所有者可以调用ACL的addEntry方法来向ACL添加新的ACL条目。
Public methods |
|
|---|---|
abstract boolean |
addEntry(Principal caller, AclEntry entry) 将ACL条目添加到此ACL。 |
abstract boolean |
checkPermission(Principal principal, Permission permission) 检查指定的委托人是否具有指定的权限。 |
abstract Enumeration<AclEntry> |
entries() 返回此ACL中条目的枚举。 |
abstract String |
getName() 返回此ACL的名称。 |
abstract Enumeration<Permission> |
getPermissions(Principal user) 返回指定主体(代表个体或组等实体)的允许权限集合的枚举。 |
abstract boolean |
removeEntry(Principal caller, AclEntry entry) 从该ACL中删除ACL条目。 |
abstract void |
setName(Principal caller, String name) 设置此ACL的名称。 |
abstract String |
toString() 返回ACL内容的字符串表示形式。 |
Inherited methods |
|
|---|---|
java.security.acl.Owner
|
|
boolean addEntry (Principal caller, AclEntry entry)
将ACL条目添加到此ACL。 一个条目将委托人(例如,个人或团体)与一组权限相关联。 每个主体最多可以有一个肯定的ACL条目(指定授予主体的权限)和一个否定ACL条目(指定拒绝权限)。 如果ACL中已经有相同类型的ACL条目(负值或正值),则返回false。
| Parameters | |
|---|---|
caller |
Principal: the principal invoking this method. It must be an owner of this ACL. |
entry |
AclEntry: the ACL entry to be added to this ACL. |
| Returns | |
|---|---|
boolean |
true on success, false if an entry of the same type (positive or negative) for the same principal is already present in this ACL. |
| Throws | |
|---|---|
NotOwnerException |
if the caller principal is not an owner of this ACL. |
boolean checkPermission (Principal principal, Permission permission)
检查指定的委托人是否具有指定的权限。 如果是,则返回true,否则返回false。 更具体地说,该方法检查传递的权限是否是指定主体的允许权限集的成员。 允许的权限集由与getPermissions方法所使用的算法相同的算法确定。
| Parameters | |
|---|---|
principal |
Principal: the principal, assumed to be a valid authenticated Principal. |
permission |
Permission: the permission to be checked for. |
| Returns | |
|---|---|
boolean |
true if the principal has the specified permission, false otherwise. |
也可以看看:
Enumeration<AclEntry> entries ()
返回此ACL中条目的枚举。 枚举中的每个元素都是AclEntry类型。
| Returns | |
|---|---|
Enumeration<AclEntry> |
an enumeration of the entries in this ACL. |
String getName ()
返回此ACL的名称。
| Returns | |
|---|---|
String |
the name of this ACL. |
也可以看看:
Enumeration<Permission> getPermissions (Principal user)
返回指定主体(代表个体或组等实体)的允许权限集合的枚举。 这组允许的权限计算如下:
个人正面和负面的权限集也被确定。 肯定权限集包含主体的肯定ACL条目(如果有)中指定的权限。 同样,否定权限集包含主体的否定ACL条目(如果有)中指定的权限。 如果此ACL中的主体不存在正(负)ACL条目,则单个正(或负)权限集将被视为空。
然后使用简单的规则计算授予主体的权限集,即单个权限始终覆盖组权限。 也就是说,委托人的个人否定权限集(特定拒绝权限)会覆盖组的正面权限集,而委托人的个人肯定权限集会覆盖组负面权限集。
| Parameters | |
|---|---|
user |
Principal: the principal whose permission set is to be returned. |
| Returns | |
|---|---|
Enumeration<Permission> |
the permission set specifying the permissions the principal is allowed. |
boolean removeEntry (Principal caller, AclEntry entry)
从该ACL中删除ACL条目。
| Parameters | |
|---|---|
caller |
Principal: the principal invoking this method. It must be an owner of this ACL. |
entry |
AclEntry: the ACL entry to be removed from this ACL. |
| Returns | |
|---|---|
boolean |
true on success, false if the entry is not part of this ACL. |
| Throws | |
|---|---|
NotOwnerException |
if the caller principal is not an owner of this Acl. |
void setName (Principal caller, String name)
设置此ACL的名称。
| Parameters | |
|---|---|
caller |
Principal: the principal invoking this method. It must be an owner of this ACL. |
name |
String: the name to be given to this ACL. |
| Throws | |
|---|---|
NotOwnerException |
if the caller principal is not an owner of this ACL. |
也可以看看:
String toString ()
返回ACL内容的字符串表示形式。
| Returns | |
|---|---|
String |
a string representation of the ACL contents. |