use of org.exist.xmldb.UserManagementService in project exist by eXist-db.
the class XMLDBSecurityTest method ownerChownUidCollection.
/**
* Owner can NOT change the owner uid of a collection
*
* As the user 'test1' attempt to change the
* ownership uid of /db/securityTest1
* to 'test2' user
*/
@Test(expected = XMLDBException.class)
public void ownerChownUidCollection() throws XMLDBException {
final Collection test = DatabaseManager.getCollection(getBaseUri() + "/db/securityTest1", "test1", "test1");
final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
// attempt to change uid ownership of /db/securityTest1 to the test2 user
final Account test2 = ums.getAccount("test2");
ums.chown(test2);
}
use of org.exist.xmldb.UserManagementService in project exist by eXist-db.
the class XMLDBSecurityTest method cannotOpenCollectionWithoutExecute.
@Test(expected = XMLDBException.class)
public void cannotOpenCollectionWithoutExecute() throws XMLDBException {
final Collection test = DatabaseManager.getCollection(getBaseUri() + "/db/securityTest1", "test1", "test1");
final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
ums.chmod("rw-rw-rw-");
test.close();
DatabaseManager.getCollection(getBaseUri() + "/db/securityTest1", "test1", "test1");
}
use of org.exist.xmldb.UserManagementService in project exist by eXist-db.
the class XMLDBSecurityTest method canCreateXmlResourceWithOnlyExecuteAndWritePermissionOnParentCollection.
@Test
public void canCreateXmlResourceWithOnlyExecuteAndWritePermissionOnParentCollection() throws XMLDBException {
Collection test = DatabaseManager.getCollection(getBaseUri() + "/db/securityTest1", "test1", "test1");
final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
ums.chmod("-wx------");
test.close();
test = DatabaseManager.getCollection(getBaseUri() + "/db/securityTest1", "test1", "test1");
final Resource resource = test.createResource("other.xml", XMLResource.RESOURCE_TYPE);
resource.setContent("<other/>");
test.storeResource(resource);
}
use of org.exist.xmldb.UserManagementService in project exist by eXist-db.
the class XMLDBSecurityTest method canReadBinaryResourceWithOnlyReadPermission.
@Test
public void canReadBinaryResourceWithOnlyReadPermission() throws XMLDBException {
Collection test = DatabaseManager.getCollection(getBaseUri() + "/db/securityTest1", "test1", "test1");
final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
Resource resource = test.getResource("test.bin");
ums.chmod(resource, "r--------");
test.close();
test = DatabaseManager.getCollection(getBaseUri() + "/db/securityTest1", "test1", "test1");
resource = test.getResource("test.bin");
assertArrayEquals("binary-test".getBytes(), (byte[]) resource.getContent());
}
use of org.exist.xmldb.UserManagementService in project exist by eXist-db.
the class XMLDBSecurityTest method cannotReadBinaryResourceWithoutExecutePermissionOnParentCollection.
@Test(expected = XMLDBException.class)
public void cannotReadBinaryResourceWithoutExecutePermissionOnParentCollection() throws XMLDBException {
Collection test = DatabaseManager.getCollection(getBaseUri() + "/db/securityTest1", "test1", "test1");
final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
ums.chmod("rw-------");
test.close();
test = DatabaseManager.getCollection(getBaseUri() + "/db/securityTest1", "test1", "test1");
final Resource resource = test.getResource("test.bin");
assertArrayEquals("binary-test".getBytes(), (byte[]) resource.getContent());
}
Aggregations