Package org.candlepin.model

Examples of org.candlepin.model.Role


        userResource.createUser(user);

        Owner owner1 = createOwner();
        Owner owner2 = createOwner();

        Role owner1Role = new Role(owner1.getKey() + " role");
        Role owner2Role = new Role(owner2.getKey() + " role");
        owner1Role.addPermission(new PermissionBlueprint(PermissionType.OWNER, owner1,
            Access.ALL));
        owner1Role.addPermission(new PermissionBlueprint(PermissionType.OWNER, owner2,
            Access.READ_ONLY));
        owner1Role.addUser(user);
        owner2Role.addUser(user);
        roleCurator.create(owner1Role);
        roleCurator.create(owner2Role);

        Set<Permission> perms = new HashSet<Permission>();
        perms.add(new OwnerPermission(owner1, Access.ALL));
View Full Code Here


        user.setPassword("password");
        userResource.createUser(user);

        Owner owner1 = createOwner();

        Role owner1Role = new Role(owner1.getKey() + " role");
        owner1Role.addPermission(new PermissionBlueprint(PermissionType.USERNAME_CONSUMERS,
            owner1, Access.ALL));
        owner1Role.addUser(user);
        roleCurator.create(owner1Role);

        Set<Permission> perms = new HashSet<Permission>();
        perms.add(new UsernameConsumersPermission(user, owner1));
        Principal userPrincipal = new UserPrincipal(user.getUsername(), perms, false);
View Full Code Here

        return userCurator.findByLogin(login);
    }

    @Override
    public void deleteRole(String roleId) {
        Role r = roleCurator.find(roleId);
        roleCurator.delete(r);
    }
View Full Code Here

        s.add(myUser);

        for (Role r : myUser.getRoles()) {
            // Copy onto a detached role object so we can omit users list, which could
            // technically leak information here.
            Role copy = new Role(r.getName());
            copy.setId(r.getId());
            copy.setPermissions(r.getPermissions());
            copy.setUsers(s);
            roles.add(copy);
        }
        return roles;
    }
View Full Code Here

        // as coming from userService
        owner = new Owner("test_owner");
        PermissionBlueprint p = new PermissionBlueprint(PermissionType.OWNER, owner,
            Access.ALL);
        User user = new User("anyuser", "");
        role = new Role();
        role.addPermission(p);
        role.addUser(user);
        when(userService.findByLogin("anyuser")).thenReturn(user);
        return systemtype;
    }
View Full Code Here

        consumerTypeCurator.create(personType);

        User user = new User(newUsername, "password");
        userCurator.create(user);

        Role adminRole = createAdminRole(owner);
        adminRole.addUser(user);
        roleCurator.create(adminRole);

        assertNull(consumerCurator.findByUser(user));

        consumer = new Consumer(CONSUMER_NAME, newUsername, owner, personType);
View Full Code Here

    }

    @Test
    public void testCreate() throws Exception {

        Role r = createRole(owner);

        Role lookedUp = roleCurator.find(r.getId());
        assertEquals(1, lookedUp.getPermissions().size());
        assertEquals(1, lookedUp.getUsers().size());
    }
View Full Code Here

        userCurator.create(user);

        PermissionBlueprint p = new PermissionBlueprint(PermissionType.OWNER, o,
            Access.ALL);

        Role r = new Role("role" + TestUtil.randomInt());
        r.addPermission(p);
        r.addUser(user);
        roleCurator.create(r);
        return r;
    }
View Full Code Here

    @Test
    public void testListForOwner() {
        Owner o2 = createOwner();

        Role r1 = createRole(owner);
        createRole(o2);

        List<Role> roles = roleCurator.listForOwner(owner);
        assertEquals(1, roles.size());
        assertEquals(r1, roles.get(0));
View Full Code Here

        assertEquals(1, roles.get(0).getPermissions().size());
    }

    @Test
    public void testAddPermission() {
        Role role = new Role("myrole");
        roleCurator.create(role);
        role.addPermission(new PermissionBlueprint(PermissionType.OWNER, owner,
            Access.ALL));
        role = roleCurator.find(role.getId());
        assertEquals(1, role.getPermissions().size());
        PermissionBlueprint perm = role.getPermissions().iterator().next();
        assertNotNull(perm.getId());
    }
View Full Code Here

TOP

Related Classes of org.candlepin.model.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.