Package org.exist.security

Examples of org.exist.security.PermissionDeniedException


      for(int i = 0; i < ql.length; i++) {
        final StoredNode node = ql[i];
        final DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
        doc.getMetadata().setIndexListener(listener);
        if (!doc.getPermissions().validate(broker.getSubject(), Permission.WRITE)) {
          throw new PermissionDeniedException("User '" + broker.getSubject().getName() + "' does not have permission to write to the document '" + doc.getDocumentURI() + "'!");
                                }
                node.appendChildren(transaction, children, child);
                doc.getMetadata().clearIndexListener();
                doc.getMetadata().setLastModified(System.currentTimeMillis());
                modifiedDocuments.add(doc);
View Full Code Here


                    continue;
                }
                final DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
                doc.getMetadata().setIndexListener(listener);
                if (!doc.getPermissions().validate(broker.getSubject(), Permission.WRITE)) {
                        throw new PermissionDeniedException("User '" + broker.getSubject().getName() + "' does not have permission to write to the document '" + doc.getDocumentURI() + "'!");
                }
                parent = (ElementImpl) node.getParentStoredNode();
                if (parent == null)
                    {throw new EXistException("The root element of a document can not be replaced with 'xu:replace'. " +
                        "Please consider removing the document or use 'xu:update' to just replace the children of the root.");}
View Full Code Here

            for (int i = 0; i < ql.length; i++) {
                final StoredNode node = ql[i];
                final DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
                doc.getMetadata().setIndexListener(listener);
                if (!doc.getPermissions().validate(broker.getSubject(), Permission.WRITE)) {
                        throw new PermissionDeniedException("permission to update document denied");
                }
                parent = (NodeImpl) node.getParentNode();
                switch (mode) {
                    case INSERT_BEFORE:
                        parent.insertBefore(transaction, children, node);
View Full Code Here

            final String newName = children.item(0).getNodeValue();
            for (int i = 0; i < ql.length; i++) {
                final StoredNode node = ql[i];
                final DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
                if (!doc.getPermissions().validate(broker.getSubject(), Permission.WRITE)) {
                        throw new PermissionDeniedException("User '" + broker.getSubject().getName() + "' does not have permission to write to the document '" + doc.getDocumentURI() + "'!");
                }
                doc.getMetadata().setIndexListener(listener);
                parent = (NodeImpl) node.getParentNode();
                switch (node.getNodeType()) {
                    case Node.ELEMENT_NODE:
View Full Code Here

            if (collection == null) {
                LOG.debug("collection " + docUri.removeLastSegment() + " not found!");
                return null;
            }
            if(!collection.getPermissionsNoLock().validate(user, Permission.READ)) {
                throw new PermissionDeniedException("Insufficient privileges to read resource");
            }
            doc = collection.getDocumentWithLock(broker, docUri.lastSegment(), Lock.READ_LOCK);
            if (doc == null) {
                LOG.debug("document " + docUri + " not found!");
                throw new EXistException("document not found");
            }
           
            if(!doc.getPermissions().validate(user, Permission.READ))
                {throw new PermissionDeniedException("Insufficient privileges to read resource " + docUri);}
            final Serializer serializer = broker.getSerializer();
            serializer.setProperties(parametri);
            final String xml = serializer.serialize(doc);
           
            return xml;
View Full Code Here

            if(doc.getResourceType() != DocumentImpl.BINARY_FILE) {
                throw new EXistException("Document " + name + " is not a binary resource");
            }
           
            if(!doc.getPermissions().validate(user, requiredPermissions)) {
                throw new PermissionDeniedException("Insufficient privileges to access resource");
            }
           
            try {
                final InputStream is = broker.getBinaryResource((BinaryDocument)doc);
    final long resourceSize = broker.getBinaryResourceSize((BinaryDocument)doc);
View Full Code Here

            broker = factory.getBrokerPool().get(user);
            collection = broker.openCollection(collUri, Lock.READ_LOCK);
            if (collection == null)
                {throw new EXistException("Collection " + collUri + " not found");}
            if (!collection.getPermissionsNoLock().validate(user, Permission.READ))
                {throw new PermissionDeniedException(
                        "not allowed to read collection " + collUri);}
            final HashMap<String, List<Object>> result = new HashMap<String, List<Object>>(collection.getDocumentCount(broker));

            for (final Iterator<DocumentImpl> i = collection.iterator(broker); i.hasNext(); ) {
              final DocumentImpl doc = i.next();
View Full Code Here

            broker = factory.getBrokerPool().get(user);
            collection = broker.openCollection(collUri, Lock.READ_LOCK);
            if (collection == null)
                {throw new EXistException("Collection " + collUri + " not found");}
            if (!collection.getPermissionsNoLock().validate(user, Permission.READ))
                {throw new PermissionDeniedException("not allowed to read collection " + collUri);}
            final HashMap<XmldbURI, List<Object>> result = new HashMap<XmldbURI, List<Object>>(collection.getChildCollectionCount(broker));
            for (final Iterator<XmldbURI> i = collection.collectionIterator(broker); i.hasNext(); ) {
              final XmldbURI child = i.next();
              final XmldbURI path = collUri.append(child);
                final Collection childColl = broker.getCollection(path);
View Full Code Here

              if (overwrite == 0) {
                  final DocumentImpl old = collection.getDocument(broker, docUri.lastSegment());
                  //TODO : register the lock within the transaction ?
                  if (old != null) {
                      transact.abort(transaction);
                      throw new PermissionDeniedException("Document exists and overwrite is not allowed");
                  }
              }
             
              final InputStream is = new ByteArrayInputStream(xml);
              source = new InputSource(is);
View Full Code Here

          if (overwrite == 0) {
            final DocumentImpl old = collection.getDocument(broker, docUri.lastSegment());
            if (old != null) {
              transact.abort(transaction);
              throw new PermissionDeniedException("Old document exists and overwrite is not allowed");
            }
          }

          //XML
          if(treatAsXML) {
View Full Code Here

TOP

Related Classes of org.exist.security.PermissionDeniedException

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.