Skip to content

Instantly share code, notes, and snippets.

@courville
Created March 4, 2023 21:04
Show Gist options
  • Save courville/9c01a0654531adaa1530fbbba20c84d2 to your computer and use it in GitHub Desktop.
Save courville/9c01a0654531adaa1530fbbba20c84d2 to your computer and use it in GitHub Desktop.
sardine cli empty ACES
package org.courville.sardinetest;
import com.github.sardine.*;
import java.io.IOException;
import java.util.List;
public class Main {
public static void main(String[] args) {
// arguments are: user password url
Sardine sardine = SardineFactory.begin();
sardine.setCredentials(args[0], args[1]);
String url = args[2];
DavAcl acl;
try {
acl = sardine.getAcl(url);
System.out.println("fromUri owner=" + acl.getOwner() + ", group=" + acl.getGroup());
List<DavAce> aces = acl.getAces();
boolean canRead = false;
boolean canWrite = false;
if (! aces.isEmpty()) {
canRead = (aces.get(0).getGranted().get(0) == "read");
canWrite = (aces.get(0).getGranted().get(1) == "write");
} else {
System.out.println("fromUri: aces empty for uri=" + url);
}
System.out.println("fromUri: uri=" + url + ", canWrite=" + canWrite + ", canRead=" + canRead);
} catch (IOException e) {
System.out.println("IOException in getAcl");
}
//List<DavResource> resources = sardine.list(httpUri.toString());
}
}
@courville
Copy link
Author

courville commented Mar 4, 2023

Running the program I get empty ACES:

fromUri owner=null, group=null
fromUri: aces empty for uri=https://redacted/file.txt
fromUri: uri=https://redacted/file.txt, canWrite=false, canRead=false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment