Package org.jresearch.flexess.core.model.uam

Examples of org.jresearch.flexess.core.model.uam.Permission


  protected void tearDown() throws Exception {
    setFixture(null);
  }

  public void testCheck() {
    Permission tested = getFixture();
   
    String iId = "testId";   
    tested.setId(iId);
    assertEquals(iId, tested.getId());
   
    Constraint iConstraint = UamFactory.eINSTANCE.createConstraint()
    PObject iPObject = UamFactory.eINSTANCE.createPObject();
   
    tested.setConstraint( iConstraint );
    tested.setPObject( iPObject );
   
    assertEquals( iConstraint, tested.getConstraint());
    assertEquals( iPObject, tested.getPObject());
   
    POperation[] iPOperations = new POperation[]{UamFactory.eINSTANCE.createPOperation(), UamFactory.eINSTANCE.createPOperation()};
   
       
    tested.getPOperation().add(iPOperations[0]);
    tested.getPOperation().add(iPOperations[1]);
   
    EList pOperations = tested.getPOperation();
   
    assertTrue(pOperations.contains(iPOperations[0]));
    assertTrue(pOperations.contains(iPOperations[1]));
  }
View Full Code Here


      if (op instanceof POperation) {
        createMetaOperation(poMeta, (POperation) op, withPermissions);
      }
    }
    for (Iterator<Permission> it3 = po.getPermission().iterator(); it3.hasNext();) {
      Permission perm = it3.next();
      ElementDescription ed = createElementDescription(perm);
      poMeta.addPermission(ed);
    }
    return poMeta;
View Full Code Here

    String annotation = EcoreUtil.getAnnotation(role, UamPackage.eNS_URI, IPObjectConstant.DESCRIPTION_ATTR);
    roleMetaInfo.setDescription(annotation);
    roleMetaInfo.setName(role.getName());

    for (Object perm : EMFUtil.getPermissions(role)) {
      Permission permission = (Permission) perm;
      IPermissionMetaInfo pm = loadPermission(modelId, permission);
      roleMetaInfo.addPermission(pm);
    }
    return roleMetaInfo;
  }
