Package co.cubicode.rbacframework.models

Examples of co.cubicode.rbacframework.models.Permission


    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");
    } else if (user.hasRole("operator")) {
      System.out.println("Es operador");
      Assert.fail();
    } else if (user.hasRole("guest")) {
      System.out.println("Es invitado");
      Assert.fail();
    } else {
      System.out.println("No tiene rol");
      Assert.fail();
    }
   
    Action action = Catalog.getElement(Action.class, "2");
    Permission permission = new Permission(action.getApplication(), action.getObjectType(), action.getOperationType());
    if (user.hasPermission(permission)) {
      Assert.fail();
    } else {
      System.out.println("No tiene permisos en web");
    }
View Full Code Here


  @Test
  public void findByPrimaryKeyTest() {
    Application application = Catalog.getElement(Application.class, ApplicationConstants.ADMIN);
    ObjectType objectType = Catalog.getElement(ObjectType.class, ObjectTypeConstants.USER);
    OperationType operationType = Catalog.getElement(OperationType.class, OperationType.CREATE);
    Permission permission = null;
    try {
      permission = PermissionBiz.findByPrimaryKey(application, objectType, operationType);
    } catch (ObjectNotFoundException e) {
      e.printStackTrace();
      Assert.fail();
View Full Code Here

TOP

Related Classes of co.cubicode.rbacframework.models.Permission

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.