Package org.jdesktop.wonderland.server.security

Examples of org.jdesktop.wonderland.server.security.Resource


        private void processCell(CellDescription cell) {
            // add to the map of cells
            cells.put(cell.getCellID(), cell);

            CellResourceManager crm = AppContext.getManager(CellResourceManager.class);
            Resource resource = crm.getCellResource(cell.getCellID());
            if (resource != null) {
                // add the resource to the security check
                Resource r = new CellIDResource(cell.getCellID(), resource);
                rm.put(r.getId(), new ActionMap(r, new ViewAction()));
            }
        }
View Full Code Here


        // ignore
    }

    public Resource checkMessage(WonderlandClientID clientID, Message message) {
        CellResourceManager crm = AppContext.getManager(CellResourceManager.class);
        Resource out = null;

        // for each cell being modified, check that the caller has
        // permissions to modify the children of the parent cell
        CellEditMessage editMessage = (CellEditMessage) message;
        switch (editMessage.getEditType()) {
            case CREATE_CELL:
                CellCreateMessage ccm = (CellCreateMessage) editMessage;
                if (ccm.getParentCellID() != null) {
                    out = crm.getCellResource(ccm.getParentCellID());
                }
                break;
            case DELETE_CELL:
                {
                    // delete requires permission from both the cell being
                    // deleted and the parent cell
                    CellDeleteMessage cdm = (CellDeleteMessage) editMessage;
                    CellMO deleteMO = CellManagerMO.getCell(cdm.getCellID());
                    if (deleteMO == null ||
                            deleteMO.getCellID().equals(CellID.getEnvironmentCellID()))
                    {
                        break;
                    }
                    Resource child = crm.getCellResource(cdm.getCellID());
                    Resource parent = null;

                    // get the cell's parent, if any
                    CellMO parentMO = deleteMO.getParent();
                    if (parentMO != null) {
                        parent = crm.getCellResource(parentMO.getCellID());
                    }

                    // now create a delete resource with child & parent
                    if (child != null || parent != null) {
                        out = new DeleteCellResource(cdm.getCellID().toString(),
                                                     child, parent);
                    }
                }
                break;
            case DUPLICATE_CELL:
                CellDuplicateMessage cnm = (CellDuplicateMessage) editMessage;
                CellMO dupMO = CellManagerMO.getCell(cnm.getCellID());
                if (dupMO != null && dupMO.getParent() != null) {
                    out = crm.getCellResource(dupMO.getParent().getCellID());
                }
                break;

            case REPARENT_CELL:
                {
                    CellReparentMessage msg = (CellReparentMessage) editMessage;

                    CellMO childMO = CellManagerMO.getCell(msg.getCellID());
                    if (childMO==null)
                        break;

                    Resource child = crm.getCellResource(msg.getCellID());
                    Resource oldParent = null;
                    Resource newParent = null;

                    CellMO oldParentMO = childMO.getParent();
                    if (oldParentMO!=null)
                        oldParent = crm.getCellResource(oldParentMO.getCellID());
View Full Code Here

            return new ErrorResource();
        }

        // now find the resource to check for permissions on this cell
        CellResourceManager crm = AppContext.getManager(CellResourceManager.class);
        Resource cellResource = crm.getCellResource(message.getCellID());
        if (cellResource == null) {
            logger.warning("No resource for cell " + message.getCellID());
           
            // there is no security on this cell, so allow anyone to
            // connect
View Full Code Here

        // doing the setting) or if there are no owners.
        ClientIdentityManager cim = AppContext.getManager(ClientIdentityManager.class);
        WonderlandIdentity id = cim.getClientID();
        if (id != null && owners != null && !owners.isEmpty()) {
            // make a request to set the permissions if this is an owner
            Resource ownerRsrc = new OwnerResource(cellRef.get().getCellID().toString(),
                                                   owners);
            ActionMap am = new ActionMap(ownerRsrc, new OwnerAction());
            ResourceMap rm = new ResourceMap();
            rm.put(ownerRsrc.getId(), am);

            SecurityManager sec = AppContext.getManager(SecurityManager.class);
            SecureTask sst = new SetStateTask(id.getUsername(), ownerRsrc.getId(),
                                              this, scss.getPermissions());
            sec.doSecure(rm, sst);
        } else {
            // no security check, just set the values
            setCellPermissions(scss.getPermissions());
View Full Code Here

                       requestCellID + " to " + clientID);

        // get the resource for this cell
        CellResourceManagerInternal crmi =
                AppContext.getManager(CellResourceManagerInternal.class);
        Resource rsrc = crmi.getCellResource(requestCellID);
        if (rsrc == null) {
            // no resource -- send permission for everything
            Set<ActionDTO> send = new LinkedHashSet<ActionDTO>();
            for (Action action : crmi.getActions(requestCellID)) {
                send.add(new ActionDTO(action));
            }
            sender.send(clientID, new PermissionsResponseMessage(messageID, send));
            return;
        }

        // construct a request for this user's permissions
        ResourceMap rm = new ResourceMap();
        Action[] actions = crmi.getActions(requestCellID).toArray(new Action[0]);
        ActionMap am = new ActionMap(rsrc, actions);
        rm.put(rsrc.getId(), am);

        // construct a new task to send the message
        SecurityManager sm = AppContext.getManager(SecurityManager.class);
        SecureTask sendTask = new SendPermissionsTask(rsrc.getId(), sender,
                                                      clientID, messageID);
        sm.doSecure(rm, sendTask);
    }
View Full Code Here

                                 Message message)
    {
        if (message instanceof CellMessage) {
            CellResourceManager crm = AppContext.getManager(CellResourceManager.class);
            CellID id = ((CellMessage) message).getCellID();
            Resource rsrc = crm.getCellResource(id);
            return rsrc;
        }

        return null;
    }
View Full Code Here

                              " for client ID" + clientID +
                              " handled by " + handler.getConnectionType());
            }

            // determine if security is needed
            Resource resource = null;
            if (handler instanceof SecureClientConnectionHandler) {
                SecureClientConnectionHandler sec =
                        (SecureClientConnectionHandler) handler;
                resource = sec.checkMessage(getWonderlandClientID(), m);
            }