View Full Code Here

  private IRoleInstanceService roleInstanceService;

  @Override
  public void executeRule(IRuleDefinition rule) throws RuleExecutionException {
    Role role = (Role) rule.getParent();
    Permission permission = (Permission) rule.getSource();
    String appId = ((SecurityModel) permission.getEPackage()).getId();
    List<IRoleInstanceMetaInfo> instances = roleInstanceService.getRoleInstances(appId, role.getId());
    for (IRoleInstanceMetaInfo info : instances) {
      IPermissionInstanceMetaInfo permissionInstanceMetaInfo = permissionInstanceService.getPermissionInstanceImpl();
      List<EAttribute> attributes = permission.getEAttributes();
      for (EAttribute attribute : attributes) {
        permissionInstanceMetaInfo.addPermissionParameter(makePermissionParameter(permissionInstanceMetaInfo, attribute));
      }
      permissionInstanceMetaInfo.setPermissionId(permission.getId());
      permissionInstanceMetaInfo.setRoleInstance(info);
      info.addPermissionInstance(permissionInstanceMetaInfo);
      try {
        roleInstanceService.saveRoleInstance(info);
      } catch (DataModelException e) {
View Full Code Here

public class AttributeAddedRule extends ParameterAwareRule implements IRule {

  @Override
  public void executeRule(IRuleDefinition rule) throws RuleExecutionException {
    Permission permission = (Permission) rule.getParent();
    EAttribute attribute = (EAttribute) rule.getSource();
    String appId = ((SecurityModel) permission.getEPackage()).getId();
    List<IPermissionInstanceMetaInfo> permissions = permissionInstanceService.getPermissionInstanceByPermission(appId, permission.getId());
    for (IPermissionInstanceMetaInfo info : permissions) {
      info.addPermissionParameter(makePermissionParameter(info, attribute));
      try {
        permissionInstanceService.savePermissionInstance(info);
      } catch (DataModelException e) {
View Full Code Here

public class PermissionDAO extends EMFDaoSupport implements IPermissionDAO {

  @Override
  public IPermissionMetaInfo findPermission(String applicationId, String name) throws ObjectNotFoundException {
    Permission permission = getPermissionByName(applicationId, name);
    if (permission == null) {
      return null;
    }
    return loadPermission(applicationId, permission);
  }
View Full Code Here

  }

  @Override
  public IPermissionMetaInfo getPermission(String applicationId, String id) throws ObjectNotFoundException {
    Permission permission = getPermissionById(applicationId, id);
    if (permission == null) {
      return null;
    }
    return loadPermission(applicationId, permission);
  }
View Full Code Here

public class ChangeModel6 {

  public static SecurityModel generateModel(SecurityModel pack) {

    Permission regionalPermission = null;
    Collection<Permission> permissions = EcoreUtil.getObjectsByType(pack.getEClassifiers(), UamPackage.eINSTANCE.getPermission());
    for (Permission object : permissions) {
      if (object.getId().equals("regional_permission")) {
        regionalPermission = object;
      }
    }
    if (regionalPermission == null) {
      throw new AssertionFailedError("No test permission defined");
    }
    EAttribute region = (EAttribute) regionalPermission.getEStructuralFeature("region");
    region.setEType(EcorePackage.eINSTANCE.getEInt());
    return pack;
  }
View Full Code Here

    order.getEOperations().add(updateOp);

    final String USER_EXPRESSION = "context orders::user_permission inv: login=object.userId"; //$NON-NLS-1$
    final String REGION_EXPRESSION = "context orders::regional_permission inv: region=object.region"; //$NON-NLS-1$

    Permission regionalPermission = UamFactory.eINSTANCE.createPermission();
    regionalPermission.setId("regional_permission"); //$NON-NLS-1$
    regionalPermission.setName("regional_permission"); //$NON-NLS-1$
    Constraint constraint = UamFactory.eINSTANCE.createConstraint();
    regionalPermission.setConstraint(constraint);
    constraint.setExpession(REGION_EXPRESSION);
    region = EcoreFactory.eINSTANCE.createEAttribute();
    region.setName("region"); //$NON-NLS-1$
    EcoreUtil.setAnnotation(region, UamPackage.eNS_URI, "#description", "region where the order comes"); //$NON-NLS-1$ //$NON-NLS-2$
    region.setEType(EcorePackage.eINSTANCE.getEString());
    regionalPermission.getEStructuralFeatures().add(region);
    regionalPermission.setPObject(order);
    // EMFUtil.addPobject(regionalPermission, order);
    pack.getEClassifiers().add(regionalPermission);

    // viewOp.getPermission().add(regionalPermission);
    // createOp.getPermission().add(regionalPermission);
    // deleteOp.getPermission().add(regionalPermission);
    // updateOp.getPermission().add(regionalPermission);

    Permission userPermission = UamFactory.eINSTANCE.createPermission();
    userPermission.setId("user_permission"); //$NON-NLS-1$
    userPermission.setName("user_permission"); //$NON-NLS-1$
    Constraint userConstraint = UamFactory.eINSTANCE.createConstraint();
    userPermission.setConstraint(userConstraint);
    userConstraint.setExpession(USER_EXPRESSION);
    userID = EcoreFactory.eINSTANCE.createEAttribute();
    EcoreUtil.setAnnotation(userID, UamPackage.eNS_URI, IAttributeConstant.ANNOTATION_KEY_RUNTIME, "true"); //$NON-NLS-1$
    userID.setName("login"); //$NON-NLS-1$
    userID.setEType(EcorePackage.eINSTANCE.getEString());
    userPermission.getEStructuralFeatures().add(userID);
    pack.getEClassifiers().add(userPermission);

    Role manager = UamFactory.eINSTANCE.createRole();
    manager.setId("manager_role"); //$NON-NLS-1$
    manager.setName("regional manager"); //$NON-NLS-1$
    EcoreUtil.setAnnotation(manager, UamPackage.eNS_URI, "#description", "orders manager"); //$NON-NLS-1$ //$NON-NLS-2$
    pack.getEClassifiers().add(manager);
    EMFUtil.addPermission(manager, regionalPermission);

    Role customer = UamFactory.eINSTANCE.createRole();
    customer.setId("customer_role"); //$NON-NLS-1$
    customer.setName("customer"); //$NON-NLS-1$
    EcoreUtil.setAnnotation(customer, UamPackage.eNS_URI, "#description", "orders customer"); //$NON-NLS-1$ //$NON-NLS-2$
    pack.getEClassifiers().add(customer);
    userPermission.setPObject(order);
    // EMFUtil.addPobject(userPermission, order);
    // order.getPermission().add(userPermission);
    EMFUtil.addPermission(customer, userPermission);
    return pack;
  }
View Full Code Here

    super(xmlElement, converted);
  }

  @Override
  public Permission rawConvert() throws LoadModelException {
    Permission result = super.rawConvert();
    for (PermissionAttributeType attribute : getXmlElement().getPermissionAttribute()) {
      result.getEStructuralFeatures().add(new PermissionAttributeConverter(attribute).convert());
    }
    Constraint constraint = UamFactory.eINSTANCE.createConstraint();
    String expression = getXmlElement().getConstraint();
    constraint.setExpession(expression == null ? "true" : expression);
    result.setConstraint(constraint);
    return result;
  }
View Full Code Here

TOP

Related Classes of org.jresearch.flexess.core.model.uam.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.