Package org.exist.xmldb

Examples of org.exist.xmldb.UserManagementService


    }

    @Test
    public void canExecuteXQueryWithOnlyExecutePermissionOnParentCollection() throws XMLDBException{
        Collection test = DatabaseManager.getCollection(baseUri + "/db/securityTest1", "test1", "test1");
        final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");

        final String xquery = "<xquery>{ 1 + 1 }</xquery>";
        Resource xqueryResource = test.createResource("test.xquery", BinaryResource.RESOURCE_TYPE);
        xqueryResource.setContent(xquery);
        test.storeResource(xqueryResource);

        ums.chmod("--x------");
        ums.chmod(xqueryResource, "rwx------"); //set execute bit on xquery (its off by default!)
        test.close();

        test = DatabaseManager.getCollection(baseUri + "/db/securityTest1", "test1", "test1");

        xqueryResource = test.getResource("test.xquery");
View Full Code Here


     * messages from 08/02/2012
     */
    @Test
    public void canExecuteXQueryWithOnlyExecuteAndReadPermission() throws XMLDBException{
        Collection test = DatabaseManager.getCollection(baseUri + "/db/securityTest1", "test1", "test1");
        final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");

        final String xquery = "<xquery>{ 1 + 2 }</xquery>";
        Resource xqueryResource = test.createResource("test.xquery", BinaryResource.RESOURCE_TYPE);
        xqueryResource.setContent(xquery);
        test.storeResource(xqueryResource);

        ums.chmod(xqueryResource, "r-x------"); //execute only on xquery
        test.close();

        test = DatabaseManager.getCollection(baseUri + "/db/securityTest1", "test1", "test1");

        xqueryResource = test.getResource("test.xquery");
View Full Code Here

    }

    @Test(expected=XMLDBException.class)
    public void cannotExecuteXQueryWithoutExecutePermission() throws XMLDBException{
        Collection test = DatabaseManager.getCollection(baseUri + "/db/securityTest1", "test1", "test1");
        final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");

        final String xquery = "<xquery>{ 1 + 2 }</xquery>";
        Resource xqueryResource = test.createResource("test.xquery", BinaryResource.RESOURCE_TYPE);
        xqueryResource.setContent(xquery);
        test.storeResource(xqueryResource);

        ums.chmod(xqueryResource, "rw-------"); //execute only on xquery
        test.close();

        test = DatabaseManager.getCollection(baseUri + "/db/securityTest1", "test1", "test1");

        xqueryResource = test.getResource("test.xquery");
View Full Code Here

        resSource.setContent("<test/>");
        source.storeResource(resSource);
       
        //pre-create the destination and set writable by all
        final Collection dest = cms.createCollection("copy-of-source");
        final UserManagementService ums = (UserManagementService)dest.getService("UserManagementService", "1.0");
        ums.chmod(0777);

       
        //as the 'test3' user copy the collection
        test = DatabaseManager.getCollection(baseUri + "/db/securityTest3", "test3", "test3");
        cms = (CollectionManagementServiceImpl) test.getService("CollectionManagementService", "1.0");
View Full Code Here

        resSource.setContent("<test2/>");
        source.storeResource(resSource);
       
        //pre-create the destination and set writable by all
        final Collection dest = cms.createCollection("copy-of-source");
        UserManagementService ums = (UserManagementService) dest.getService("UserManagementService", "1.0");
        ums.chmod(0777);
       
        //pre-create a destination resource and set no access to group and others
        Resource resDestSource1 = dest.createResource("source1.xml", XMLResource.RESOURCE_TYPE);
        resDestSource1.setContent("<old/>");
        dest.storeResource(resDestSource1);
        ums.chmod(resDestSource1, 0700);
       
       
        //as the 'test3' user copy the collection
        test = DatabaseManager.getCollection(baseUri + "/db/securityTest3", "test3", "test3");
        cms = (CollectionManagementServiceImpl) test.getService("CollectionManagementService", "1.0");
View Full Code Here

        //as the 'test3' user copy the resource
        test = DatabaseManager.getCollection(baseUri + "/db/securityTest3", "test3", "test3");
        cms = (CollectionManagementServiceImpl) test.getService("CollectionManagementService", "1.0");
        cms.copyResource("/db/securityTest3/source.xml", "/db/securityTest3", "copy-of-source.xml");

        final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
        final Permission permissions = ums.getPermissions(test.getResource("copy-of-source.xml"));

        //resource should be owned by test3:guest, i.e. permissions were not preserved from the test1 users doc /db/securityTest3/source.xml
        assertEquals("test3", permissions.getOwner().getName());
        assertEquals("guest", permissions.getGroup().getName());
    }
View Full Code Here

       
        //pre-create the dest resource (before the copy) and set writable by all
        final Resource resDest = test.createResource("copy-of-source.xml", XMLResource.RESOURCE_TYPE);
        resDest.setContent("<old/>");
        test.storeResource(resDest);
        UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
        ums.chmod(resDest, 0777);

       
        //as the 'test3' user copy the resource
        test = DatabaseManager.getCollection(baseUri + "/db/securityTest3", "test3", "test3");
        cms = (CollectionManagementServiceImpl) test.getService("CollectionManagementService", "1.0");
        cms.copyResource("/db/securityTest3/source.xml", "/db/securityTest3", "copy-of-source.xml");

        //as test3 user!
        ums = (UserManagementService) test.getService("UserManagementService", "1.0");
        final Permission permissions = ums.getPermissions(test.getResource("copy-of-source.xml"));

        //resource should be owned by test3:guest, i.e. permissions were not preserved from the test1 users doc /db/securityTest3/source.xml
        assertEquals("test1", permissions.getOwner().getName());
        assertEquals("users", permissions.getGroup().getName());
       
View Full Code Here

        test = DatabaseManager.getCollection(baseUri + "/db/securityTest3", "test3", "test3");
        cms = (CollectionManagementServiceImpl) test.getService("CollectionManagementService", "1.0");
        cms.copy("/db/securityTest3/source", "/db/securityTest3", "copy-of-source");


        final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
        final Permission permissions = ums.getPermissions(test.getChildCollection("copy-of-source"));

        //collection should be owned by test3:guest, i.e. permissions were not preserved from the test1 users collection /db/securityTest3/source
        assertEquals("test3", permissions.getOwner().getName());
        assertEquals("guest", permissions.getGroup().getName());
    }