View Full Code Here

                      "No handler for " + type);
            return;
        }

        // determine if security is needed
        Resource resource = null;
        if (ref.get() instanceof SecureClientConnectionHandler) {
            SecureClientConnectionHandler sec =
                    (SecureClientConnectionHandler) ref.get();
            resource = sec.checkConnect(getWonderlandClientID(), properties);
        }
View Full Code Here

        // loop through each action set in the request, and generate
        // an appropriate response
        for (ActionMap set : request.values()) {
            // get the resource this set pertains to
            Resource resource = set.getResource();

            // create a response set that we will append the granted
            // permissions to
            ActionMap grantSet = new ActionMap(resource);
            grant.put(resource.getId(), grantSet);

            // create a set of requests to schedule.  We do not add the
            // set immediately -- it will be added at the end if it
            // is not empty
            ActionMap scheduleSet = new ActionMap(resource);

            // go through each action, and decider whether to grant or deny
            // access, or if necessary, schedule for later
            for (Action action : set.values()) {
                // query the resource about this permission, and handle the
                // result
                switch (resource.request(id.getIdentity(), action)) {
                    case GRANT:
                        // access is granted, add to the response list
                        grantSet.put(action.getName(), action);
                        break;
                    case DENY:
                        // access is denied -- nothing to do
                        break;
                    case SCHEDULE:
                        // add to the set to schedule
                        scheduleSet.put(action.getName(), action);
                        break;
                }
            }

            // if the schedule set is not empty, add it for scheduling
            if (!scheduleSet.isEmpty()) {
                schedule.put(resource.getId(), scheduleSet);
            }
        }

        // determine if we can respond immediately
        if (schedule.isEmpty()) {
View Full Code Here

        public void run() {
            // go through each request in the schedule set, and make the
            // request for it
            for (ActionMap m : schedule.values()) {
                // get the resource we are referring to
                Resource resource = m.getResource();

                // get the object that will hold the result of scheduled
                // requests
                ActionMap out = grant.get(resource.getId());
                if (out == null) {
                    out = new ActionMap(resource);
                    grant.put(resource.getId(), out);
                }

                // now make the requests
                for (Action a : m.values()) {
                    if (resource.request(identity.getIdentity(), a, registry)) {
                        out.put(a.getName(), a);
                    }
                }
            }
            try {
View Full Code Here

TOP

Related Classes of org.jdesktop.wonderland.server.security.Resource

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.