use of org.exist.security.internal.aider.ACEAider in project exist by eXist-db.
the class RemoteUserManagementService method listCollectionPermissions.
@Override
public Permission[] listCollectionPermissions() throws XMLDBException {
try {
final List<Object> params = new ArrayList<>();
params.add(collection.getPath());
final Map result = (Map) collection.execute("listCollectionPermissions", params);
final Permission[] perm = new Permission[result.size()];
final String[] collections = collection.listChildCollections();
Object[] t;
for (int i = 0; i < collections.length; i++) {
t = (Object[]) result.get(collections[i]);
final String owner = (String) t[0];
final String group = (String) t[1];
final int mode = (Integer) t[2];
final Stream<ACEAider> aces = extractAces(t[3]);
perm[i] = getPermission(owner, group, mode, aces);
}
return perm;
} catch (final PermissionDeniedException pde) {
throw new XMLDBException(ErrorCodes.PERMISSION_DENIED, pde.getMessage(), pde);
}
}
use of org.exist.security.internal.aider.ACEAider in project exist by eXist-db.
the class RemoteUserManagementService method getPermissions.
@Override
public Permission getPermissions(final Collection coll) throws XMLDBException {
if (coll == null) {
throw new XMLDBException(ErrorCodes.INVALID_COLLECTION, "collection is null");
}
try {
final List<Object> params = new ArrayList<>();
params.add(((RemoteCollection) coll).getPath());
final Map result = (Map) collection.execute("getPermissions", params);
final String owner = (String) result.get("owner");
final String group = (String) result.get("group");
final int mode = (Integer) result.get("permissions");
final Stream<ACEAider> aces = extractAces(result.get("acl"));
return getPermission(owner, group, mode, aces);
} catch (final PermissionDeniedException pde) {
throw new XMLDBException(ErrorCodes.PERMISSION_DENIED, pde.getMessage(), pde);
}
}
use of org.exist.security.internal.aider.ACEAider in project exist by eXist-db.
the class LocalUserManagementService method getAces.
private Optional<List<ACEAider>> getAces(@Nullable final Permission permission) {
final Optional<List<ACEAider>> maybeAces;
if (permission != null && permission instanceof ACLPermission) {
final ACLPermission aclPerm = (ACLPermission) permission;
final List<ACEAider> aces = new ArrayList<>(aclPerm.getACECount());
for (int i = 0; i < aclPerm.getACECount(); i++) {
aces.add(new ACEAider(aclPerm.getACEAccessType(i), aclPerm.getACETarget(i), aclPerm.getACEWho(i), aclPerm.getACEMode(i)));
}
maybeAces = Optional.of(aces);
} else {
maybeAces = Optional.empty();
}
return maybeAces;
}
Aggregations