View Full Code Here

        //create collection owned by "test1", and group "users" in /db/securityTest3
        Collection source = cms.createCollection("source");
       
        //pre-create the dest collection and grant access to all (0777)
        Collection dest = cms.createCollection("copy-of-source");
        UserManagementService ums = (UserManagementService)dest.getService("UserManagementService", "1.0");
        ums.chmod(0777);

        //as the 'test3' user copy the collection
        test = DatabaseManager.getCollection(baseUri + "/db/securityTest3", "test3", "test3");
        cms = (CollectionManagementServiceImpl) test.getService("CollectionManagementService", "1.0");
        cms.copy("/db/securityTest3/source", "/db/securityTest3", "copy-of-source");

        //re-get ums as 'test3' user
        ums = (UserManagementService) test.getService("UserManagementService", "1.0");
        final Permission permissions = ums.getPermissions(test.getChildCollection("copy-of-source"));

        //collection should STILL be owned by test1:users, i.e. permissions were preserved from the test1 users collection /db/securityTest3/copy-of-source
        assertEquals("test1", permissions.getOwner().getName());
        assertEquals("users", permissions.getGroup().getName());
    }
View Full Code Here

        test = DatabaseManager.getCollection(baseUri + "/db/securityTest3", "test3", "test3");
        cms = (CollectionManagementServiceImpl) test.getService("CollectionManagementService", "1.0");
        cms.copy("/db/securityTest3/source", "/db/securityTest3", "copy-of-source");


        UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
        final Collection copyOfSource = test.getChildCollection("copy-of-source");
        Permission permissions = ums.getPermissions(copyOfSource);

        //collection should be owned by test3:guest, i.e. permissions were not preserved from the test1 users doc /db/securityTest3/source
        assertEquals("test3", permissions.getOwner().getName());
        assertEquals("guest", permissions.getGroup().getName());

        ums = (UserManagementService) copyOfSource.getService("UserManagementService", "1.0");
        final Resource resCopyOfSource = copyOfSource.getResource("source.xml");
        permissions = ums.getPermissions(resCopyOfSource);

        //resource in collection should be owned by test3:guest, i.e. permissions were not preserved from the test1 users doc /db/securityTest3/source.xml
        assertEquals("test3", permissions.getOwner().getName());
        assertEquals("guest", permissions.getGroup().getName());
    }
View Full Code Here

TOP

Related Classes of org.exist.xmldb.UserManagementService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.