Package org.exist.security.internal.aider

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


                    for(String memberOf_groupName : memberOf_groupNames) {
                        memberOf_groups.add(getGroup(invokingUser, memberOf_groupName));
                    }*/

                    //create the user account
                    final UserAider userAider = new UserAider(ID, username, primaryGroup);

                    //add the member groups
                    for(final Group memberOf_group : getGroupMembershipForLdapUser(ctx, ldapUser)) {
                        userAider.addGroup(memberOf_group);
                    }

                    //store any requested metadata
                    for(final SimpleEntry<AXSchemaType, String> metadata : getMetadataForLdapUser(ldapUser)) {
                        userAider.setMetadataValue(metadata.getKey(), metadata.getValue());
                    }

                    final Account account = getSecurityManager().addAccount(userAider);

                    //LDAPAccountImpl account = sm.addAccount(instantiateAccount(ID, username));
View Full Code Here


    private void createUser(final String username, final String password) throws XMLDBException, PermissionDeniedException {
        final Collection root = DatabaseManager.getCollection("xmldb:exist:///db", "admin", "");
        final UserManagementService ums = (UserManagementService) root.getService("UserManagementService", "1.0");

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

        if(!manager.hasAdminPrivileges(user)) {
            throw new PermissionDeniedException("Account '"+user.getName()+"' not allowed to create new account");
        }

        final UserAider u = new UserAider(name);
        u.setEncodedPassword(passwd);
        u.setPasswordDigest(passwdDigest);

        for(final String g : groups) {
            if(!u.hasGroup(g)) {
                u.addGroup(g);
            }
        }
       
        if(enabled != null) {
            u.setEnabled(enabled);
        }
       
        if(umask != null) {
            u.setUserMask(umask);
        }
       
        if(metadata != null) {
            for(final String key : metadata.keySet()) {
                if(AXSchemaType.valueOfNamespace(key) != null) {
                    u.setMetadataValue(AXSchemaType.valueOfNamespace(key), metadata.get(key));
                } else if(EXistSchemaType.valueOfNamespace(key) != null) {
                    u.setMetadataValue(EXistSchemaType.valueOfNamespace(key), metadata.get(key));
                }
            }
        }
       
        try {
View Full Code Here

    public boolean updateAccount(final String name, String passwd, final String passwdDigest, final Vector<String> groups, final Boolean enabled, final Integer umask, final Map<String, String> metadata) throws EXistException, PermissionDeniedException {
        if(passwd.length() == 0) {
            passwd = null;
        }
       
        final UserAider account = new UserAider(name);
        account.setEncodedPassword(passwd);
        account.setPasswordDigest(passwdDigest);

        for(final String g : groups) {
            account.addGroup(g);
        }
       
        if(enabled != null) {
            account.setEnabled(enabled);
        }
       
        if(umask != null) {
            account.setUserMask(umask);
        }
       
        if(metadata != null) {
            for(final String key : metadata.keySet()) {
                if(AXSchemaType.valueOfNamespace(key) != null) {
                    account.setMetadataValue(AXSchemaType.valueOfNamespace(key), metadata.get(key));
                } else if(EXistSchemaType.valueOfNamespace(key) != null) {
                    account.setMetadataValue(EXistSchemaType.valueOfNamespace(key), metadata.get(key));
                }
            }
        }
       
        final SecurityManager manager = factory.getBrokerPool().getSecurityManager();
View Full Code Here

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

          broker = factory.getBrokerPool().get(user);
         
          Account u;

          if (!manager.hasAccount(name)) {
            u = new UserAider(name);
          } else {
            u = manager.getAccount(name);
          }

          for (final String g : groups) {
View Full Code Here

            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");
            ums.addAccount(user);

            user = new UserAider("test3", ums.getGroup("guest"));
            user.setPassword("test3");
            ums.addAccount(user);

            // create a collection /db/securityTest1 as owned by "test1:users" and mode 0770
            CollectionManagementService cms = (CollectionManagementService)root.getService("CollectionManagementService", "1.0");
            Collection test = cms.createCollection("securityTest1");
View Full Code Here

        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);

            ums.addAccount(user);
            ums.getAccount(userName);
            user.addGroup(group2);

            ums.updateAccount(user);

            /*** RESTART THE SERVER ***/
            stopServer();
            startServer();
            /**************************/

            root = DatabaseManager.getCollection(baseUri + "/db", "admin", "");
            ums = (UserManagementService)root.getService("UserManagementService", "1.0");

            user = ums.getAccount("testUser");
            assertNotNull(user);

            Group defaultGroup = user.getDefaultGroup();
            assertNotNull(defaultGroup);
            assertEquals(group1Name, defaultGroup.getName());

            String groups[] = user.getGroups();
            assertNotNull(groups);
            assertEquals(2, groups.length);
            assertEquals(group1Name, groups[0]);
            assertEquals(group2Name, groups[1]);

View Full Code Here

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

            final Group group = ums.getGroup(group_uid);

            final Account user = new UserAider(account_uid, group);
            user.setPassword(account_pwd);
            ums.addAccount(user);
           
        } catch(final XMLDBException xmldbe) {
            throw new ApiException(xmldbe);
        } finally {
View Full Code Here

            if(tab == null || tab.isEmpty()) {
                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")
                );
               
                u = new UserAider(
                    (String) tab.get("realmId"),
                    (String) tab.get("name"),
                    defaultGroup
                );
            } else {
                u = new UserAider(
                    (String) tab.get("realmId"),
                    (String) tab.get("name")
                );
            }

            final Object[] groups = (Object[]) tab.get("groups");
            for(final Object group : groups) {
                u.addGroup((String) group);
            }
           
            u.setEnabled(Boolean.valueOf((String)tab.get("enabled")));
            u.setUserMask((Integer)tab.get("umask"));
           
            final Map<String, String> metadata = (Map<String, String>)tab.get("metadata");
            for(final String key : metadata.keySet()) {
                if(AXSchemaType.valueOfNamespace(key) != null) {
                    u.setMetadataValue(AXSchemaType.valueOfNamespace(key), metadata.get(key));
                } else if(EXistSchemaType.valueOfNamespace(key) != null) {
                    u.setMetadataValue(EXistSchemaType.valueOfNamespace(key), metadata.get(key));
                }
            }
           
            return u;
                       
View Full Code Here

TOP

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

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.