Examples of UserRegistry


Examples of org.wso2.carbon.registry.core.session.UserRegistry

        return getUserRegistry(userName, tenantId, null);
    }

    public UserRegistry getUserRegistry(String userName, int tenantId, String chroot)
            throws RegistryException {
        return new UserRegistry(userName, tenantId, registry, realmService,
                RegistryUtils.concatenateChroot(this.chroot, chroot));
    }
View Full Code Here

Examples of org.wso2.carbon.registry.core.session.UserRegistry

            log.error(msg);
            throw new RegistryException(msg);
        }
        // first we will get an anonymous user registry associated with the tenant
        realmService.getBootstrapRealmConfiguration();
        UserRegistry anonymousUserRegistry = new UserRegistry(
                CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME,
                tenantId,
                registry,
                realmService,
                null);
        return anonymousUserRegistry.getUserRealm();
    }
View Full Code Here

Examples of org.wso2.carbon.registry.core.session.UserRegistry

    // Test each registry has different virtual roots
    public void testVirtualRoots() throws Exception {

        RealmConfiguration realmConfig = ctx.getRealmService().getBootstrapRealmConfiguration();
        UserRegistry registry1 =
                embeddedRegistryService.getUserRegistry(realmConfig.getAdminUserName(), 0);
        Resource r = registry1.newResource();
        registry1.put("/test", r);

        r = registry1.get("/");
        r.addProperty("name", "value");
        registry1.put("/", r);

        UserRegistry registry2 =
                embeddedRegistryService.getUserRegistry(realmConfig.getAdminUserName(), 1);
        r = registry2.get("/");
        Properties p = r.getProperties();
        assertEquals("The properties in the second registry should be 0", p.size(), 0);

        boolean notExist = false;
        try {
            registry2.get("/test");
        } catch (ResourceNotFoundException e) {
            notExist = true;
        }
        assertTrue("The /test should be null in the second registry", notExist);
View Full Code Here

Examples of org.wso2.carbon.registry.core.session.UserRegistry

        // embeddedRegistryService = new InMemoryEmbeddedRegistryService();
        // get the realm config to retrieve admin username, password
        RealmConfiguration realmConfig = ctx.getRealmService().getBootstrapRealmConfiguration();
       
        UserRegistry adminRegistry = embeddedRegistryService.
                getUserRegistry(realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
        UserRealm adminRealm = adminRegistry.getUserRealm();

        adminRealm.getUserStoreManager().addUser("foo", "cce123", null, null, null);
        adminRealm.getUserStoreManager();

        adminRealm.getAuthorizationManager().
                authorizeUser("foo", RegistryConstants.ROOT_PATH, ActionConstants.PUT);
        adminRealm.getUserStoreManager().addUser("bar", "swe123", null, null, null);

        UserRegistry fooRegistry = embeddedRegistryService.getUserRegistry("foo", "cce123");
        UserRegistry barRegistry = embeddedRegistryService.getUserRegistry("bar", "swe123");

        String r1Content = "R1";
        Resource r1 = fooRegistry.newResource();
        r1.setContent(r1Content.getBytes());

        fooRegistry.put("/r1", r1);

        adminRegistry.applyTag("/r1", "java");
        fooRegistry.applyTag("/r1", "java");
        barRegistry.applyTag("/r1", "java");

        Tag[] tags1 = adminRegistry.getTags("/r1");
        assertEquals("There should be 3 taggings on resource '/r1'", 3, tags1[0].getTagCount());

        // owner of the /r1 removes a tag. all tags should be removed
        fooRegistry.removeTag("/r1", "java");
        Tag[] tags2 = adminRegistry.getTags("/r1");
        assertEquals("There should be 0 taggings on resource '/r1'", 0, tags2.length);

        adminRegistry.applyTag("/r1", "java");
        fooRegistry.applyTag("/r1", "java");
        barRegistry.applyTag("/r1", "java");

        // admin removes a tag. all tags should be removed
        adminRegistry.removeTag("/r1", "java");
        Tag[] tags3 = adminRegistry.getTags("/r1");
        assertEquals("There should be 0 taggings on resource '/r1'", 0, tags3.length);

        adminRegistry.applyTag("/r1", "java");
        fooRegistry.applyTag("/r1", "java");
        barRegistry.applyTag("/r1", "java");

        // normal user removes a tag. only the tag applied by the user is removed
        barRegistry.removeTag("/r1", "java");
        Tag[] tags4 = adminRegistry.getTags("/r1");
        assertEquals("There should be 2 taggings on resource '/r1'", 2, tags4[0].getTagCount());
    }
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.