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 該使用者主體的存取層級。 此檔案屬性檢視定義 #getAcl() getAcl了 ,以及 #setAcl(List) setAcl 根據 RFC 中指定的 ACL 模型來讀寫 ACL 的方法;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@」。 當 和 都AclFileAttributeViewPosixFileAttributeView支援時,這些特殊的使用者身份可能會被包含在 ACL AclEntry entries 中,並可被讀取或寫入。 檔案系統 UserPrincipalLookupService 的檔案可用來取得 a 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>
當需要動態存取檔案屬性時,此屬性檢視所支援的屬性如下:
Files#getAttribute getAttribute此方法可透過呼叫 #getAcl getAcl or #getOwner getOwner 方法來讀取 ACL 或擁有者屬性。
Files#setAttribute setAttribute此方法可用於更新 ACL 或擁有者屬性,就像呼叫 #setAcl setAcl or #setOwner setOwner 方法一樣。
<h2> 建立檔案 <時設定 ACL /h2>
支援此屬性檢視的實作,也可能支援在建立檔案或目錄時設定初始 ACL。 初始 ACL 可能提供給Files#createFile createFileFiles#createDirectory createDirectory方法,例如 或 ,FileAttribute其中 a FileAttribute#name name 是物件"acl:acl"FileAttribute#value value清單AclEntry。
若實作支援的 ACL 模型與 NFSv4 定義的 ACL 模型不同,則在建立檔案時設定初始 ACL,必須將 ACL 轉換成檔案系統支援的模型。 建立檔案的方法應拒絕(拋出 IOException IOException)任何因轉譯而安全性較低的檔案嘗試。
在 1.7 版本中加入。
Java 文件 java.nio.file.attribute.AclFileAttributeView。
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。
屬性
| 名稱 | Description |
|---|---|
| Acl |
取得或設定該檔案的存取控制清單。 |
| Handle |
取得底層 Android 物件的 JNI 值。 (繼承來源 IJavaObject) |
| JniIdentityHashCode |
回傳包裹實例的 |
| JniManagedPeerState |
管理貴族的狀況。 (繼承來源 IJavaPeerable) |
| JniObjectReferenceControlBlock |
一個支援讀取或更新檔案存取控制 Lists(ACL)或檔案擁有者屬性的檔案屬性檢視。 (繼承來源 IJavaPeerable) |
| JniPeerMembers |
成員存取與召喚支援。 (繼承來源 IJavaPeerable) |
| Owner |
取得或設定檔案擁有者。 (繼承來源 IFileOwnerAttributeView) |
| PeerReference |
回傳JniObjectReference包裹後的 Java 物件實例。 (繼承來源 IJavaPeerable) |
方法
| 名稱 | Description |
|---|---|
| Disposed() |
當實例被處理後才被召喚。 (繼承來源 IJavaPeerable) |
| DisposeUnlessReferenced() |
如果沒有未解決的參考資料,則 |
| Finalized() |
當實例完成後才會被通知。 (繼承來源 IJavaPeerable) |
| Name() |
回傳屬性檢視的名稱。 |
| SetJniIdentityHashCode(Int32) |
將回傳的值設為 |
| SetJniManagedPeerState(JniManagedPeerStates) |
一個支援讀取或更新檔案存取控制 Lists(ACL)或檔案擁有者屬性的檔案屬性檢視。 (繼承來源 IJavaPeerable) |
| SetPeerReference(JniObjectReference) |
將回傳的值設為 |
| UnregisterFromRuntime() |
取消註冊此實例,讓執行時不會在未來 Java.Interop.JniRuntime+JniValueManager.PeekValue 的呼叫中回傳該實例。 (繼承來源 IJavaPeerable) |
擴充方法
| 名稱 | Description |
|---|---|
| GetJniTypeName(IJavaPeerable) |
取得實例 |
| JavaAs<TResult>(IJavaPeerable) |
試著強制 |
| JavaCast<TResult>(IJavaObject) |
執行 Android 執行時檢查型別轉換。 |
| JavaCast<TResult>(IJavaObject) |
一個支援讀取或更新檔案存取控制 Lists(ACL)或檔案擁有者屬性的檔案屬性檢視。 |
| TryJavaCast<TResult>(IJavaPeerable, TResult) |
試著強制 |