Package org.exist.security.internal.aider

Examples of org.exist.security.internal.aider.GroupAider


        return defaultRealm.getGroups();
    }
   
    @Override
    public void addGroup(String name) throws PermissionDeniedException, EXistException {
        addGroup(new GroupAider(name));
    }
View Full Code Here


   
    return new_account;
  }
 
  public static Group createGroup(Element element) {
    return new GroupAider(RealmImpl.ID, element.getAttribute("name")); //, Integer.parseInt(element.getAttribute("id")
  }
View Full Code Here

    }//GEN-LAST:event_btnCreateActionPerformed

    protected void createUser() {
       
        //1 - create personal group
        GroupAider groupAider = null;
        if(cbPersonalGroup.isSelected()) {
            groupAider = new GroupAider(txtUsername.getText());
            groupAider.setMetadataValue(EXistSchemaType.DESCRIPTION, "Personal group for " + txtUsername.getText());
            try {
                getUserManagementService().addGroup(groupAider);
            } catch(final XMLDBException xmldbe) {
                JOptionPane.showMessageDialog(this, "Could not create personal group '" + txtUsername.getText() + "': " + xmldbe.getMessage(), "Create User Error", JOptionPane.ERROR_MESSAGE);
                return;
            }
        }
       
        //2 - create the user
        final UserAider userAider = new UserAider(txtUsername.getText());
        userAider.setMetadataValue(AXSchemaType.FULLNAME, txtFullName.getText());
        userAider.setMetadataValue(EXistSchemaType.DESCRIPTION, txtDescription.getText());
        userAider.setPassword(txtPassword.getText());
        userAider.setEnabled(!cbDisabled.isSelected());
        userAider.setUserMask(UmaskSpinnerModel.octalUmaskToInt((String)spnUmask.getValue()));
       
        //add the personal group to the user
        if(cbPersonalGroup.isSelected()) {
            userAider.addGroup(txtUsername.getText());
        }
       
        //add any other groups to the user
        final Iterator<String> itMemberOfGroups = memberOfGroupsModel.iterator();
        while(itMemberOfGroups.hasNext()) {
            final String memberOfGroup = itMemberOfGroups.next();
            userAider.addGroup(memberOfGroup);
        }
       
        //set the primary group
        try {
            userAider.setPrimaryGroup(new GroupAider(getPrimaryGroup()));
        } catch(final PermissionDeniedException pde) {
            JOptionPane.showMessageDialog(this, "Could not set primary group '" + getPrimaryGroup() + "' of user '" + txtUsername.getText() + "': " + pde.getMessage(), "Create User Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
       
        try {
            getUserManagementService().addAccount(userAider);
        } catch(final XMLDBException xmldbe) {
            JOptionPane.showMessageDialog(this, "Could not create user '" + txtUsername.getText() + "': " + xmldbe.getMessage(), "Create User Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
       
        //3 - if created personal group, then add us as the manager
        if(cbPersonalGroup.isSelected()) {
            try {
                groupAider.addManager(userAider);
                getUserManagementService().updateGroup(groupAider);
            } catch(final XMLDBException xmldbe) {
                JOptionPane.showMessageDialog(this, "Could not set user '" + txtUsername.getText() + "' as manager of personal group '" + txtUsername.getText() + "': " + xmldbe.getMessage(), "Create User Error", JOptionPane.ERROR_MESSAGE);
                return;
            } catch(final PermissionDeniedException pde) {
View Full Code Here

    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) {
View Full Code Here

    private void checkUserSettings() throws PackageException {
        final org.exist.security.SecurityManager secman = broker.getBrokerPool().getSecurityManager();
        try {
            if (group != null && !secman.hasGroup(group)) {
                final GroupAider aider = new GroupAider(group);
                secman.addGroup(aider);
            }
            if (user != null && !secman.hasAccount(user)) {
                final UserAider aider = new UserAider(user);
                aider.setPassword(password);
                if (group != null)
                    {aider.addGroup(group);}

                secman.addAccount(aider);
            }
        } catch (final ConfigurationException e) {
            throw new PackageException("Failed to create user: " + user, e);
View Full Code Here

      if (primaryGroup == null)
        try {
          primaryGroup = executeAsSystemUser(new Unit<Group>() {
            @Override
            public Group execute(DBBroker broker) throws EXistException, PermissionDeniedException {
              return addGroup(new GroupAider(ID, OAUTH));
            }
          });
               
          if (primaryGroup == null)
            throw new ConfigurationException("OAuth realm can not create primary group 'OAuth'.");
View Full Code Here

    }
   
    private Group createGroupInDatabase(final String groupname) throws AuthenticationException {
        try {
            //return sm.addGroup(instantiateGroup(this, groupname));
            return getSecurityManager().addGroup(new GroupAider(ID, groupname));

        } catch(Exception e) {
            throw new AuthenticationException(AuthenticationException.UNNOWN_EXCEPTION, e.getMessage(), e);
        }
    }
View Full Code Here

        final Account user = new UserAider(username);
        user.setPassword(password);

        //create the personal group
        Group group = new GroupAider(username);
        group.setMetadataValue(EXistSchemaType.DESCRIPTION, "Personal group for " + username);
        group.addManager(ums.getAccount("admin"));
        ums.addGroup(group);

        //add the personal group as the primary group
        user.addGroup(username);

        //create the account
        ums.addAccount(user);

        //add the new account as a manager of their personal group
        ums.addGroupManager(username, group.getName());
    }
View Full Code Here

           
            if(!manager.hasAdminPrivileges(user)) {
                throw new PermissionDeniedException("Not allowed to create group");
            }
           
            final Group role = new GroupAider(name);
           
            for(final String key : metadata.keySet()) {
                if(AXSchemaType.valueOfNamespace(key) != null) {
                    role.setMetadataValue(AXSchemaType.valueOfNamespace(key), metadata.get(key));
                } else if(EXistSchemaType.valueOfNamespace(key) != null) {
                    role.setMetadataValue(EXistSchemaType.valueOfNamespace(key), metadata.get(key));
                }
            }
           
           
            try {
View Full Code Here

      
        final SecurityManager manager = factory.getBrokerPool().getSecurityManager();

      if(manager.hasGroup(name)) {
       
            final GroupAider group = new GroupAider(name);
       
            for(final String groupManager : managers) {
                group.addManager(new UserAider(groupManager));
            }

            if(metadata != null) {
                for(final String key : metadata.keySet()) {
                    if(AXSchemaType.valueOfNamespace(key) != null) {
                        group.setMetadataValue(AXSchemaType.valueOfNamespace(key), metadata.get(key));
                    } else if(EXistSchemaType.valueOfNamespace(key) != null) {
                        group.setMetadataValue(EXistSchemaType.valueOfNamespace(key), metadata.get(key));
                    }
                }
            }
           
            try {
View Full Code Here

TOP

Related Classes of org.exist.security.internal.aider.GroupAider

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.