Package org.jdesktop.wonderland.modules.security.common

Examples of org.jdesktop.wonderland.modules.security.common.Principal


        // add the current user as an owner
        ServerSessionManager primarySM = LoginManager.getPrimary();
        if (primarySM != null) {
            WonderlandSession primarySession = primarySM.getPrimarySession();
            if (primarySession != null) {
                Principal owner = new Principal(
                        primarySession.getUserID().getUsername(),
                        Principal.Type.USER);
                perms.getOwners().add(owner);
            }
        }

        // add view permissions for all users
        Principal p = new Principal("users", Principal.Type.EVERYBODY);
        ActionDTO view = new ActionDTO(new ViewAction());
        perms.getPermissions().add(new Permission(
                p, view, Permission.Access.GRANT));
        ActionDTO modify = new ActionDTO(new ModifyAction());
        perms.getPermissions().add(new Permission(
View Full Code Here


            type = Type.USER;
        } else {
            type = Type.GROUP;
        }

        perms.addRow(new Principal(addNameTF.getText(), type));
    }//GEN-LAST:event_addOKButtonActionPerformed
View Full Code Here

    }//GEN-LAST:event_addOKButtonActionPerformed

    private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed
        int curRow = permsTable.getSelectedRow();

        Principal p = perms.getPrincipal(curRow);
        SortedSet<Permission> ps = perms.getPerms(curRow);
        Set<ActionDTO> aps = new HashSet<ActionDTO>(perms.getAllPerms());

        edit.removeAllChildren();
        edit.setUserObject(new PrincipalHolder(p));

        // build the tree of actions
        Map<Action, DefaultMutableTreeNode> actions =
                new HashMap<Action, DefaultMutableTreeNode>();
        while (!aps.isEmpty()) {
            for (Iterator<ActionDTO> i = aps.iterator(); i.hasNext();) {
                ActionDTO actionDTO = i.next();
                Action action = actionDTO.getAction();
                DefaultMutableTreeNode node = null;

                if (action.getParent() == null) {
                    // top level action
                    node = new DefaultMutableTreeNode(new ActionHolder(action));
                    edit.add(node);
                } else if (actions.containsKey(action.getParent())) {
                    // we found the parent of this action -- add it to
                    // the tree
                    node = new DefaultMutableTreeNode(new ActionHolder(action));
                    actions.get(action.getParent()).add(node);
                }

                if (node != null) {
                    i.remove();
                    actions.put(action, node);

                    // find the associated permission, if any
                    Permission search = new Permission(p, actionDTO, null);
                    SortedSet<Permission> tail = ps.tailSet(search);
                    if (!tail.isEmpty() && tail.first().equals(search)) {
                        ActionHolder ah = (ActionHolder) node.getUserObject();
                        ah.setAccess(tail.first().getAccess());
                    }
                }
            }
        }

        // reset the model on the tree
        editPermsTree.setModel(new DefaultTreeModel(edit));
        editPermPermCombo.setEnabled(false);
        editPermPermCombo.setSelectedIndex(0);
        editPermDescription.setText(BUNDLE.getString("Choose_Permission"));

        // expand the tree
        int row = 0;
        while (row < editPermsTree.getRowCount()) {
            editPermsTree.expandRow(row);
            row++;
        }

        editPermsTree.setRootVisible(false);
        String text = BUNDLE.getString("Edit_Permission_For");
        text = MessageFormat.format(text, p.getId());
        editPermsPrincipalLabel.setText(text);
        editPermsDialog.pack();
        editPermsDialog.setVisible(true);

        editPermsTree.invalidate();
View Full Code Here

        public CellPermissions toPermissions() {
            CellPermissions out = new CellPermissions();

            for (int i = 0; i < principals.size(); i++) {
                Principal p = principals.get(i);
                if (owner.get(i)) {
                    out.getOwners().add(p);
                } else {
                    out.getPermissions().addAll(perms.get(i));
                }
View Full Code Here

        public int getColumnCount() {
            return 4;
        }

        public Object getValueAt(int rowIndex, int columnIndex) {
            Principal p;

            switch (columnIndex) {
                case 0:
                    p = principals.get(rowIndex);
                    return p.getType().toString();
                case 1:
                    p = principals.get(rowIndex);

                    // special case -- if the princpal is an everybody
                    // principal (the "users" group), display the name as
                    // "everyone else"
                    String name = p.getId();
                    if (p.getType() == Principal.Type.EVERYBODY) {
                        name = BUNDLE.getString("Everybody");
                    }

                    return name;
                case 2:
View Full Code Here

   
    public Set<Principal> getRemotePrincipals(String username) {
        Set<Principal> out = new LinkedHashSet<Principal>();
       
        // add the user principal based on this user's username
        out.add(new Principal(username, Type.USER));

        // add the default group principal
        out.add(new Principal(defaultGroup, Type.EVERYBODY));

        // get the credential manager to use
        CredentialManager cm = ServerAuthentication.getAuthenticationService();
        try {
            // request this user's groups
            Set<GroupDTO> groups =
                    GroupUtils.getGroupsForUser(BASE_URL, username, false, cm);
            for (GroupDTO g : groups) {
                out.add(new Principal(g.getId(), Type.GROUP));
            }
        } catch (IOException ex) {
            logger.log(Level.WARNING, "Error reading groups for " + username +
                       " from " + BASE_URL, ex);
        } catch (JAXBException ex) {
View Full Code Here

TOP

Related Classes of org.jdesktop.wonderland.modules.security.common.Principal

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.