Share via


IAclFileAttributeView Interface

Definition

A file attribute view that supports reading or updating a file's Access Control Lists (ACL) or file owner attributes.

[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
Attributes
Implements

Remarks

A file attribute view that supports reading or updating a file's Access Control Lists (ACL) or file owner attributes.

ACLs are used to specify access rights to file system objects. An ACL is an ordered list of AclEntry access-control-entries, each specifying a UserPrincipal and the level of access for that user principal. This file attribute view defines the #getAcl() getAcl, and #setAcl(List) setAcl methods to read and write ACLs based on the ACL model specified in RFC&nbsp;3530: Network File System (NFS) version 4 Protocolhttp://www.ietf.org/rfc/rfc3530.txt. This file attribute view is intended for file system implementations that support the NFSv4 ACL model or have a <em>well-defined</em> mapping between the NFSv4 ACL model and the ACL model used by the file system. The details of such mapping are implementation dependent and are therefore unspecified.

This class also extends FileOwnerAttributeView so as to define methods to get and set the file owner.

When a file system provides access to a set of FileStore file-systems that are not homogeneous then only some of the file systems may support ACLs. The FileStore#supportsFileAttributeView supportsFileAttributeView method can be used to test if a file system supports ACLs.

<h2>Interoperability</h2>

RFC&nbsp;3530 allows for special user identities to be used on platforms that support the POSIX defined access permissions. The special user identities are "OWNER@", "GROUP@", and "EVERYONE@". When both the AclFileAttributeView and the PosixFileAttributeView are supported then these special user identities may be included in ACL AclEntry entries that are read or written. The file system's UserPrincipalLookupService may be used to obtain a UserPrincipal to represent these special identities by invoking the UserPrincipalLookupService#lookupPrincipalByName lookupPrincipalByName method.

<b>Usage Example:</b> Suppose we wish to add an entry to an existing ACL to grant "joe" access:

// 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> Dynamic Access </h2>

Where dynamic access to file attributes is required, the attributes supported by this attribute view are as follows: <blockquote> <table class="striped"> <caption style="display:none">Supported attributes</caption> <thead> <tr> <th scope="col"> Name </th> <th scope="col"> Type </th> </tr> </thead> <tbody> <tr> <th scope="row"> "acl" </th> <td> List&lt;AclEntry&gt; </td> </tr> <tr> <th scope="row"> "owner" </th> <td> UserPrincipal</td> </tr> </tbody> </table> </blockquote>

The Files#getAttribute getAttribute method may be used to read the ACL or owner attributes as if by invoking the #getAcl getAcl or #getOwner getOwner methods.

The Files#setAttribute setAttribute method may be used to update the ACL or owner attributes as if by invoking the #setAcl setAcl or #setOwner setOwner methods.

<h2> Setting the ACL when creating a file </h2>

Implementations supporting this attribute view may also support setting the initial ACL when creating a file or directory. The initial ACL may be provided to methods such as Files#createFile createFile or Files#createDirectory createDirectory as an FileAttribute with FileAttribute#name name"acl:acl" and a FileAttribute#value value that is the list of AclEntry objects.

Where an implementation supports an ACL model that differs from the NFSv4 defined ACL model then setting the initial ACL when creating the file must translate the ACL to the model supported by the file system. Methods that create a file should reject (by throwing IOException IOException) any attempt to create a file that would be less secure as a result of the translation.

Added in 1.7.

Java documentation for java.nio.file.attribute.AclFileAttributeView.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Properties

Acl
Handle

Gets the JNI value of the underlying Android object.

(Inherited from IJavaObject)
JniIdentityHashCode

Returns the value of java.lang.System.identityHashCode() for the wrapped instance.

(Inherited from IJavaPeerable)
JniManagedPeerState

State of the managed peer.

(Inherited from IJavaPeerable)
JniPeerMembers

Member access and invocation support.

(Inherited from IJavaPeerable)
Owner (Inherited from IFileOwnerAttributeView)
PeerReference

Returns a JniObjectReference of the wrapped Java object instance.

(Inherited from IJavaPeerable)

Methods

Disposed()

Called when the instance has been disposed.

(Inherited from IJavaPeerable)
DisposeUnlessReferenced()

If there are no outstanding references to this instance, then calls Dispose(); otherwise, does nothing.

(Inherited from IJavaPeerable)
Finalized()

Called when the instance has been finalized.

(Inherited from IJavaPeerable)
Name()

Returns the name of the attribute view.

SetJniIdentityHashCode(Int32)

Set the value returned by JniIdentityHashCode.

(Inherited from IJavaPeerable)
SetJniManagedPeerState(JniManagedPeerStates) (Inherited from IJavaPeerable)
SetPeerReference(JniObjectReference)

Set the value returned by PeerReference.

(Inherited from IJavaPeerable)
UnregisterFromRuntime()

Unregister this instance so that the runtime will not return it from future Java.Interop.JniRuntime+JniValueManager.PeekValue invocations.

(Inherited from IJavaPeerable)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to