Package org.osgi.service.useradmin

Examples of org.osgi.service.useradmin.Role


        if (roles.get(name) != null) {
            // role 'name' already exists, abort and return null
            return null;
        }

        Role role;
        switch (type) {
        case Role.USER:
            role = new UserImpl(name);
            break;
        case Role.GROUP:
View Full Code Here


       
        m_latch = new CountDownLatch(1);
       
        new Thread(new Runnable() {
            public void run() {
                Role anyone = m_repository.getRoleByName(Role.USER_ANYONE);
                assertTrue(role.addMember(anyone));
            };
        }).start();

        assertTrue(m_latch.await(1, TimeUnit.SECONDS));
View Full Code Here

       
        m_latch = new CountDownLatch(1);
       
        new Thread(new Runnable() {
            public void run() {
                Role anyone = m_repository.getRoleByName(Role.USER_ANYONE);
                assertTrue(role.addRequiredMember(anyone));
            };
        }).start();

        assertTrue(m_latch.await(100, TimeUnit.SECONDS));
View Full Code Here

    /**
     * Tests that changing the properties of a user-role yields an event.
     */
    public void testAddRolePropertiesYieldsEvent() throws Exception {
        final Role role = m_repository.addRole("testUser", Role.USER);
        assertNotNull(role);
       
        m_latch = new CountDownLatch(1);
       
        new Thread(new Runnable() {
            public void run() {
                role.getProperties().put("key", "value");
            };
        }).start();

        assertTrue(m_latch.await(1, TimeUnit.SECONDS));
    }
View Full Code Here

    /**
     * Tests that changing the credentials of a user-role yields an event.
     */
    public void testChangePropertiesYieldsEvent() throws Exception {
        final Role role = m_repository.addRole("testUser", Role.USER);
        role.getProperties().put("key", "value1");
        assertNotNull(role);
       
        m_latch = new CountDownLatch(1);
       
        new Thread(new Runnable() {
            public void run() {
                role.getProperties().put("key", "value2");
            };
        }).start();

        assertTrue(m_latch.await(1, TimeUnit.SECONDS));
    }
View Full Code Here

    /**
     * Tests that changing the properties of a user-role yields an event.
     */
    public void testRemoveRolePropertiesYieldsEvent() throws Exception {
        final Role role = m_repository.addRole("testUser", Role.USER);
        role.getProperties().put("key", "value");
        assertNotNull(role);
       
        m_latch = new CountDownLatch(1);
       
        new Thread(new Runnable() {
            public void run() {
                role.getProperties().remove("key");
            };
        }).start();

        assertTrue(m_latch.await(1, TimeUnit.SECONDS));
    }
View Full Code Here

    /**
     * Tests that removing a member from a group-role yields an event.
     */
    public void testRemovingGroupMemberYieldsEvent() throws Exception {
        final Role anyone = m_repository.getRoleByName(Role.USER_ANYONE);
        final Group role = (Group) m_repository.addRole("testGroup", Role.GROUP);
        assertNotNull(role);
        role.addRequiredMember(anyone);
       
        m_latch = new CountDownLatch(1);
View Full Code Here

        public Role addRole(String roleName, int type) throws IOException {
            if (roleName == null) {
                throw new IllegalArgumentException("Name cannot be null!");
            }

            Role role = createRole(roleName, type);

            Object result = m_entries.putIfAbsent(roleName, role);
            return (result == null) ? role : null;
        }
View Full Code Here

            }
           
            List matchingRoles = new ArrayList();
            Iterator rolesIter = roles.iterator();
            while (rolesIter.hasNext()) {
                Role role = (Role) rolesIter.next();
                if ((filter == null) || filter.match(role.getProperties())) {
                    matchingRoles.add(role);
                }
            }

            Role[] result = new Role[matchingRoles.size()];
View Full Code Here

        public Role removeRole(String roleName) throws Exception {
            if (roleName == null) {
                throw new IllegalArgumentException("Name cannot be null!");
            }
            Role role = getRoleByName(roleName);
            boolean result = m_entries.remove(roleName, role);
            return result ? role : null;
        }
View Full Code Here

TOP

Related Classes of org.osgi.service.useradmin.Role

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.