Share via


IAclFileAttributeView 介面

定義

支援讀取或更新檔案 存取控制 清單 (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 可用來透過叫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&lt;AclEntry&gt; acl = view.getAcl();
                acl.add(0, entry);   // insert before any DENY entries
                view.setAcl(acl);

<h2> 動態存取 </h2>

需要動態存取檔案屬性時,此屬性檢視支援的屬性如下所示:<blockquote><數據表類別=“striped”<>標題 style=“display:none”>Supported attributes</標題<> thead<>tr><th scope=“col” Name </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 createFileFiles#createDirectory createDirectoryFileAttribute"acl:acl"FileAttribute#name name以及 FileAttribute#value value 物件清單的 。AclEntry

其中,實作支援與 NFSv4 定義的 ACL 模型不同的 ACL 模型,然後在建立檔案時設定初始 ACL,必須將 ACL 轉譯為文件系統所支援的模型。 建立檔案的方法應該藉由擲 IOException IOException 回) 任何嘗試建立因轉譯而較不安全的檔案,來拒絕 (。

已在1.7中新增。

java.nio.file.attribute.AclFileAttributeViewJava 檔。

此頁面的部分是根據 原始碼專案所建立和共用的工作進行修改,並根據 中所述的詞彙使用。

屬性

Acl

支援讀取或更新檔案 存取控制 清單 (ACL) 或檔案擁有者屬性的檔案屬性檢視。

Handle

取得基礎 Android 物件的 JNI 值。

(繼承來源 IJavaObject)
JniIdentityHashCode

傳回包裝實例的 java.lang.System.identityHashCode() 值。

(繼承來源 IJavaPeerable)
JniManagedPeerState

受控對等的狀態。

(繼承來源 IJavaPeerable)
JniPeerMembers

成員存取和調用支援。

(繼承來源 IJavaPeerable)
Owner

支援讀取或更新檔案 存取控制 清單 (ACL) 或檔案擁有者屬性的檔案屬性檢視。

(繼承來源 IFileOwnerAttributeView)
PeerReference

JniObjectReference 回已包裝 Java 物件實例的 。

(繼承來源 IJavaPeerable)

方法

Disposed()

在處置實例時呼叫。

(繼承來源 IJavaPeerable)
DisposeUnlessReferenced()

如果沒有這個實例的未完成參考,則呼叫 Dispose(),否則不會執行任何動作。

(繼承來源 IJavaPeerable)
Finalized()

實例完成時呼叫。

(繼承來源 IJavaPeerable)
Name()

傳回屬性檢視的名稱。

SetJniIdentityHashCode(Int32)

設定所 JniIdentityHashCode傳回的值。

(繼承來源 IJavaPeerable)
SetJniManagedPeerState(JniManagedPeerStates)

支援讀取或更新檔案 存取控制 清單 (ACL) 或檔案擁有者屬性的檔案屬性檢視。

(繼承來源 IJavaPeerable)
SetPeerReference(JniObjectReference)

設定所 PeerReference傳回的值。

(繼承來源 IJavaPeerable)
UnregisterFromRuntime()

取消註冊此實例,讓運行時間不會從未來的 Java.Interop.JniRuntime+JniValueManager.PeekValue 調用傳回它。

(繼承來源 IJavaPeerable)

擴充方法

JavaCast<TResult>(IJavaObject)

執行 Android 執行時間檢查的類型轉換。

JavaCast<TResult>(IJavaObject)

支援讀取或更新檔案 存取控制 清單 (ACL) 或檔案擁有者屬性的檔案屬性檢視。

GetJniTypeName(IJavaPeerable)

支援讀取或更新檔案 存取控制 清單 (ACL) 或檔案擁有者屬性的檔案屬性檢視。

適用於