rmischke-dlr commented on issue #282:
URL: https://github.com/apache/mina-sshd/issues/282#issuecomment-1341118430

   This is the test program for reproducing the above output:
   
   ```
   import java.io.IOException;
   import java.nio.file.Files;
   import java.nio.file.Path;
   import java.nio.file.Paths;
   import java.nio.file.attribute.AclEntry;
   import java.nio.file.attribute.AclFileAttributeView;
   import java.nio.file.attribute.UserPrincipal;
   import java.util.Objects;
   
   public class ACLTest {
   
       public static void main(String[] args) {
           Path path = Paths.get("dummy.dat");
           if (Files.exists(path)) {
               System.err.println("Test file " + path + " already exists - 
please delete it");
               System.exit(1);
           }
   
           try {
               Files.newOutputStream(path).close();
           } catch (IOException e) {
               e.printStackTrace();
               System.exit(1);
           }
           try {
               AclFileAttributeView view = Files.getFileAttributeView(path, 
AclFileAttributeView.class);
               UserPrincipal owner = Files.getOwner(path);
               Objects.requireNonNull(view, "Null AclFileAttributeView");
               Objects.requireNonNull(owner, "Null UserPrincipal");
               System.out.println("Owner: " + owner);
               for (AclEntry acl : view.getAcl()) {
                   System.out.println("ACL:");
                   System.out.println("  Principal:       " + acl.principal());
                   System.out.println("  Type:            " + acl.type());
                   System.out.println("  Permissions:     " + 
acl.permissions());
                   System.out.println("  Owner~Principal: " + 
owner.equals(acl.principal()));
               }
           } catch (IOException | SecurityException e) {
               e.printStackTrace();
           } finally {
               try {
                   Files.delete(path);
               } catch (IOException e) {
                   System.err.println("Failed to delete test file " + path + ": 
" + e.toString());
                   System.exit(1);
               }
           }
       }
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to