Package org.exist.security

Examples of org.exist.security.Group


    /* (non-Javadoc)
     * @see org.exist.security.User#addGroup(java.lang.String)
     */
    @Override
    public Group addGroup(final String name) {
        final Group role = new GroupAider(realmId, name)
        roles.put(name, role);
        return role;
    }
View Full Code Here


      Node node;
      Element next;
      Account account;
      NodeList ul;
//      String lastId;
      Group group;
      for (int i = 0; i < nl.getLength(); i++) {
        if (nl.item(i).getNodeType() != Node.ELEMENT_NODE)
          {continue;}
        next = (Element) nl.item(i);
        if ("users".equals(next.getTagName())) {
//          lastId = next.getAttribute("last-id");
//          try {
//            nextUserId = Integer.parseInt(lastId);
//          } catch (NumberFormatException e) {
//          }
          ul = next.getChildNodes();
          for (int j = 0; j < ul.getLength(); j++) {
            node = ul.item(j);
            if (node.getNodeType() == Node.ELEMENT_NODE && "user".equals(node.getLocalName())) {
              account = createAccount(major, minor, (Element) node);
             
              if (sm.hasAccount(account.getName())) {
                                sm.updateAccount(account);
              } else {
                sm.addAccount(account);
              }
            }
          }
        } else if ("groups".equals(next.getTagName())) {
//          lastId = next.getAttribute("last-id");
//          try {
//            nextGroupId = Integer.parseInt(lastId);
//          } catch (NumberFormatException e) {
//          }
          ul = next.getChildNodes();
          for (int j = 0; j < ul.getLength(); j++) {
            node = ul.item(j);
            if (node.getNodeType() == Node.ELEMENT_NODE && "group".equals(node.getLocalName())) {
              group = createGroup((Element) node);

              if (sm.hasGroup(group.getName())) {
                sm.updateGroup(group);
              } else {
                sm.addGroup(group);
              }
            }
View Full Code Here

    }//GEN-LAST:event_btnCreateActionPerformed

    protected void createGroup() {
       
        //1 - create the group
        Group group = null;
        try {
            final GroupAider groupAider = new GroupAider(txtGroupName.getText());
            groupAider.setMetadataValue(EXistSchemaType.DESCRIPTION, txtDescription.getText());
            getUserManagementService().addGroup(groupAider);
           
            //get the created group
            group = getUserManagementService().getGroup(txtGroupName.getText());
        } catch(final XMLDBException xmldbe) {
            JOptionPane.showMessageDialog(this, "Could not create group '" + txtGroupName.getText() + "': " + xmldbe.getMessage(), "Create Group Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
       
        //2 - add the users to the group and set managers
        for(int i = 0; i < getGroupMembersTableModel().getRowCount(); i++) {
            final String member = (String)getGroupMembersTableModel().getValueAt(i, 0);

            try {
                getUserManagementService().addAccountToGroup(member, group.getName());
               
                final boolean isManager = (Boolean)getGroupMembersTableModel().getValueAt(i, 1);
                if(isManager) {
                    getUserManagementService().addGroupManager(member, group.getName());
                }
            } catch(final XMLDBException xmldbe) {
                JOptionPane.showMessageDialog(this, "Could not add user '" + member + "' to group '" + group.getName() + "': " + xmldbe.getMessage(), "Create Group Error", JOptionPane.ERROR_MESSAGE);
                return;
            }
        }
       
        setVisible(false);
View Full Code Here


    @Override
    public boolean deleteGroup(String name) throws PermissionDeniedException, EXistException {

        final Group group = getGroup(name);
        if (group == null) {
            return false;
        }

        if (group.getRealmId() == null) {
            throw new ConfigurationException("Group must have realm id.");
        }
       
        groupLocks.getWriteLock(group).lock();
        try {
            return findRealmForRealmId(group.getRealmId()).deleteGroup(group);
        } finally {
            groupLocks.getWriteLock(group).unlock();
        }
    }
View Full Code Here

    }

    @Override
    public Group getGroup(String name) {
      for(final Realm realm : realms) {
            final Group group = realm.getGroup(name);
            if(group != null){
                return group;
            }
      }
        return null;
View Full Code Here

                final ErrorReport.CollectionError error = new ErrorReport.CollectionError( ErrorReport.ACCESS_FAILED, "Owner account not found for collection: " + collection.getURI());
                error.setCollectionId( collection.getId() );
                error.setCollectionURI( collection.getURI() );
                errorList.add(error);
            }
            Group group = perms.getGroup();
            if (group == null) {
                final ErrorReport.CollectionError error = new ErrorReport.CollectionError( ErrorReport.ACCESS_FAILED, "Owner group not found for collection: " + collection.getURI());
                error.setCollectionId( collection.getId() );
                error.setCollectionURI( collection.getURI() );
                errorList.add(error);
View Full Code Here

            Permission perms = doc.getPermissions();
            Account owner = perms.getOwner();
            if (owner == null) {
                return new ErrorReport.ResourceError(ErrorReport.RESOURCE_ACCESS_FAILED, "Owner account not found for document " + doc.getFileURI());
            }
            Group group = perms.getGroup();
            if (group == null) {
                return new ErrorReport.ResourceError(ErrorReport.RESOURCE_ACCESS_FAILED, "Owner group not found for document " + doc.getFileURI());
            }
        } catch(Exception e) {
            return new ErrorReport.ResourceError(ErrorReport.RESOURCE_ACCESS_FAILED, "Exception caught while checking permissions on document " + doc.getFileURI(), e);
View Full Code Here

    }//GEN-LAST:event_tblUsersMouseClicked

    private void miEditGroupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miEditGroupActionPerformed
        final String selectedGroup = getSelectedGroup();
            try {
                final Group group = userManagementService.getGroup(selectedGroup);
                showEditGroupDialog(group);
            } catch(final XMLDBException xmldbe) {
                JOptionPane.showMessageDialog(this, "Could not edit group '" + selectedGroup + "': " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
            }
    }//GEN-LAST:event_miEditGroupActionPerformed
View Full Code Here

   
    private void miRemoveGroupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miRemoveGroupActionPerformed
        final String selectedGroup = getSelectedGroup();
       
        try {
            final Group group = userManagementService.getGroup(selectedGroup);
            userManagementService.removeGroup(group);
       
            groupsTableModel.removeRow(tblGroups.getSelectedRow());
        } catch(final XMLDBException xmldbe) {
            JOptionPane.showMessageDialog(this, "Could not remove group '" + selectedGroup + "': " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
View Full Code Here

       
        miRemoveGroup.setEnabled(canDelete);
       
         if(evt.getClickCount() == 2) {
            try {
                final Group group = userManagementService.getGroup(selectedGroup);
                showEditGroupDialog(group);
            } catch(final XMLDBException xmldbe) {
                JOptionPane.showMessageDialog(this, "Could not edit group '" + selectedGroup + "': " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
            }
        }
View Full Code Here

TOP

Related Classes of org.exist.security.Group

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.