Created
March 4, 2023 21:04
-
-
Save courville/9c01a0654531adaa1530fbbba20c84d2 to your computer and use it in GitHub Desktop.
sardine cli empty ACES
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Running the program I get empty ACES: