Package org.exist.security

Examples of org.exist.security.Subject


        final NativeBroker broker = EasyMock.createMockBuilder(NativeBroker.class)
                .addMockedMethod("getCollection")
                .addMockedMethod("getSubject")
                .createStrictMock();

        final Subject subject = EasyMock.createStrictMock(Subject.class);


        //grant EXECUTE and READ permissions on the src
        expect(srcCollection.getPermissionsNoLock()).andReturn(srcPermissions);
        expect(broker.getSubject()).andReturn(subject);
        expect(srcPermissions.validate(subject, Permission.EXECUTE | Permission.READ)).andReturn(true);

        //grant EXECUTE and WRITE permission on the dest
        expect(broker.getCollection(dest)).andReturn(destCollection);
        final Capture<XmldbURI> newDestURICapture = new Capture<XmldbURI>();
        expect(broker.getCollection(capture(newDestURICapture))).andReturn(newDestCollection);
        expect(destCollection.getPermissionsNoLock()).andReturn(destPermissions);
        expect(broker.getSubject()).andReturn(subject);
        expect(destPermissions.validate(subject, Permission.EXECUTE | Permission.WRITE)).andReturn(false);

        //expectations for exception that should be thrown
        expect(srcCollection.getURI()).andReturn(src);
        expect(destCollection.getURI()).andReturn(dest);
        expect(broker.getSubject()).andReturn(subject);
        expect(subject.getName()).andReturn("Fake user");

        //test below
        replay(subject, destCollection, destPermissions, srcCollection, srcPermissions, broker);

        //run the test
View Full Code Here


        final NativeBroker broker = EasyMock.createMockBuilder(NativeBroker.class)
                .addMockedMethod("getCollection")
                .addMockedMethod("getSubject")
                .createStrictMock();

        final Subject subject = EasyMock.createStrictMock(Subject.class);

        //grant EXECUTE and READ permissions on the src
        expect(srcCollection.getPermissionsNoLock()).andReturn(srcPermissions);
        expect(broker.getSubject()).andReturn(subject);
        expect(srcPermissions.validate(subject, Permission.EXECUTE | Permission.READ)).andReturn(true);
View Full Code Here

        final NativeBroker broker = EasyMock.createMockBuilder(NativeBroker.class)
                .addMockedMethod("getCollection")
                .addMockedMethod("getSubject")
                .createStrictMock();

        final Subject subject = EasyMock.createStrictMock(Subject.class);

        //grant EXECUTE and READ permissions on the src
        expect(srcCollection.getPermissionsNoLock()).andReturn(srcPermissions);
        expect(broker.getSubject()).andReturn(subject);
        expect(srcPermissions.validate(subject, Permission.EXECUTE | Permission.READ)).andReturn(true);
View Full Code Here

        final NativeBroker broker = EasyMock.createMockBuilder(NativeBroker.class)
                .addMockedMethod("getCollection")
                .addMockedMethod("getSubject")
                .createStrictMock();

        final Subject subject = EasyMock.createStrictMock(Subject.class);

        //grant EXECUTE and READ permissions on the src
        expect(srcCollection.getPermissionsNoLock()).andReturn(srcPermissions);
        expect(broker.getSubject()).andReturn(subject);
        expect(srcPermissions.validate(subject, Permission.EXECUTE | Permission.READ)).andReturn(true);
View Full Code Here

        final NativeBroker broker = EasyMock.createMockBuilder(NativeBroker.class)
                .addMockedMethod("getCollection")
                .addMockedMethod("getSubject")
                .createStrictMock();

        final Subject subject = EasyMock.createStrictMock(Subject.class);

        //grant EXECUTE and READ permissions on the src
        expect(srcCollection.getPermissionsNoLock()).andReturn(srcPermissions);
        expect(broker.getSubject()).andReturn(subject);
        expect(srcPermissions.validate(subject, Permission.EXECUTE | Permission.READ)).andReturn(true);

        //grant EXECUTE and WRITE permission on the dest
        expect(broker.getCollection(dest)).andReturn(destCollection);
        final Capture<XmldbURI> newDestURICapture = new Capture<XmldbURI>();
        expect(broker.getCollection(capture(newDestURICapture))).andReturn(newDestCollection);
        expect(destCollection.getPermissionsNoLock()).andReturn(destPermissions);
        expect(broker.getSubject()).andReturn(subject);
        expect(destPermissions.validate(subject, Permission.EXECUTE | Permission.WRITE)).andReturn(false);

        //expectations for exception that should be thrown
        expect(srcCollection.getURI()).andReturn(src);
        expect(destCollection.getURI()).andReturn(dest);
        expect(broker.getSubject()).andReturn(subject);
        expect(subject.getName()).andReturn("Fake user");

        //no sub-documents
        expect(srcCollection.iterator(broker)).andReturn(new EmptyIterator<DocumentImpl>());

        //no sub-collections
