Examples of UserManagementService


Examples of org.exist.xmldb.UserManagementService

        assertEquals(userName, account.getAttributes().getNamedItem("name").getNodeValue());
    }

    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
        ums.addGroupManager(username, group.getName());
    }
View Full Code Here

Examples of org.exist.xmldb.UserManagementService

    @Test
    public void checkGroupMembership() throws XMLDBException, PermissionDeniedException {

        Collection root = DatabaseManager.getCollection(baseUri + "/db", "admin", "");
        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);

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

        } finally {
            //cleanup
            try { ums.removeGroup(group1); } catch(Exception e) {}
            try { ums.removeGroup(group2); } catch(Exception e) {}
            try { ums.removeAccount(user); } catch(Exception e) {}
        }
    }
View Full Code Here

Examples of org.exist.xmldb.UserManagementService

                    col = DatabaseManager.getCollection(URI + "/" + XUPDATE_COLLECTION);
                    if(col == null) {
                        Collection root = DatabaseManager.getCollection(URI, "admin", "");
                        CollectionManagementService mgtService = (CollectionManagementService) root.getService("CollectionManagementService", "1.0");
                        col = mgtService.createCollection(XUPDATE_COLLECTION);
                        UserManagementService ums = (UserManagementService) col.getService("UserManagementService", "1.0");
                        // change ownership to guest
                        Account guest = ums.getAccount("guest");
                        ums.chown(guest, guest.getPrimaryGroup());
                        ums.chmod(Permission.DEFAULT_COLLECTION_PERM);

                        System.out.println("collection created.");
                    }
            } catch (Exception e) {
                    e.printStackTrace();
View Full Code Here

Examples of org.exist.xmldb.UserManagementService

    protected void chownCol(final String collectionUri, final String owner_uid, final String group_gid, final String uid, final String pwd) throws ApiException {
       
        Collection col = null;
        try {
            col = DatabaseManager.getCollection(baseUri + collectionUri, uid, pwd);
            final UserManagementService ums = (UserManagementService) col.getService("UserManagementService", "1.0");
           
            ums.chown(ums.getAccount(owner_uid), group_gid);
        } catch(final XMLDBException xmldbe) {
            throw new ApiException(xmldbe);
        } finally {
            if(col != null) {
                try {
View Full Code Here

Examples of org.exist.xmldb.UserManagementService

    protected void chmodCol(final String collectionUri, final String mode, final String uid, final String pwd) throws ApiException {
       
        Collection col = null;
        try {
            col = DatabaseManager.getCollection(baseUri + collectionUri, uid, pwd);
            final UserManagementService ums = (UserManagementService) col.getService("UserManagementService", "1.0");

            ums.chmod(mode);
        } catch(final XMLDBException xmldbe) {
            throw new ApiException(xmldbe);
        } finally {
            if(col != null) {
                try {
View Full Code Here

Examples of org.exist.xmldb.UserManagementService

        Collection col = null;
        try {
            col = DatabaseManager.getCollection(baseUri + getCollectionUri(resourceUri), uid, pwd);
           
            final Resource resource = col.getResource(getResourceName(resourceUri));
            final UserManagementService ums = (UserManagementService) col.getService("UserManagementService", "1.0");
           
            ums.chown(resource, ums.getAccount(owner_uid), group_gid);
        } catch(final XMLDBException xmldbe) {
            throw new ApiException(xmldbe);
        } finally {
            if(col != null) {
                try {
View Full Code Here

Examples of org.exist.xmldb.UserManagementService

        Collection col = null;
        try {
            col = DatabaseManager.getCollection(baseUri + getCollectionUri(resourceUri), uid, pwd);
           
            final Resource resource = col.getResource(getResourceName(resourceUri));
            final UserManagementService ums = (UserManagementService) col.getService("UserManagementService", "1.0");
            ums.chmod(resource, mode);
        } catch(final XMLDBException xmldbe) {
            throw new ApiException(xmldbe);
        } finally {
            if(col != null) {
                try {
View Full Code Here

Examples of org.exist.xmldb.UserManagementService

    @Override
    protected void removeAccount(final String account_uid, final String uid, final String pwd) throws ApiException {
        Collection col = null;
        try {
            col = DatabaseManager.getCollection(baseUri + "/db", uid, pwd);
            final UserManagementService ums = (UserManagementService) col.getService("UserManagementService", "1.0");

            final Account acct = ums.getAccount(account_uid);
            if(acct != null){
                ums.removeAccount(acct);
            }
        } catch(final XMLDBException xmldbe) {
            throw new ApiException(xmldbe);
        } finally {
            if(col != null) {
View Full Code Here

Examples of org.exist.xmldb.UserManagementService

    @Override
    protected void removeGroup(String group_uid, String uid, String pwd) throws ApiException {
        Collection col = null;
        try {
            col = DatabaseManager.getCollection(baseUri + "/db", uid, pwd);
            final UserManagementService ums = (UserManagementService) col.getService("UserManagementService", "1.0");

            final Group grp = ums.getGroup(group_uid);
            if(grp != null){
                ums.removeGroup(grp);
            }
        } catch(final XMLDBException xmldbe) {
            throw new ApiException(xmldbe);
        } finally {
            if(col != null) {
View Full Code Here

Examples of org.exist.xmldb.UserManagementService

    @Override
    protected void createAccount(String account_uid, String account_pwd, String group_uid, String uid, String pwd) throws ApiException {
        Collection col = null;
        try {
            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 {
            if(col != null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.