Package com.streamreduce.core.model

Examples of com.streamreduce.core.model.Role


        assertNotNull(user);
        assertEquals(testUser.getId(), user.getId());
        assertTrue(baseline > 0);

        Set<Role> roles = userService.getAccountRoles(user.getAccountId());
        Role devRole = null;
        for (Role role : roles) {
            if (role.getName().equals(Roles.DEVELOPER_ROLE)) {
                devRole = role;
                break;
            }
        }
        assertNotNull(devRole);

        // make user admin
        makeRequest(getUrl() + "/" + user.getId() + "/roles/" + devRole.getId(), "POST", null, authToken);

        // get user again
        url = getUrl() + "/" + testUser.getUsername();
        user = jsonToObject(makeRequest(url, "GET", null, authToken), TypeFactory.defaultInstance().constructType(UserResponseDTO.class));
View Full Code Here


    /**
     * Bootstrap the initial Roles and their Permissions.
     */
    private void bootstrapRoles() {
        if (roleDAO.findRole(Roles.ADMIN_ROLE) == null) {
            Role admin = new Role(Roles.ADMIN_ROLE, "Administrator Role");
            admin.setPermissions(Permissions.ALL);
            roleDAO.save(admin);
        }
        if (roleDAO.findRole(Roles.DEVELOPER_ROLE) == null) {
            Role dev = new Role(Roles.DEVELOPER_ROLE, "Developer Role");
            dev.addPermissions(Permissions.APP_USER);
            roleDAO.save(dev);
        }
        if (roleDAO.findRole(Roles.USER_ROLE) == null) {
            Role user = new Role(Roles.USER_ROLE, "Required Role to Login");
            user.addPermissions(Permissions.APP_USER);
            roleDAO.save(user);
        }
    }
View Full Code Here

        User currentUser = securityService.getCurrentUser();

        try {

            Role adminRole = securityService.findRole(Roles.ADMIN_ROLE);
            if (currentUser.getId().equals(userId) && adminRole.getId().equals(roleId)) {
                // you can't remove the admin role from yourself!
                return error("You can not remove the administrator role from your own user.", Response.status(Response.Status.BAD_REQUEST));
            }

            User user = userService.getUserById(userId, currentUser.getAccount());
View Full Code Here

    }

    @Override
    public Set<Role> getUserRoles() {
        Set<Role> roles = new HashSet<>();
        Role r = roleDAO.findRole(Roles.USER_ROLE);
        roles.add(r);
        return roles;
    }
View Full Code Here

    }

    @Override
    public Set<Role> getAdminRoles() {
        Set<Role> roles = new HashSet<>();
        Role r = roleDAO.findRole(Roles.ADMIN_ROLE);
        roles.add(r);
        r = roleDAO.findRole(Roles.USER_ROLE);
        roles.add(r);
        return roles;
    }
View Full Code Here

        return accountDAO.find().asList();
    }

    @Override
    public void addRole(User user, ObjectId roleId) throws UserNotFoundException {
        Role role = roleDAO.get(roleId);
        // don't allow dupes if the same Id
        if (!(user.getRoles().contains(role))) {
            user.addRole(role);
            updateUser(user);
        }
View Full Code Here

TOP

Related Classes of com.streamreduce.core.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.