Package org.candlepin.model

Examples of org.candlepin.model.PermissionBlueprint


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


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

        ConsumerType systemtype = new ConsumerType(
            ConsumerType.ConsumerTypeEnum.PERSON);
        // create an owner, a ownerperm, and roles for the user we prodive
        // 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);
View Full Code Here

    private Role createRole(Owner o) {
        User user = new User(RandomStringUtils.random(5), "pass");
        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);
View Full Code Here

    @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

        TestPrincipalProviderSetter.get().setPrincipal(p);
        return p;
    }

    public Role createAdminRole(Owner owner) {
        PermissionBlueprint p = new PermissionBlueprint(PermissionType.OWNER, owner,
            Access.ALL);
        Role role = new Role("testrole" + TestUtil.randomInt());
        role.addPermission(p);
        return role;
    }
View Full Code Here

            "OwnerResource should have thrown BadRequestException");
    }

    @Test
    public void cleanupWithOutstandingPermissions() {
        PermissionBlueprint p = new PermissionBlueprint(PermissionType.OWNER, owner,
            Access.ALL);
        Role r = new Role("rolename");
        r.addPermission(p);
        roleCurator.create(r);
        ownerResource.deleteOwner(owner.getKey(), false);
View Full Code Here

        this.system = initSystem();

        owner = new Owner("test_owner");
        user = new User(USER, "");
        PermissionBlueprint p = new PermissionBlueprint(PermissionType.OWNER, owner,
            Access.ALL);
        role = new Role();
        role.addPermission(p);
        role.addUser(user);
View Full Code Here

            ConsumerType.ConsumerTypeEnum.PERSON);

        // create an owner, an ownerperm, and roles for the user we provide
        // 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);
View Full Code Here

                                      @PathParam("perm_id") String permissionId) {

        Role existingRole = lookupRole(roleId);
        Set<PermissionBlueprint> picks = new HashSet<PermissionBlueprint>();
        boolean found = true;
        PermissionBlueprint toRemove = null;
        for (PermissionBlueprint op : existingRole.getPermissions()) {
            if (!op.getId().equals(permissionId)) {
                picks.add(op);
            }
            else {
                found = true;
                toRemove = op;
            }

        }
        if (!found) {
            throw new NotFoundException(i18n.tr("No such permission: {0} in role: {1}",
                permissionId, roleId));
        }

        existingRole.setPermissions(picks);
        Role r = this.userService.updateRole(existingRole);
        toRemove.setOwner(null);
        permissionCurator.delete(toRemove);
        return r;
    }
View Full Code Here

TOP

Related Classes of org.candlepin.model.PermissionBlueprint

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.