IAclFileAttributeView 介面
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
支援讀取或更新檔案 存取控制 清單 (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
- 屬性
- 實作
備註
支援讀取或更新檔案 存取控制 清單 (ACL) 或檔案擁有者屬性的檔案屬性檢視。
ACL 可用來指定檔案系統對象的訪問許可權。 ACL 是 的已排序列表,每個清單 AclEntry access-control-entries都會指定 UserPrincipal 和 該用戶主體的存取層級。 這個檔案屬性檢視會#getAcl() getAcl根據 RFC 中指定的 ACL 模型定義 讀取和寫入 ACL 的 和 #setAcl(List) setAcl 方法;3530:網路文件系統 (NFS) 第4版通訊協定http://www.ietf.org/rfc/rfc3530.txt。 這個檔案屬性檢視適用於支援 NFSv4 ACL 模型的文件系統實作,或具有 <NFSv4 ACL 模型與文件系統所使用的 ACL 模型之間的 em> 定義良好</em> 對應。 這類對應的詳細數據相依於實作,因此未指定。
這個類別也會擴充 FileOwnerAttributeView ,以便定義方法來取得和設定檔案擁有者。
當檔案系統提供一組 FileStore file-systems 非同質的存取權時,只有某些文件系統可能支援 ACL。 FileStore#supportsFileAttributeView supportsFileAttributeView方法可用來測試檔系統是否支援 ACL。
<h2>互操作性</h2>
RFC 3530 允許在支援POSIX定義訪問許可權的平臺上使用特殊使用者身分識別。 特殊使用者身分識別為 “OWNER@ ”“、”“GROUP@ 和 ”EVERYONE@“。 AclFileAttributeView支援 和 時,PosixFileAttributeView這些特殊使用者身分識別可能會包含在讀取或寫入的 ACL AclEntry entries 中。 文件系統 UserPrincipalLookupService 的 可用來取得 UserPrincipal ,藉由 UserPrincipalLookupService#lookupPrincipalByName lookupPrincipalByName 叫用 方法來表示這些特殊身分識別。
<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<>數據表類別=“striped”<>caption style=“display:none”>Supported attributes</caption><thead<>tr th scope=“col” Name </th scope=“col”>> Type </th<>></tr></thead<>tbody><tr<><>th scope=“row”> “acl” </th><td>List<UserPrincipal<>/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以及 FileAttribute#value value 物件清單AclEntry的 。
其中實作支援與 NFSv4 定義的 ACL 模型不同的 ACL 模型,然後在建立檔案時設定初始 ACL 時,必須將 ACL 轉譯為檔案系統支援的模型。 建立檔案的方法應該拒絕 ( IOException IOException擲回 )任何建立因翻譯而較不安全的檔案嘗試。
已在1.7中新增。
的 java.nio.file.attribute.AclFileAttributeViewJava 檔。
此頁面的部分是根據 Android 開放原始碼專案所建立和共用的工作進行修改,並根據 Creative Commons 2.5 屬性授權中所述的詞彙使用。
屬性
| Acl |
支援讀取或更新檔案 存取控制 清單 (ACL) 或檔案擁有者屬性的檔案屬性檢視。 |
| Handle |
取得基礎 Android 物件的 JNI 值。 (繼承來源 IJavaObject) |
| JniIdentityHashCode |
傳回包裝實例的 值 |
| JniManagedPeerState |
受控對等的狀態。 (繼承來源 IJavaPeerable) |
| JniPeerMembers |
成員存取和調用支援。 (繼承來源 IJavaPeerable) |
| Owner |
支援讀取或更新檔案 存取控制 清單 (ACL) 或檔案擁有者屬性的檔案屬性檢視。 (繼承來源 IFileOwnerAttributeView) |
| PeerReference |
傳 JniObjectReference 回已包裝 Java 物件實例的 。 (繼承來源 IJavaPeerable) |
方法
| Disposed() |
處置實例時呼叫。 (繼承來源 IJavaPeerable) |
| DisposeUnlessReferenced() |
如果這個實例沒有未完成的參考,則呼叫 |
| Finalized() |
實例完成時呼叫。 (繼承來源 IJavaPeerable) |
| Name() |
傳回屬性檢視的名稱。 |
| SetJniIdentityHashCode(Int32) |
設定所 |
| SetJniManagedPeerState(JniManagedPeerStates) |
支援讀取或更新檔案 存取控制 清單 (ACL) 或檔案擁有者屬性的檔案屬性檢視。 (繼承來源 IJavaPeerable) |
| SetPeerReference(JniObjectReference) |
設定所 |
| UnregisterFromRuntime() |
取消註冊此實例,讓運行時間不會從未來的 Java.Interop.JniRuntime+JniValueManager.PeekValue 調用傳回它。 (繼承來源 IJavaPeerable) |
擴充方法
| JavaCast<TResult>(IJavaObject) |
執行 Android 執行時間檢查的類型轉換。 |
| JavaCast<TResult>(IJavaObject) |
支援讀取或更新檔案 存取控制 清單 (ACL) 或檔案擁有者屬性的檔案屬性檢視。 |
| GetJniTypeName(IJavaPeerable) |
支援讀取或更新檔案 存取控制 清單 (ACL) 或檔案擁有者屬性的檔案屬性檢視。 |