Package org.exist.security.internal.aider

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


        if( name == null ) {
            throw( new BuildException( "Must specify a group name" ) );
        }

        try {
            final GroupAider group = new GroupAider( name );

            log( "Adding group " + name, Project.MSG_INFO );
            service.addGroup( group );

        }
View Full Code Here


            removeAccounts(ums, new String[]{"test1", "test2", "test3"});

            //remove group 'users'
            removeGroups(ums, new String[]{"users"});

            final Group group = new GroupAider("exist", "users");
            ums.addGroup(group);

            UserAider user = new UserAider("test1", group);
            user.setPassword("test1");
            ums.addAccount(user);
           
            final Group extGroup = new GroupAider("exist", "extusers");
            ums.addGroup(extGroup);
            ums.addAccountToGroup("test1", "extusers");

            user = new UserAider("test2", group);
            user.setPassword("test2");
View Full Code Here

        UserManagementService ums = (UserManagementService)root.getService("UserManagementService", "1.0");

        final String group1Name = "testGroup1";
        final String group2Name = "testGroup2";
        final String userName = "testUser";
        Group group1 = new GroupAider(group1Name);
        Group group2 = new GroupAider(group2Name);
        Account user = new UserAider(userName, group1);

        try {
            ums.addGroup(group1);
            ums.addGroup(group2);
View Full Code Here

        Collection col = null;
        try {
            col = DatabaseManager.getCollection(baseUri + "/db", uid, pwd);
            final UserManagementService ums = (UserManagementService) col.getService("UserManagementService", "1.0");

            Group group = new GroupAider("exist", group_uid);
            ums.addGroup(group);
        } catch(final XMLDBException xmldbe) {
            throw new ApiException(xmldbe);
        } finally {
            if(col != null) {
View Full Code Here

      throw xPathException;
    }

    logger.info("Attempting to create group " + groupName);

    Group group = new GroupAider(groupName);

    final DBBroker broker = context.getBroker();
    final Subject currentUser = broker.getSubject();

    try {

      final SecurityManager sm = broker.getBrokerPool().getSecurityManager();

      // add the current user as a group manager
      group.addManager(currentUser);

      if (args.length == 2) {
        // add the additional group managers, this also makes sure they
        // all exist first!
        for (final SequenceIterator i = args[1].iterate(); i.hasNext();) {
          final String groupManager = i.nextItem().getStringValue();

          final Account groupManagerAccount = sm.getAccount(groupManager);
          if (groupManagerAccount == null) {
            logger.error("Could not find the user: " + groupManager);
            // throw exception is better -shabanovd
            return BooleanValue.FALSE;
          }
          group.addManager(groupManagerAccount);
        }
      }

      // create the group
      group = sm.addGroup(group);

            //TEMP - ESCALATE TO DBA :-(
            //START TEMP - we also need to make every manager a member of the group otherwise
            //they do not show up as group members automatically - this is a design problem because group
            //membership is managed on the user and not the group, this needs to be fixed!
            //see XMLDBAddUserToGroup and XMLDBRemoveUserFromGroup also
            final Subject currentSubject = context.getBroker().getSubject();
            try {
                //escalate
                context.getBroker().setSubject(sm.getSystemSubject());

                //perform action
                for(final Account manager : group.getManagers()) {
                    manager.addGroup(group);
                    sm.updateAccount(manager);
                }
            } finally {
                context.getBroker().setSubject(currentSubject);
View Full Code Here

                return null;
            }
                    
            final UserAider u;
            if(tab.get("default-group-id") != null) {
                final GroupAider defaultGroup = new GroupAider(
                    (Integer) tab.get("default-group-id"),
                    (String) tab.get("default-group-realmId"),
                    (String) tab.get("default-group-name")
                );
               
View Full Code Here

                params.add(name);
               
                final Map<String,Object> tab = (HashMap<String,Object>) parent.getClient().execute("getGroup", params);
               
                if(tab != null && !tab.isEmpty()) {
                    final Group group = new GroupAider((Integer)tab.get("id"), (String) tab.get("realmId"), (String) tab.get("name"));
                   
                    final Object[] managers = (Object[]) tab.get("managers");
                    for(final Object manager : managers) {
                        group.addManager(getAccount((String)manager));
                    }
                   
                    final Map<String, String> metadata = (Map<String, String>)tab.get("metadata");
                    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));
                        }
                    }
                   
                    return group;
                }
View Full Code Here

                    }

                    final String[] subGroups;
                    if(getSignature().getArgumentCount() == 3 || getSignature().getArgumentCount() == 5) {
                        //create the personal group
                        final Group group = new GroupAider(username);
                        group.setMetadataValue(EXistSchemaType.DESCRIPTION, "Personal group for " + username);
                        group.addManager(currentUser);
                        securityManager.addGroup(group);

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

                        subGroups = getGroups(args[2]);
                    } else {
                        //add the primary group as the primary group
                        user.addGroup(args[2].getStringValue());

                        subGroups = getGroups(args[3]);
                    }

                    for(int i = 0; i <  subGroups.length; i++) {
                        user.addGroup(subGroups[i]);
                    }

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

                    //if we created a personal group, then add the new account as a manager of their personal group
                    if(getSignature().getArgumentCount() == 3 || getSignature().getArgumentCount() == 5) {
                        final Group group = securityManager.getGroup(username);
                        group.addManager(securityManager.getAccount(username));
                        securityManager.updateGroup(group);
                    }
                } else {
                    throw new XPathException("Unknown function call: " + getSignature());
                }
View Full Code Here

                if(!currentSubject.hasDbaRole()) {
                    throw new XPathException("Only DBA users may create a user group.");
                }

                final Group group = new GroupAider(groupName);
                group.addManager(currentSubject);

                if(getSignature().getArgumentCount() == 3) {
                    //set group managers
                    final List<Account> groupManagers = getGroupManagers(securityManager, args[1]);
                    group.addManagers(groupManagers);
                }

                //set metadata
                if(getSignature().getArgumentCount() >= 2) {
                    group.setMetadataValue(EXistSchemaType.DESCRIPTION, args[getSignature().getArgumentCount() - 1].toString());
                }

                securityManager.addGroup(group);

            } else if(isCalledAs(qnRemoveGroup.getLocalName()) || isCalledAs(qnDeleteGroup.getLocalName())) {
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.