Package org.exist.security

Examples of org.exist.security.Permission


      try {
      modifyMetadata(new ModifyMetadata() {

        @Override
        public void modify(DocumentImpl resource) throws IOException {
          Permission perm = resource.getPermissions();
          try {
                        perm.setMode(perm.getMode() | (READ << 6) & ~(WRITE << 6));
                    } catch (PermissionDeniedException e) {
                        throw new IOException(e);
                    }
        }

        @Override
        public void modify(Collection collection) throws IOException {
          Permission perm = collection.getPermissionsNoLock();
          try {
                        perm.setMode(perm.getMode() | (READ << 6) & ~(WRITE << 6));
                    } catch (PermissionDeniedException e) {
                        throw new IOException(e);
                    }
        }
       
View Full Code Here


      try {
      modifyMetadata(new ModifyMetadata() {

        @Override
        public void modify(DocumentImpl resource) throws IOException {
          Permission perm = resource.getPermissions();
          try {
                        perm.setMode(perm.getMode() | (EXECUTE << 6));
                    } catch (PermissionDeniedException e) {
                        throw new IOException(e);
                    }
        }

        @Override
        public void modify(Collection collection) throws IOException {
          Permission perm = collection.getPermissionsNoLock();
          try {
                        perm.setMode(perm.getMode() | (EXECUTE << 6));
                    } catch (PermissionDeniedException e) {
                        throw new IOException(e);
                    }
        }
       
View Full Code Here

        final String childCollections[] = current.listChildCollections();
        final String childResources[] = current.listResources();
       
        resources = new String[childCollections.length + childResources.length];
        //Collection child;
        Permission perm;
       
        final List<ResourceDescriptor> tableData = new ArrayList<ResourceDescriptor>(resources.length); // A list of ResourceDescriptor for the GUI
       
        final String cols[] = new String[4];
        int i = 0;
        for (; i < childCollections.length; i++) {
            //child = current.getChildCollection(childCollections[i]);
           
            perm = mgtService.getSubCollectionPermissions(current, childCollections[i]);
           
            if ("true".equals(properties.getProperty("permissions"))) {
                cols[0] = perm.toString();
              cols[1] = getOwnerName(perm);
              cols[2] = getGroupName(perm);
                cols[3] = URIUtils.urlDecodeUtf8(childCollections[i]);
                resources[i] = 'd' + formatString(cols, colSizes);
            } else {
                resources[i] = URIUtils.urlDecodeUtf8(childCollections[i]);
            }

            final Date created = mgtService.getSubCollectionCreationTime(current, childCollections[i]);

            if (startGUI) {
                tableData.add( new ResourceDescriptor.Collection(
                        XmldbURI.create(childCollections[i]),
                        getOwnerName(perm),
                        getGroupName(perm),
                        "c" + ((perm instanceof ACLPermission && ((ACLPermission)perm).getACECount() > 0) ? perm.toString() + '+' : perm.toString()),
                        created ) );
            }
            completitions.add(childCollections[i]);
        }
        Resource res;
        for (int j = 0; j < childResources.length; i++, j++) {
            res = current.getResource(childResources[j]);
            perm = mgtService.getPermissions(res);
            if (perm == null) {
                System.out.println("null"); //TODO this is not useful!
            }
            if ("true".equals(properties.getProperty("permissions"))) {
                resources[i] = '-' + perm.toString() + '\t' + perm.getOwner().getName()
                + '\t' + perm.getGroup().getName() + '\t'
                        + URIUtils.urlDecodeUtf8(childResources[j]);
            } else {
                resources[i] = URIUtils.urlDecodeUtf8(childResources[j]);
            }
           
            final Date lastModificationTime = ((EXistResource)res).getLastModificationTime();
            resources[i] += "\t" + lastModificationTime;
           
            if (startGUI) {
                tableData.add(new ResourceDescriptor.Document(
                        XmldbURI.create(childResources[j]),
                        getOwnerName(perm),
                        getGroupName(perm),
                        "-" + ((perm instanceof ACLPermission && ((ACLPermission)perm).getACECount() > 0) ? perm.toString() + '+' : perm.toString()),
                        lastModificationTime ) );
            }
            completitions.add(childResources[j]);
        }
        if (startGUI) {
View Full Code Here

              getTarget().getLock().acquire(Lock.WRITE_LOCK);

                final TransactionManager txnManager = broker.getDatabase().getTransactionManager();
                final Txn txn = txnManager.beginTransaction();
              try {
                    final Permission permission = getTarget().getPermissions();
                  permission.setOwner(getOwner());
                  permission.setGroup(getGroup());
                  permission.setMode(getMode());
                  if(permission instanceof ACLPermission) {
                      final ACLPermission aclPermission = (ACLPermission)permission;
                      aclPermission.clear();
                      for(final ACEAider ace : getAces()) {
                          aclPermission.addACE(ace.getAccessType(), ace.getTarget(), ace.getWho(), ace.getMode());
View Full Code Here

              final TransactionManager txnManager = broker.getDatabase().getTransactionManager();
                final Txn txn = txnManager.beginTransaction();

              try {
               
                final Permission permission = getTarget().getPermissions();
                  permission.setOwner(getOwner());
                  permission.setGroup(getGroup());
                  permission.setMode(getMode());
                  if(permission instanceof ACLPermission) {
                      final ACLPermission aclPermission = (ACLPermission)permission;
                      aclPermission.clear();
                      for(final ACEAider ace : getAces()) {
                          aclPermission.addACE(ace.getAccessType(), ace.getTarget(), ace.getWho(), ace.getMode());
View Full Code Here

    @Override
    public void apply() {
        try {
            final UserManagementService service = (UserManagementService)getTarget().getParentCollection().getService("UserManagementService", "1.0");
            final Permission permissions = service.getPermissions(getTarget());
            service.setPermissions(getTarget(), getOwner(), getGroup(), getMode(), getAces()); //persist
        } catch(final XMLDBException xe) {
            String name = "unknown";
            try { name = getTarget().getId(); } catch(final XMLDBException x) { LOG.error(x.getMessage(), x); }
            final String msg = "ERROR: Failed to set permissions on Document '" + name + "'.";
View Full Code Here

        final Txn txn = mgr.beginTransaction();
        try {
            final Collection collection = broker.getOrCreateCollection(txn, targetCollection);
            final XmldbURI name = XmldbURI.createInternal("repo.xml");
            final IndexInfo info = collection.validateXMLResource(txn, broker, name, updatedXML);
            final Permission permission = info.getDocument().getPermissions();
            setPermissions(false, MimeType.XML_TYPE, permission);

            collection.store(txn, broker, info, updatedXML, false);

            mgr.commit(txn);
View Full Code Here

                try {
                    if (mime.isXMLType()) {
                        final InputSource is = new InputSource(file.toURI().toASCIIString());
                        final IndexInfo info = targetCollection.validateXMLResource(txn, broker, name, is);
                        info.getDocument().getMetadata().setMimeType(mime.getName());
                        final Permission permission = info.getDocument().getPermissions();
                        setPermissions(false, mime, permission);

                        targetCollection.store(txn, broker, info, is, false);
                    } else {
                        final long size = file.length();
                        final FileInputStream is = new FileInputStream(file);
                        final BinaryDocument doc =
                                targetCollection.addBinaryResource(txn, broker, name, is, mime.getName(), size);
                        is.close();

                        final Permission permission = doc.getPermissions();
                        setPermissions(false, mime, permission);
                        doc.getMetadata().setMimeType(mime.getName());
                        broker.storeXMLResource(txn, doc);
                    }
                    mgr.commit(txn);
View Full Code Here

            if (fileman.getSelectedRowCount() == 1) {
                final int row = fileman.convertRowIndexToModel(fileman.getSelectedRow());
                final ResourceDescriptor desc = resources.getRow(row);
                name = desc.getName();
               
                final Permission perm;
                if (desc.isCollection()) {
                    final Collection coll = collection.getChildCollection(name.toString());
                    created = ((CollectionImpl) coll).getCreationTime();
                    perm = service.getPermissions(coll);
                } else {
                    final Resource res = collection.getResource(name.toString());
                    created = ((EXistResource) res).getCreationTime();
                    modified = ((EXistResource) res).getLastModificationTime();
                    mimeType = ((EXistResource) res).getMimeType();
                    perm = service.getPermissions(res);
                }
               
                //this is a local instance, we cannot use disconnected local instance in the ResourcePropertyDialog
                if(perm instanceof org.exist.security.Permission) {
                    permAider = PermissionAiderFactory.getPermission(perm.getOwner().getName(), perm.getGroup().getName(), perm.getMode());
                    //copy acl
                    if(perm instanceof ACLPermission && permAider instanceof ACLPermission) {
                        final ACLPermission aclPermission = (ACLPermission)perm;
                        for(int i = 0; i < aclPermission.getACECount(); i++) {
                            ((ACLPermission)permAider).addACE(aclPermission.getACEAccessType(i), aclPermission.getACETarget(i), aclPermission.getACEWho(i), aclPermission.getACEMode(i));
View Full Code Here

 
            CollectionManagementService cms = (CollectionManagementService) rootCollection.getService("CollectionManagementService", "1.0");
            Collection adminCollection = cms.createCollection(ADMIN_COLLECTION_NAME);
            UserManagementService ums = (UserManagementService) rootCollection.getService("UserManagementService", "1.0");
            if (ums != null) {
                Permission p = ums.getPermissions(adminCollection);
                p.setMode(Permission.USER_STRING + "=+read,+write," + Permission.GROUP_STRING + "=-read,-write," + Permission.OTHER_STRING + "=-read,-write");
                ums.setPermissions(adminCollection, p);

                Collection guestCollection = DatabaseManager.getCollection(URI + XmldbURI.ROOT_COLLECTION + "/" + ADMIN_COLLECTION_NAME, "guest", "guest");

                Resource resource = guestCollection.createResource("testguest", "BinaryResource");
View Full Code Here

TOP

Related Classes of org.exist.security.Permission

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.