IAclFileAttributeView 接口
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
支持读取或更新文件访问控制 Lists (ACL) 或文件所有者属性的文件属性视图。
[Android.Runtime.Register("java/nio/file/attribute/AclFileAttributeView", "", "Java.Nio.FileNio.Attributes.IAclFileAttributeViewInvoker", ApiSince=26)]
public interface IAclFileAttributeView : IDisposable, Java.Interop.IJavaPeerable, Java.Nio.FileNio.Attributes.IFileOwnerAttributeView
[<Android.Runtime.Register("java/nio/file/attribute/AclFileAttributeView", "", "Java.Nio.FileNio.Attributes.IAclFileAttributeViewInvoker", ApiSince=26)>]
type IAclFileAttributeView = interface
interface IFileOwnerAttributeView
interface IFileAttributeView
interface IAttributeView
interface IJavaObject
interface IDisposable
interface IJavaPeerable
- 属性
- 实现
注解
支持读取或更新文件访问控制 Lists (ACL) 或文件所有者属性的文件属性视图。
ACL 用于指定对文件系统对象的访问权限。 ACL 是 的有序列表 AclEntry access-control-entries
,每个列表指定 UserPrincipal
以及该用户主体的访问级别。 此文件属性视图根据 RFC  中指定的 ACL 模型定义 #getAcl() getAcl
读取和写入 ACL 的 和 #setAcl(List) setAcl
方法 ;3530:网络文件系统 (NFS) 版本 4 协议http://www.ietf.org/rfc/rfc3530.txt。 此文件属性视图适用于支持 NFSv4 ACL 模型或在 NFSv4 ACL 模型与文件系统使用的 ACL 模型之间具有<>明确定义的</em> 映射的文件系统实现。 此类映射的详细信息依赖于实现,因此未指定。
此类还进行扩展 FileOwnerAttributeView
,以便定义获取和设置文件所有者的方法。
当文件系统提供对一组非同质的 FileStore file-systems
的访问时,只有某些文件系统可能支持 ACL。 方法 FileStore#supportsFileAttributeView supportsFileAttributeView
可用于测试文件系统是否支持 ACL。
<h2>互操作性</h2>
RFC 3530 允许在支持 POSIX 定义的访问权限的平台上使用特殊用户标识。 特殊用户标识为“OWNER@
”、“GROUP@
”和“EVERYONE@
”。 如果 同时 AclFileAttributeView
支持 和 , PosixFileAttributeView
则这些特殊用户标识可以包含在读取或写入的 ACL AclEntry entries
中。 文件系统的 UserPrincipalLookupService
可用于通过调用 UserPrincipalLookupService#lookupPrincipalByName lookupPrincipalByName
方法获取 UserPrincipal
来表示这些特殊标识。
<b>用法示例:</b> 假设我们希望向现有 ACL 添加一个条目,以授予“joe”访问权限:
// lookup "joe"
UserPrincipal joe = file.getFileSystem().getUserPrincipalLookupService()
.lookupPrincipalByName("joe");
// get view
AclFileAttributeView view = Files.getFileAttributeView(file, AclFileAttributeView.class);
// create ACE to give "joe" read access
AclEntry entry = AclEntry.newBuilder()
.setType(AclEntryType.ALLOW)
.setPrincipal(joe)
.setPermissions(AclEntryPermission.READ_DATA, AclEntryPermission.READ_ATTRIBUTES)
.build();
// read ACL, insert ACE, re-write ACL
List<AclEntry> acl = view.getAcl();
acl.add(0, entry); // insert before any DENY entries
view.setAcl(acl);
<h2> 动态访问 </h2>
如果需要对文件属性进行动态访问,则此属性视图支持的属性如下所示:<blockquote><table class=“striped”<>描述文字 style=“display:none”>Supported attributes</描述文字<>thead<>tr<>th scope=“col”> Name </th><th scope=“col”> Type </th<>/tr<>/thead<>tbody tr><><th scope=“row”> “acl” </th><td>List
<AclEntry
> </td></tr><th><scope=“row”> “owner” </th><td<UserPrincipal
>/td<>/tr></tbody<>/table></blockquote>
方法 Files#getAttribute getAttribute
可用于读取 ACL 或所有者属性,就像通过调用 #getAcl getAcl
或 #getOwner getOwner
方法一样。
方法 Files#setAttribute setAttribute
可用于更新 ACL 或所有者属性,就像通过调用 #setAcl setAcl
或 #setOwner setOwner
方法一样。
<h2> 在创建文件 </h2 时设置 ACL>
支持此属性视图的实现还可能支持在创建文件或目录时设置初始 ACL。 初始 ACL 可以提供给方法,例如 Files#createFile createFile
或 Files#createDirectory createDirectory
作为 FileAttribute
"acl:acl"
FileAttribute#name name
对象列表的 AclEntry
和 。FileAttribute#value value
如果实现支持不同于 NFSv4 定义的 ACL 模型的 ACL 模型,则在创建文件时设置初始 ACL 必须将 ACL 转换为文件系统支持的模型。 创建文件的方法应通过引发 IOException IOException
) 尝试创建因转换而不安全的文件而拒绝 (。
在 1.7 中添加。
的 java.nio.file.attribute.AclFileAttributeView
Java 文档。
此页面的部分内容是基于 创建和共享的工作进行的修改,并根据 署名许可中所述的术语使用。
属性
Acl |
支持读取或更新文件访问控制 Lists (ACL) 或文件所有者属性的文件属性视图。 |
Handle |
获取基础 Android 对象的 JNI 值。 (继承自 IJavaObject) |
JniIdentityHashCode |
返回包装实例的 的值 |
JniManagedPeerState |
托管对等方的状态。 (继承自 IJavaPeerable) |
JniPeerMembers |
成员访问和调用支持。 (继承自 IJavaPeerable) |
Owner |
支持读取或更新文件访问控制 Lists (ACL) 或文件所有者属性的文件属性视图。 (继承自 IFileOwnerAttributeView) |
PeerReference |
返回 JniObjectReference 包装的 Java 对象实例的 。 (继承自 IJavaPeerable) |
方法
Disposed() |
释放实例时调用。 (继承自 IJavaPeerable) |
DisposeUnlessReferenced() |
如果没有对此实例的未完成引用,则调用 |
Finalized() |
在实例完成时调用。 (继承自 IJavaPeerable) |
Name() |
返回属性视图的名称。 |
SetJniIdentityHashCode(Int32) |
设置 返回 |
SetJniManagedPeerState(JniManagedPeerStates) |
支持读取或更新文件访问控制 Lists (ACL) 或文件所有者属性的文件属性视图。 (继承自 IJavaPeerable) |
SetPeerReference(JniObjectReference) |
设置 返回 |
UnregisterFromRuntime() |
取消注册此实例,以便运行时不会从将来 Java.Interop.JniRuntime+JniValueManager.PeekValue 的调用中返回它。 (继承自 IJavaPeerable) |
扩展方法
JavaCast<TResult>(IJavaObject) |
执行 Android 运行时检查的类型转换。 |
JavaCast<TResult>(IJavaObject) |
支持读取或更新文件访问控制 Lists (ACL) 或文件所有者属性的文件属性视图。 |
GetJniTypeName(IJavaPeerable) |
支持读取或更新文件访问控制 Lists (ACL) 或文件所有者属性的文件属性视图。 |