View Full Code Here

        final NativeBroker broker = EasyMock.createMockBuilder(NativeBroker.class)
                .addMockedMethod("getCollection")
                .addMockedMethod("getSubject")
                .createStrictMock();

        final Subject subject = EasyMock.createStrictMock(Subject.class);

        //grant EXECUTE and READ permissions on the src
        expect(srcCollection.getPermissionsNoLock()).andReturn(srcPermissions);
        expect(broker.getSubject()).andReturn(subject);
        expect(srcPermissions.validate(subject, Permission.EXECUTE | Permission.READ)).andReturn(true);

        //grant EXECUTE and WRITE permission on the dest
        expect(broker.getCollection(dest)).andReturn(destCollection);
        final Capture<XmldbURI> newDestURICapture = new Capture<XmldbURI>();
        expect(broker.getCollection(capture(newDestURICapture))).andReturn(newDestCollection);
        expect(destCollection.getPermissionsNoLock()).andReturn(destPermissions);
        expect(broker.getSubject()).andReturn(subject);
        expect(destPermissions.validate(subject, Permission.EXECUTE | Permission.WRITE)).andReturn(true);
        expect(newDestCollection.getPermissionsNoLock()).andReturn(newDestPermissions);
        expect(broker.getSubject()).andReturn(subject);
        expect(newDestPermissions.validate(subject, Permission.EXECUTE | Permission.WRITE)).andReturn(false);

        //expectations for exception that should be thrown
        expect(srcCollection.getURI()).andReturn(src);
        expect(newDestCollection.getURI()).andReturn(dest.append(newName));
        expect(broker.getSubject()).andReturn(subject);
        expect(subject.getName()).andReturn("Fake user");

        //no sub-documents
        expect(srcCollection.iterator(broker)).andReturn(new EmptyIterator<DocumentImpl>());

        //no sub-collections
View Full Code Here

        final NativeBroker broker = EasyMock.createMockBuilder(NativeBroker.class)
                .addMockedMethod("getCollection")
                .addMockedMethod("getSubject")
                .createStrictMock();

        final Subject subject = EasyMock.createStrictMock(Subject.class);

        //grant EXECUTE and READ permissions on the src
        expect(srcCollection.getPermissionsNoLock()).andReturn(srcPermissions);
        expect(broker.getSubject()).andReturn(subject);
        expect(srcPermissions.validate(subject, Permission.EXECUTE | Permission.READ)).andReturn(true);
View Full Code Here

        final NativeBroker broker = EasyMock.createMockBuilder(NativeBroker.class)
                .addMockedMethod("getCollection")
                .addMockedMethod("getSubject")
                .createStrictMock();

        final Subject subject = EasyMock.createStrictMock(Subject.class);

        //grant EXECUTE and READ permissions on the src
        expect(srcCollection.getPermissionsNoLock()).andReturn(srcPermissions);
        expect(broker.getSubject()).andReturn(subject);
        expect(srcPermissions.validate(subject, Permission.EXECUTE | Permission.READ)).andReturn(true);

        //grant EXECUTE and WRITE permission on the dest
        expect(broker.getCollection(dest)).andReturn(destCollection);
        final Capture<XmldbURI> newDestURICapture = new Capture<XmldbURI>();
        expect(broker.getCollection(capture(newDestURICapture))).andReturn(newDestCollection);
        expect(destCollection.getPermissionsNoLock()).andReturn(destPermissions);
        expect(broker.getSubject()).andReturn(subject);
        expect(destPermissions.validate(subject, Permission.EXECUTE | Permission.WRITE)).andReturn(true);
        expect(newDestCollection.getPermissionsNoLock()).andReturn(newDestPermissions);
        expect(broker.getSubject()).andReturn(subject);
        expect(newDestPermissions.validate(subject, Permission.EXECUTE | Permission.WRITE)).andReturn(true);

        //one sub-document with READ permission
        expect(srcCollection.iterator(broker)).andReturn(new ArrayIterator<DocumentImpl>(srcSubDocument));
        expect(srcSubDocument.getPermissions()).andReturn(srcSubDocumentPermissions);
        expect(broker.getSubject()).andReturn(subject);
        expect(srcSubDocumentPermissions.validate(subject, Permission.READ)).andReturn(false);

        //expectations for exception that should be thrown
        expect(srcCollection.getURI()).andReturn(src);
        expect(srcSubDocument.getURI()).andReturn(src.append(newName).append("someSubDocument.xml"));
        expect(broker.getSubject()).andReturn(subject);
        expect(subject.getName()).andReturn("Fake user");

        //no sub-collections
        expect(srcCollection.collectionIterator(broker)).andReturn(new EmptyIterator<XmldbURI>());

        //test below
View Full Code Here

    public void finish(int event, DBBroker broker, Txn transaction, XmldbURI documentPath, DocumentImpl document) {

      if (documentPath == null || documentPath.startsWith(VERSIONS_COLLECTION))
        return;

      Subject activeSubject = broker.getSubject();

      try {
        broker.setSubject(broker.getBrokerPool().getSecurityManager().getSystemSubject());

        if (vDoc != null && !removeLast) {
View Full Code Here

        if (documentPath.startsWith(VERSIONS_COLLECTION))
            return;

        this.broker = broker;
        Subject activeSubject = broker.getSubject();

        try {
            broker.setSubject(broker.getBrokerPool().getSecurityManager().getSystemSubject());

            Collection collection = document.getCollection();
View Full Code Here

TOP

Related Classes of org.exist.security.Subject

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.