src/share/classes/java/nio/file/attribute/AclFileAttributeView.java

Print this page




  68  * method. </p>
  69  *
  70  * <p> <b>Usage Example:</b>
  71  * Suppose we wish to add an entry to an existing ACL to grant "joe" access:
  72  * <pre>
  73  *     // lookup "joe"
  74  *     UserPrincipal joe = file.getFileSystem().getUserPrincipalLookupService()
  75  *         .lookupPrincipalByName("joe");
  76  *
  77  *     // get view
  78  *     AclFileAttributeView view = Files.getFileAttributeView(file, AclFileAttributeView.class);
  79  *
  80  *     // create ACE to give "joe" read access
  81  *     AclEntry entry = AclEntry.newBuilder()
  82  *         .setType(AclEntryType.ALLOW)
  83  *         .setPrincipal(joe)
  84  *         .setPermissions(AclEntryPermission.READ_DATA, AclEntryPermission.READ_ATTRIBUTES)
  85  *         .build();
  86  *
  87  *     // read ACL, insert ACE, re-write ACL
  88  *     List&lt;AclEntry&gt acl = view.getAcl();
  89  *     acl.add(0, entry);   // insert before any DENY entries
  90  *     view.setAcl(acl);
  91  * </pre>
  92  *
  93  * <h4> Dynamic Access </h4>
  94  * <p> Where dynamic access to file attributes is required, the attributes
  95  * supported by this attribute view are as follows:
  96  * <blockquote>
  97  * <table border="1" cellpadding="8">
  98  *   <tr>
  99  *     <th> Name </th>
 100  *     <th> Type </th>
 101  *   </tr>
 102  *   <tr>
 103  *     <td> "acl" </td>
 104  *     <td> {@link List}&lt;{@link AclEntry}&gt; </td>
 105  *   </tr>
 106  *   <tr>
 107  *     <td> "owner" </td>
 108  *     <td> {@link UserPrincipal} </td>




  68  * method. </p>
  69  *
  70  * <p> <b>Usage Example:</b>
  71  * Suppose we wish to add an entry to an existing ACL to grant "joe" access:
  72  * <pre>
  73  *     // lookup "joe"
  74  *     UserPrincipal joe = file.getFileSystem().getUserPrincipalLookupService()
  75  *         .lookupPrincipalByName("joe");
  76  *
  77  *     // get view
  78  *     AclFileAttributeView view = Files.getFileAttributeView(file, AclFileAttributeView.class);
  79  *
  80  *     // create ACE to give "joe" read access
  81  *     AclEntry entry = AclEntry.newBuilder()
  82  *         .setType(AclEntryType.ALLOW)
  83  *         .setPrincipal(joe)
  84  *         .setPermissions(AclEntryPermission.READ_DATA, AclEntryPermission.READ_ATTRIBUTES)
  85  *         .build();
  86  *
  87  *     // read ACL, insert ACE, re-write ACL
  88  *     List&lt;AclEntry&gt; acl = view.getAcl();
  89  *     acl.add(0, entry);   // insert before any DENY entries
  90  *     view.setAcl(acl);
  91  * </pre>
  92  *
  93  * <h4> Dynamic Access </h4>
  94  * <p> Where dynamic access to file attributes is required, the attributes
  95  * supported by this attribute view are as follows:
  96  * <blockquote>
  97  * <table border="1" cellpadding="8">
  98  *   <tr>
  99  *     <th> Name </th>
 100  *     <th> Type </th>
 101  *   </tr>
 102  *   <tr>
 103  *     <td> "acl" </td>
 104  *     <td> {@link List}&lt;{@link AclEntry}&gt; </td>
 105  *   </tr>
 106  *   <tr>
 107  *     <td> "owner" </td>
 108  *     <td> {@link UserPrincipal} </td>