Package co.cubicode.rbacframework.models

Examples of co.cubicode.rbacframework.models.Role


public class RBACTest extends ApiTest {

  @Test
  public void rbacTest() throws ObjectNotFoundException {
    User user = UserBiz.findByPrimaryKey(1L);
    Role role = RoleBiz.findByPrimaryKey(user.getRole().getId());
    List<RolePermission> ids = RolePermissionBiz.findByRoleAndApplication(role, ApplicationConstants.ADMIN);
    List<Permission> permissions = new ArrayList<Permission>();
    for (RolePermission rolePermission : ids) {
      Permission permission = PermissionBiz.findByPrimaryKey(rolePermission.getApplicationId(), rolePermission.getObjectTypeId(),
          rolePermission.getOperationTypeId());
      permissions.add(permission);
    }
    role.setPermissions(permissions);
    user.setRole(role);
    System.out.println(user);

    if (user.hasRole("administrator")) {
      System.out.println("Es administrador");
View Full Code Here


public class RoleTest extends ApiTest {

  @Test
  public void findByPrimaryKeyTest() throws ObjectNotFoundException {
    Role role = RoleBiz.findByPrimaryKey(1);
    System.out.println(role);
  }
View Full Code Here

    user.setPassword("admin");
    user.setCreateDate(Calendar.getInstance().getTime());
    user.setUpdateDate(Calendar.getInstance().getTime());
    user.setLastLogin(Calendar.getInstance().getTime());
    user.setStatus(Status.getElement(Status.class, Status.ACTIVE));
    Role role = new Role();
    role.setId(1);
    user.setRole(role);
    try {
      user = UserBiz.create(user);
    } catch (ObjectUpdateException e) {
      e.printStackTrace();
View Full Code Here

    user.setLastName("Sin apellido");
    String password = "Jfsebe4tbGvr";
    user.setPassword(PasswordUtils.hashPassword(password));
    user.setCreateDate(Calendar.getInstance().getTime());
    user.setStatus(Status.getElement(Status.class, Status.ACTIVE));
    Role role = new Role();
    role.setId(1);
    user.setRole(role);
    try {
      user = UserBiz.create(user);
    } catch (ObjectUpdateException e) {
      e.printStackTrace();
View Full Code Here

TOP

Related Classes of co.cubicode.rbacframework.models.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.