use of org.exist.xmldb.UserManagementService in project exist by eXist-db.
the class XMLDBSecurityTest method dbaChownUidResource.
/**
* DBA can change the owner uid of a resource
*
* As the user 'admin' (who is a DBA) attempt to change the
* ownership uid of /db/securityTest1/test.xml
* to 'test2' user
*/
@Test
public void dbaChownUidResource() throws XMLDBException {
final Collection test = DatabaseManager.getCollection(getBaseUri() + "/db/securityTest1", "admin", "");
final Resource resource = test.getResource("test.xml");
final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
// attempt to change uid ownership of /db/securityTest1/test.xml to the test2 user
final Account test2 = ums.getAccount("test2");
ums.chown(resource, test2);
}
use of org.exist.xmldb.UserManagementService in project exist by eXist-db.
the class XMLDBSecurityTest method setGid_copyCollection_collectionGroupInheritedFromParent.
@Test
public void setGid_copyCollection_collectionGroupInheritedFromParent() throws XMLDBException {
Collection test = DatabaseManager.getCollection(getBaseUri() + "/db/securityTest2", "test1", "test1");
EXistCollectionManagementService cms = (EXistCollectionManagementService) test.getService("CollectionManagementService", "1.0");
UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
// create the /db/securityTest2/src collection with owner "test1:extusers" and default mode
Collection srcCollection = cms.createCollection("src");
ums = (UserManagementService) srcCollection.getService("UserManagementService", "1.0");
ums.chgrp("extusers");
// create /db/securityTest2/parentCollection with owner "test1:users" and mode "rwxrwsrwx"
Collection parentCollection = cms.createCollection("parentCollection");
ums = (UserManagementService) parentCollection.getService("UserManagementService", "1.0");
ums.chmod("rwxrwsrwx");
// now copy /db/securityTest2/src to /db/securityTest2/parentCollection/src
// as "user3:guest", it should inherit the group ownership 'users' from the parent
// collection which is setGid and it should have its setGid bit set
test = DatabaseManager.getCollection(getBaseUri() + "/db/securityTest2", "test3", "test3");
cms = (EXistCollectionManagementService) test.getService("CollectionManagementService", "1.0");
cms.copy("src", "/db/securityTest2/parentCollection", "src");
parentCollection = DatabaseManager.getCollection(getBaseUri() + "/db/securityTest2/parentCollection", "test3", "test3");
ums = (UserManagementService) parentCollection.getService("UserManagementService", "1.0");
final Collection destCollection = parentCollection.getChildCollection("src");
final Permission permissions = ums.getPermissions(destCollection);
assertEquals("users", permissions.getGroup().getName());
assertTrue(permissions.isSetGid());
}
use of org.exist.xmldb.UserManagementService in project exist by eXist-db.
the class XMLDBSecurityTest method worldChmodCollection.
// fails since guest has no write permissions
@Test(expected = XMLDBException.class)
public void worldChmodCollection() throws XMLDBException {
final Collection test = DatabaseManager.getCollection(getBaseUri() + "/db/securityTest1", "guest", "guest");
final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
// grant myself all rights ;-)
ums.chmod(0777);
}
use of org.exist.xmldb.UserManagementService in project exist by eXist-db.
the class XMLDBSecurityTest method onlyReadAndExecuteRequiredToListCollectionSubCollections.
@Test
public void onlyReadAndExecuteRequiredToListCollectionSubCollections() throws XMLDBException {
final Collection test = DatabaseManager.getCollection(getBaseUri() + "/db/securityTest1", "test1", "test1");
final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
ums.chmod("r-x------");
test.listChildCollections();
}
use of org.exist.xmldb.UserManagementService in project exist by eXist-db.
the class XMLDBSecurityTest method cannotOpenRootCollectionWithoutExecute.
@Test(expected = XMLDBException.class)
public void cannotOpenRootCollectionWithoutExecute() throws XMLDBException {
final Collection test = DatabaseManager.getCollection(getBaseUri() + "/db", "admin", "");
final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
ums.chmod("rw-rw-rw-");
test.close();
DatabaseManager.getCollection(getBaseUri() + "/db", "test1", "test1");
}
Aggregations